Title: [285797] trunk
Revision
285797
Author
simon.fra...@apple.com
Date
2021-11-14 20:06:38 -0800 (Sun, 14 Nov 2021)

Log Message

Fingers down on the trackpad should stop an animated scroll
https://bugs.webkit.org/show_bug.cgi?id=233114

Reviewed by Wenson Hsieh.
Source/WebCore:

Fingers down on the trackpad sends a "MayBegin" event; this needs to stop any in-progress
animated momentum scroll.

This failed because ScrollingTreeScrollingNodeDelegateMac::handleWheelEvent() early-returned
on the MayBegin event before it got to ScrollingEffectsController. Fix that, and have
ScrollingEffectsController::handleWheelEvent() return true to say it was handled.

This triggered an assertion in ScrollingTreeGestureState, but for "post-main-thread"
handling for which the assertion was wrong.

Test: fast/scrolling/mac/momentum-animator-maybegin-stops.html

* page/scrolling/ScrollingTreeGestureState.cpp:
(WebCore::ScrollingTreeGestureState::nodeDidHandleEvent):
* page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm:
(WebCore::ScrollingTreeScrollingNodeDelegateMac::handleWheelEvent):
* platform/mac/ScrollingEffectsController.mm:
(WebCore::ScrollingEffectsController::handleWheelEvent):

LayoutTests:

* fast/scrolling/mac/momentum-animator-maybegin-stops-expected.txt: Added.
* fast/scrolling/mac/momentum-animator-maybegin-stops.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (285796 => 285797)


--- trunk/LayoutTests/ChangeLog	2021-11-15 02:45:28 UTC (rev 285796)
+++ trunk/LayoutTests/ChangeLog	2021-11-15 04:06:38 UTC (rev 285797)
@@ -1,3 +1,13 @@
+2021-11-14  Simon Fraser  <simon.fra...@apple.com>
+
+        Fingers down on the trackpad should stop an animated scroll
+        https://bugs.webkit.org/show_bug.cgi?id=233114
+
+        Reviewed by Wenson Hsieh.
+
+        * fast/scrolling/mac/momentum-animator-maybegin-stops-expected.txt: Added.
+        * fast/scrolling/mac/momentum-animator-maybegin-stops.html: Added.
+
 2021-11-13  Simon Fraser  <simon.fra...@apple.com>
 
         Run a ScrollAnimationMomentum for the momentum phase of a scroll

Added: trunk/LayoutTests/fast/scrolling/mac/momentum-animator-maybegin-stops-expected.txt (0 => 285797)


--- trunk/LayoutTests/fast/scrolling/mac/momentum-animator-maybegin-stops-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/momentum-animator-maybegin-stops-expected.txt	2021-11-15 04:06:38 UTC (rev 285797)
@@ -0,0 +1,7 @@
+Momentum event reached main thread
+PASS scrollEventCount > 0 is true
+PASS scrollEventCount is scrollEventCountAtMayBegin
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/scrolling/mac/momentum-animator-maybegin-stops.html (0 => 285797)


--- trunk/LayoutTests/fast/scrolling/mac/momentum-animator-maybegin-stops.html	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/momentum-animator-maybegin-stops.html	2021-11-15 04:06:38 UTC (rev 285797)
@@ -0,0 +1,119 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ MomentumScrollingAnimatorEnabled=true ] -->
+<html>
+<head>
+    <style>
+        body {
+            height: 2000px;
+            width: 200%;
+        }
+    </style>
+    <script src=""
+    <script src=""
+    <script>
+        var jsTestIsAsync = true;
+        
+        let sawMomentumEvent = false;
+        let sawFingersDown = false;
+        let scrollEventCount = 0;
+        let scrollEventCountAtMayBegin = 0;
+        
+        async function testEventSequence()
+        {
+            const events = [
+                {
+                    type : "wheel",
+                    viewX : 100,
+                    viewY : 100,
+                    deltaY : -10, // Note that this delta is currently ignored.
+                    phase : "began"
+                },
+                {
+                    type : "wheel",
+                    deltaY : -50,
+                    phase : "changed"
+                },
+                {
+                    type : "wheel",
+                    phase : "ended"
+                },
+                {
+                    type : "wheel",
+                    deltaY : -60,
+                    momentumPhase : "began"
+                },
+                {
+                    type: "wheel",
+                    viewX : 101, // defeat coalescing
+                    deltaY : -99,
+                    momentumPhase: "changed"
+                },
+                {
+                    type: "wheel",
+                    viewX : 102, // defeat coalescing
+                    deltaY : -80,
+                    momentumPhase: "changed"
+                },
+                {
+                    type : "wheel",
+                    momentumPhase : "ended"
+                }
+            ];
+
+            await UIHelper.mouseWheelSequence({ events }, { waitForCompletion: false});
+            await UIHelper.waitForCondition(() => { return sawMomentumEvent });
+            shouldBeTrue('scrollEventCount > 0');
+
+            const fingersDownGesture = [
+                {
+                    type : "wheel",
+                    viewX : 100,
+                    viewY : 100,
+                    phase : "maybegin"
+                }
+            ];
+
+            await UIHelper.mouseWheelSequence({ events: fingersDownGesture }, { waitForCompletion: false});
+            // We can't detect the "mayBegin" via events. so wait for a presentation update to make
+            // sure it got to the main thread.
+            await UIHelper.ensurePresentationUpdate();
+            
+            scrollEventCountAtMayBegin = scrollEventCount;
+            await UIHelper.renderingUpdate();
+            await UIHelper.renderingUpdate();
+            
+            // Make sure no more scroll events fire.
+            shouldBe('scrollEventCount', 'scrollEventCountAtMayBegin');
+            finishJSTest();
+        }
+
+        async function scrollTest()
+        {
+            await testEventSequence();
+        }
+
+        window.addEventListener('load', () => {
+            window.addEventListener('wheel', (event) => {
+                if (event.deltaY == 99) {
+                    debug('Momentum event reached main thread');
+                    sawMomentumEvent = true;
+                }
+
+                if (event.deltaY == 12) {
+                    debug('Saw the fingers down gesture');
+                    sawFingersDown = true;
+                }
+                // console.log(`wheel ${event.deltaX} ${event.deltaY}`);
+            }, { passive: true });
+
+            window.addEventListener('scroll', (event) => {
+                ++scrollEventCount;
+            });
+            
+            setTimeout(scrollTest, 0);
+        }, false);
+    </script>
+</head>
+<body>
+    <script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (285796 => 285797)


