From 0afbd827e01d101d464c5687c664af1afdaaad0e Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Sun, 17 Mar 2024 08:02:52 +0100 Subject: [PATCH] LibWeb: Skip page scrolling for wheel events consumed by scrollable box Leftover from 90879a07ba6ab3cf61c52b3d601f1ed5052b807c --- ...ble-should-not-be-propagated-to-body-2.txt | 2 ++ ...le-should-not-be-propagated-to-body-2.html | 33 +++++++++++++++++++ .../Libraries/LibWeb/Page/EventHandler.cpp | 3 +- 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Text/expected/wheel-events-consumed-by-scrollable-should-not-be-propagated-to-body-2.txt create mode 100644 Tests/LibWeb/Text/input/wheel-events-consumed-by-scrollable-should-not-be-propagated-to-body-2.html diff --git a/Tests/LibWeb/Text/expected/wheel-events-consumed-by-scrollable-should-not-be-propagated-to-body-2.txt b/Tests/LibWeb/Text/expected/wheel-events-consumed-by-scrollable-should-not-be-propagated-to-body-2.txt new file mode 100644 index 00000000000..a6cf81cb72e --- /dev/null +++ b/Tests/LibWeb/Text/expected/wheel-events-consumed-by-scrollable-should-not-be-propagated-to-body-2.txt @@ -0,0 +1,2 @@ + scrollable.scrollTop: 200 +window.scrollY: 0 diff --git a/Tests/LibWeb/Text/input/wheel-events-consumed-by-scrollable-should-not-be-propagated-to-body-2.html b/Tests/LibWeb/Text/input/wheel-events-consumed-by-scrollable-should-not-be-propagated-to-body-2.html new file mode 100644 index 00000000000..07ef31afd4a --- /dev/null +++ b/Tests/LibWeb/Text/input/wheel-events-consumed-by-scrollable-should-not-be-propagated-to-body-2.html @@ -0,0 +1,33 @@ + + +
+
+
+ + diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index a79e0535b10..bc337ab4502 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -180,7 +180,8 @@ bool EventHandler::handle_mousewheel(CSSPixelPoint position, CSSPixelPoint scree containing_block = containing_block->containing_block(); } - paintable->handle_mousewheel({}, position, buttons, modifiers, wheel_delta_x, wheel_delta_y); + if (paintable->handle_mousewheel({}, position, buttons, modifiers, wheel_delta_x, wheel_delta_y)) + return true; auto node = dom_node_for_event_dispatch(*paintable);