Title: [283465] trunk
Revision
283465
Author
[email protected]
Date
2021-10-03 08:52:45 -0700 (Sun, 03 Oct 2021)

Log Message

REGRESSION (r283335): rubber-banding no longer locks to an axis
https://bugs.webkit.org/show_bug.cgi?id=231131

Reviewed by Tim Horton.

Source/WebCore:

r283335 introduced a bug where pulling down to rubber-band would result in sideways
motion even when the gesture was mostly vertical.

ScrollingEffectsController::modifyScrollDeltaForStretching() has some axis-locking behavior
that was broken by r283335, so restore the old behavior.

Test: fast/scrolling/mac/rubberband-axis-locking.html

* platform/mac/ScrollingEffectsController.mm:
(WebCore::ScrollingEffectsController::modifyScrollDeltaForStretching):
(WebCore::isHorizontalSide): Deleted.
(WebCore::isVerticalSide): Deleted.

LayoutTests:

* fast/scrolling/mac/rubberband-axis-locking-expected.txt: Added.
* fast/scrolling/mac/rubberband-axis-locking.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (283464 => 283465)


--- trunk/LayoutTests/ChangeLog	2021-10-03 13:59:48 UTC (rev 283464)
+++ trunk/LayoutTests/ChangeLog	2021-10-03 15:52:45 UTC (rev 283465)
@@ -1,3 +1,13 @@
+2021-10-03  Simon Fraser  <[email protected]>
+
+        REGRESSION (r283335): rubber-banding no longer locks to an axis
+        https://bugs.webkit.org/show_bug.cgi?id=231131
+
+        Reviewed by Tim Horton.
+
+        * fast/scrolling/mac/rubberband-axis-locking-expected.txt: Added.
+        * fast/scrolling/mac/rubberband-axis-locking.html: Added.
+
 2021-10-02  Youenn Fablet  <[email protected]>
 
         Add support for ServiceWorkerGlobalScope push event handler

Added: trunk/LayoutTests/fast/scrolling/mac/rubberband-axis-locking-expected.txt (0 => 283465)


--- trunk/LayoutTests/fast/scrolling/mac/rubberband-axis-locking-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/rubberband-axis-locking-expected.txt	2021-10-03 15:52:45 UTC (rev 283465)
@@ -0,0 +1,6 @@
+
+Tests axis locking while rubberbanding
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/scrolling/mac/rubberband-axis-locking.html (0 => 283465)


--- trunk/LayoutTests/fast/scrolling/mac/rubberband-axis-locking.html	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/rubberband-axis-locking.html	2021-10-03 15:52:45 UTC (rev 283465)
@@ -0,0 +1,92 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        body {
+            height: 2000px;
+            width: 200%;
+        }
+    </style>
+    <script src=""
+    <script src=""
+    <script>
+        var jsTestIsAsync = true;
+        
+        var initialScrollX;
+        var initialScrollY;
+
+        async function resetScrollPositions(x, y)
+        {
+            window.scrollTo(x, y);
+            // Wait for scroll events to fire.
+            await UIHelper.renderingUpdate();
+        }
+        
+        async function testVerticalRubberband()
+        {
+            await resetScrollPositions(100, 0);
+            initialScrollX = window.scrollX;
+            
+            let scrollListener = () => {
+                if (window.scrollX != initialScrollX)
+                    testFailed('Horizontal scroll position ' + window.scrollX + ' is not ' + initialScrollX);
+            }
+
+            window.addEventListener('scroll', scrollListener);
+
+            eventSender.monitorWheelEvents();
+            eventSender.mouseMoveTo(100, 100);
+            // Pull down and slightly sideways
+            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 2, "began", "none");
+            eventSender.mouseScrollByWithWheelAndMomentumPhases(1, 2, "changed", "none");
+            eventSender.mouseScrollByWithWheelAndMomentumPhases(1, 2, "changed", "none");
+            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, "ended", "none");
+            await UIHelper.waitForScrollCompletion();
+
+            window.removeEventListener('scroll', scrollListener);
+        }
+
+        async function testHorizontalRubberband()
+        {
+            await resetScrollPositions(0, 100);
+            initialScrollY = window.scrollY;
+
+            let scrollListener = () => {
+                if (window.scrollY != initialScrollY)
+                    testFailed('Vertical scroll position ' + window.scrollY + ' is not ' + initialScrollY);
+            }
+
+            window.addEventListener('scroll', scrollListener);
+
+            eventSender.monitorWheelEvents();
+            eventSender.mouseMoveTo(100, 100);
+            // Pull left and slightly sideways
+            eventSender.mouseScrollByWithWheelAndMomentumPhases(2, 0, "began", "none");
+            eventSender.mouseScrollByWithWheelAndMomentumPhases(2, -1, "changed", "none");
+            eventSender.mouseScrollByWithWheelAndMomentumPhases(2, -1, "changed", "none");
+            eventSender.mouseScrollByWithWheelAndMomentumPhases(0, 0, "ended", "none");
+            await UIHelper.waitForScrollCompletion();
+
+            window.removeEventListener('scroll', scrollListener);
+        }
+
+        async function scrollTest()
+        {
+            debug('');
+            debug('Tests axis locking while rubberbanding');
+
+            await testVerticalRubberband();
+            await testHorizontalRubberband();
+
+            finishJSTest();
+        }
+
+        window.addEventListener('load', () => {
+            setTimeout(scrollTest, 0);
+        }, false);
+    </script>
+</head>
+<body>
+    <script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (283464 => 283465)


