From 3eb9ae4ed57612a55ebab397a4060bfffb5e6a05 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Sun, 6 Aug 2023 14:36:02 +0200 Subject: [PATCH] LibWeb: Find closest scrollable paintable to call handle_mousewheel() This makes event handler to try to find scrollable paintable in the chain of containing blocks of hit box. This is very naive and will have to be improved in the future. --- Userland/Libraries/LibWeb/Page/EventHandler.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index 0ea1aff1b0..ae6f19d209 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -163,6 +163,15 @@ bool EventHandler::handle_mousewheel(CSSPixelPoint position, unsigned button, un if (auto result = target_for_mouse_position(position); result.has_value()) paintable = result->paintable; + auto* containing_block = paintable->containing_block(); + while (containing_block) { + if (containing_block->is_scrollable()) { + const_cast(containing_block->paintable_box())->handle_mousewheel({}, position, buttons, modifiers, wheel_delta_x * scroll_step_size, wheel_delta_y * scroll_step_size); + break; + } + containing_block = containing_block->containing_block(); + } + if (paintable) { paintable->handle_mousewheel({}, position, buttons, modifiers, wheel_delta_x, wheel_delta_y);