Truly independent web browser
LibWeb: Keep a flicked touchpad gesture held into its momentum
Zaggy10246e241be6c01f
diff --git a/Libraries/LibWeb/HTML/LocalNavigable.cpp b/Libraries/LibWeb/HTML/LocalNavigable.cppindex 29fdbc4a7b9..d816a8d511e 100644--- a/Libraries/LibWeb/HTML/LocalNavigable.cpp+++ b/Libraries/LibWeb/HTML/LocalNavigable.cpp@@ -5295,7 +5295,8 @@ void LocalNavigable::note_user_scroll_gesture_phase(Web::ScrollGesturePhase phasif (!travels_under_momentum)reset_momentum_fling_state();- if (m_wheel_user_scroll_gesture_hold && m_user_scroll_gesture_travels_under_momentum != travels_under_momentum)+ // Fingers that touch down during momentum start another gesture, which settles the flicked one.+ if (m_wheel_user_scroll_gesture_hold && m_user_scroll_gesture_travels_under_momentum && !travels_under_momentum)release_wheel_user_scroll_gesture_hold();m_user_scroll_gesture_travels_under_momentum = travels_under_momentum;diff --git a/Tests/LibWeb/Text/expected/async-scrolling/fling-ends-once.txt b/Tests/LibWeb/Text/expected/async-scrolling/fling-ends-once.txtnew file mode 100644index 00000000000..5ab20205482--- /dev/null+++ b/Tests/LibWeb/Text/expected/async-scrolling/fling-ends-once.txt@@ -0,0 +1,2 @@+plain: scrollend events before the momentum ended: 0, in all: 1+snapping: scrollend events before the momentum ended: 0, in all: 1diff --git a/Tests/LibWeb/Text/input/async-scrolling/fling-ends-once.html b/Tests/LibWeb/Text/input/async-scrolling/fling-ends-once.htmlnew file mode 100644index 00000000000..ad9e680b3cb--- /dev/null+++ b/Tests/LibWeb/Text/input/async-scrolling/fling-ends-once.html@@ -0,0 +1,60 @@+<!DOCTYPE html>+<script src="../include.js"></script>+<style>+ body {+ margin: 0;+ }++ .scroller {+ width: 200px;+ height: 200px;+ overflow: scroll;+ }++ .content {+ height: 5000px;+ }++ #snapping {+ scroll-snap-type: y mandatory;+ }++ #snapping .area {+ height: 200px;+ scroll-snap-align: start;+ }+</style>+<div class="scroller" id="plain"><div class="content"></div></div>+<div class="scroller" id="snapping"></div>+<script>+ promiseTest(async () => {+ const snapping = document.getElementById("snapping");+ for (let i = 0; i < 25; i++) {+ const area = document.createElement("div");+ area.className = "area";+ snapping.appendChild(area);+ }+ await animationFrame();+ await animationFrame();++ // The fingers of a flick lift, and its momentum carries the scroll on. The scroll ends once, with the momentum.+ const fling = async (scroller, y) => {+ let scrollends = 0;+ scroller.addEventListener("scrollend", () => scrollends++);+ internals.wheelThroughUIProcess(50, y, 0, 0, true, "began");+ for (let step = 0; step < 3; step++)+ await internals.wheelThroughUIProcess(50, y, 0, 50, true, "ongoing");+ for (let step = 0; step < 5; step++) {+ await internals.wheelThroughUIProcess(50, y, 0, 30, true, "momentum");+ await animationFrame();+ }+ const scrollendsBeforeMomentumEnded = scrollends;+ await internals.wheelThroughUIProcess(50, y, 0, 0, true, "ended");+ await new Promise(resolve => setTimeout(resolve, 1000));+ println(`${scroller.id}: scrollend events before the momentum ended: ${scrollendsBeforeMomentumEnded}, in all: ${scrollends}`);+ };++ await fling(document.getElementById("plain"), 50);+ await fling(snapping, 250);+ });+</script>