From c5da92f664a22b367b4bac0a9a45da971097df82 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Fri, 3 Oct 2025 17:51:22 +0200 Subject: [PATCH] LibWeb: Try to dispatch wheel event on hit-testing target first ...before falling back to containing block. Fixes a bug when we can't scroll innermost scrollable element, because wheel event dispatching immediately falls back to containing block. --- Libraries/LibWeb/Page/EventHandler.cpp | 2 +- ...ld-be-consumed-by-innermost-scrollable.txt | 1 + ...d-be-consumed-by-innermost-scrollable.html | 70 +++++++++++++++++++ 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/wheel-event-should-be-consumed-by-innermost-scrollable.txt create mode 100644 Tests/LibWeb/Text/input/wheel-event-should-be-consumed-by-innermost-scrollable.html diff --git a/Libraries/LibWeb/Page/EventHandler.cpp b/Libraries/LibWeb/Page/EventHandler.cpp index ccbaeb88122..6c0bd2d4686 100644 --- a/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Libraries/LibWeb/Page/EventHandler.cpp @@ -408,7 +408,7 @@ EventResult EventHandler::handle_mousewheel(CSSPixelPoint viewport_position, CSS paintable = result->paintable; if (paintable) { - auto* containing_block = paintable->containing_block(); + Painting::Paintable* containing_block = paintable; while (containing_block) { auto handled_scroll_event = containing_block->handle_mousewheel({}, viewport_position, buttons, modifiers, wheel_delta_x, wheel_delta_y); if (handled_scroll_event) diff --git a/Tests/LibWeb/Text/expected/wheel-event-should-be-consumed-by-innermost-scrollable.txt b/Tests/LibWeb/Text/expected/wheel-event-should-be-consumed-by-innermost-scrollable.txt new file mode 100644 index 00000000000..1b47d5e9c43 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wheel-event-should-be-consumed-by-innermost-scrollable.txt @@ -0,0 +1 @@ +inner.scrollTop: 100, inner.scrollLeft: 0 diff --git a/Tests/LibWeb/Text/input/wheel-event-should-be-consumed-by-innermost-scrollable.html b/Tests/LibWeb/Text/input/wheel-event-should-be-consumed-by-innermost-scrollable.html new file mode 100644 index 00000000000..49cf69c0f8d --- /dev/null +++ b/Tests/LibWeb/Text/input/wheel-event-should-be-consumed-by-innermost-scrollable.html @@ -0,0 +1,70 @@ + + + +
+
+
+
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
+
+
+
+