--- trunk/Source/WebCore/ChangeLog	2021-10-03 13:59:48 UTC (rev 283464)
+++ trunk/Source/WebCore/ChangeLog	2021-10-03 15:52:45 UTC (rev 283465)
@@ -1,3 +1,23 @@
+2021-10-03  Simon Fraser  <[email protected]>
+
+        REGRESSION (r283335): rubber-banding no longer locks to an axis
+        https://bugs.webkit.org/show_bug.cgi?id=231131
+
+        Reviewed by Tim Horton.
+
+        r283335 introduced a bug where pulling down to rubber-band would result in sideways
+        motion even when the gesture was mostly vertical.
+
+        ScrollingEffectsController::modifyScrollDeltaForStretching() has some axis-locking behavior
+        that was broken by r283335, so restore the old behavior.
+
+        Test: fast/scrolling/mac/rubberband-axis-locking.html
+
+        * platform/mac/ScrollingEffectsController.mm:
+        (WebCore::ScrollingEffectsController::modifyScrollDeltaForStretching):
+        (WebCore::isHorizontalSide): Deleted.
+        (WebCore::isVerticalSide): Deleted.
+
 2021-10-03  Antti Koivisto  <[email protected]>
 
         [LFC][Integration] More run->box renaming and other iterator cleanups

Modified: trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm (283464 => 283465)


--- trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm	2021-10-03 13:59:48 UTC (rev 283464)
+++ trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm	2021-10-03 15:52:45 UTC (rev 283465)
@@ -113,16 +113,6 @@
     return ScrollableArea::targetSideForScrollDelta(delta, dominantAxis);
 }
 
-static bool isHorizontalSide(std::optional<BoxSide> side)
-{
-    return side && (*side == BoxSide::Left || *side == BoxSide::Right);
-}
-
-static bool isVerticalSide(std::optional<BoxSide> side)
-{
-    return side && (*side == BoxSide::Top || *side == BoxSide::Bottom);
-}
-
 bool ScrollingEffectsController::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
 {
     if (processWheelEventForScrollSnap(wheelEvent))
@@ -244,7 +234,7 @@
 {
     auto affectedSide = affectedSideOnDominantAxis(delta);
     if (isVerticallyStretched) {
-        if (!isHorizontallyStretched && isHorizontalSide(affectedSide) && m_client.isPinnedOnSide(*affectedSide)) {
+        if (!isHorizontallyStretched && affectedSide && m_client.isPinnedOnSide(*affectedSide)) {
             // Stretching only in the vertical.
             if (delta.height() && (fabsf(delta.width() / delta.height()) < rubberbandDirectionLockStretchRatio))
                 delta.setWidth(0);
@@ -260,7 +250,7 @@
 
     if (isHorizontallyStretched) {
         // Stretching only in the horizontal.
-        if (isVerticalSide(affectedSide) && m_client.isPinnedOnSide(*affectedSide)) {
+        if (affectedSide && m_client.isPinnedOnSide(*affectedSide)) {
             if (delta.width() && (fabsf(delta.height() / delta.width()) < rubberbandDirectionLockStretchRatio))
                 delta.setHeight(0);
             else if (fabsf(delta.height()) < rubberbandMinimumRequiredDeltaBeforeStretch) {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to