Skip to content

Truly independent web browser

Compositor: Leave wheel steps to the main thread before a display list

Aliaksandr Kalenika02023427c4d
diff --git a/Services/Compositor/ContextState.cpp b/Services/Compositor/ContextState.cpp
index c25fa344e96..a0e90d0e4b1 100644
--- a/Services/Compositor/ContextState.cpp
+++ b/Services/Compositor/ContextState.cpp
@@ -782,6 +782,11 @@ ContextState::AsyncScrollResult ContextState::async_scroll_by(
{
auto now = now_for_testing.value_or(MonotonicTime::now());
+ // Nothing hit tests a wheel before the first display list shows where the scrollers are, and the page can let a
+ // touchpad step through to here before then.
+ if (!m_has_async_scrolling_state)
+ return AsyncScrollResult::declined(Web::InputRoutingDecision::NoAsyncScrollingState);
+
// The UI hands this context every wheel event before WebContent's main thread passes it on. A step that the main
// thread passes on after the UI sent one it cannot come before must neither latch a scroller nor pull a stretch,
// since nothing would be left to let go of either.
diff --git a/Tests/LibWeb/Crash/UIEvents/wheel-from-ui-before-first-frame-with-blocking-listener.html b/Tests/LibWeb/Crash/UIEvents/wheel-from-ui-before-first-frame-with-blocking-listener.html
new file mode 100644
index 00000000000..9cdcea86b9a
--- /dev/null
+++ b/Tests/LibWeb/Crash/UIEvents/wheel-from-ui-before-first-frame-with-blocking-listener.html
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<script>
+ // The blocking listener makes the compositor's wheel listener state stale before any display list reaches it.
+ addEventListener("wheel", () => {}, { passive: false });
+ internals.wheelThroughUIProcess(10, 10, 0, 10, true, "ongoing");
+</script>