--- trunk/Source/WebCore/ChangeLog	2021-11-15 02:45:28 UTC (rev 285796)
+++ trunk/Source/WebCore/ChangeLog	2021-11-15 04:06:38 UTC (rev 285797)
@@ -1,3 +1,29 @@
+2021-11-14  Simon Fraser  <simon.fra...@apple.com>
+
+        Fingers down on the trackpad should stop an animated scroll
+        https://bugs.webkit.org/show_bug.cgi?id=233114
+
+        Reviewed by Wenson Hsieh.
+        
+        Fingers down on the trackpad sends a "MayBegin" event; this needs to stop any in-progress
+        animated momentum scroll.
+
+        This failed because ScrollingTreeScrollingNodeDelegateMac::handleWheelEvent() early-returned
+        on the MayBegin event before it got to ScrollingEffectsController. Fix that, and have
+        ScrollingEffectsController::handleWheelEvent() return true to say it was handled.
+
+        This triggered an assertion in ScrollingTreeGestureState, but for "post-main-thread"
+        handling for which the assertion was wrong.
+
+        Test: fast/scrolling/mac/momentum-animator-maybegin-stops.html
+
+        * page/scrolling/ScrollingTreeGestureState.cpp:
+        (WebCore::ScrollingTreeGestureState::nodeDidHandleEvent):
+        * page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm:
+        (WebCore::ScrollingTreeScrollingNodeDelegateMac::handleWheelEvent):
+        * platform/mac/ScrollingEffectsController.mm:
+        (WebCore::ScrollingEffectsController::handleWheelEvent):
+
 2021-11-14  Said Abou-Hallawa  <s...@apple.com>
 
         [GPU Process] Remove the reference to Filter from FilterEffect

Modified: trunk/Source/WebCore/page/scrolling/ScrollingTreeGestureState.cpp (285796 => 285797)


--- trunk/Source/WebCore/page/scrolling/ScrollingTreeGestureState.cpp	2021-11-15 02:45:28 UTC (rev 285796)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTreeGestureState.cpp	2021-11-15 04:06:38 UTC (rev 285797)
@@ -66,8 +66,8 @@
         m_scrollingTree.handleWheelEventPhase(nodeID, event.phase());
         break;
     case PlatformWheelEventPhase::Cancelled:
-        // handleGestureCancel() should have been called first.
-        ASSERT_NOT_REACHED();
+        // We can get here for via handleWheelEventAfterMainThread(), in which case handleGestureCancel() was not called first.
+        handleGestureCancel(event);
         break;
     case PlatformWheelEventPhase::Began:
         m_activeNodeID = nodeID;

Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm (285796 => 285797)


--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm	2021-11-15 02:45:28 UTC (rev 285796)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeScrollingNodeDelegateMac.mm	2021-11-15 04:06:38 UTC (rev 285797)
@@ -106,11 +106,6 @@
     if (isInUserScroll != wasInUserScroll)
         scrollingNode().setUserScrollInProgress(isInUserScroll);
 
-    // PlatformWheelEventPhase::MayBegin fires when two fingers touch the trackpad, and is used to flash overlay scrollbars.
-    // We know we're scrollable at this point, so handle the event.
-    if (wheelEvent.phase() == PlatformWheelEventPhase::MayBegin)
-        return true;
-
     return m_scrollController.handleWheelEvent(wheelEvent);
 }
 

Modified: trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm (285796 => 285797)


--- trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm	2021-11-15 02:45:28 UTC (rev 285796)
+++ trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm	2021-11-15 04:06:38 UTC (rev 285797)
@@ -140,7 +140,7 @@
             LOG(ScrollAnimations, "Event (%s, %s): stopping animated scroll", phaseToString(wheelEvent.phase()), phaseToString(wheelEvent.momentumPhase()));
             stopAnimatedScroll();
         }
-        return false;
+        return true;
     }
 
     if (wheelEvent.phase() == PlatformWheelEventPhase::Began) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to