Title: [288524] branches/safari-613-branch
Revision
288524
Author
[email protected]
Date
2022-01-24 17:56:35 -0800 (Mon, 24 Jan 2022)

Log Message

Cherry-pick r288336. rdar://problem/86558157

    REGRESSION (r284136): A slight horizontal rubberband kills scroll momentum
    https://bugs.webkit.org/show_bug.cgi?id=234384

    Reviewed by Tim Horton.

    Source/WebCore:

    ScrollAnimationRubberBand subtly changed the behavior of the rubberband animation on the
    axis that is not the rubberbanding axis. Because it converged on m_targetOffset, it always
    resulted in no offset on that axis.

    Fix by restoring the behavior from before r284136, which applies the rubberbanding as a
    delta from the current offset and no longer uses m_targetOffset, which is removed. It's a
    bit surprising that this rubberband animation drives a vertical scroll when the gesture is
    primarily horizontal (normally we'd clamp these deltas to be purely horizontal), but people
    are used to this behavior so restore it.

    Test: fast/scrolling/mac/j-shaped-scroll-rubberband.html

    * platform/ScrollAnimation.h:
    * platform/ScrollingEffectsController.cpp:
    (WebCore::ScrollingEffectsController::overscrollAmount):
    (WebCore::ScrollingEffectsController::scrollOffset):
    * platform/ScrollingEffectsController.h:
    * platform/mac/ScrollAnimationRubberBand.h:
    * platform/mac/ScrollAnimationRubberBand.mm:
    (WebCore::ScrollAnimationRubberBand::startRubberBandAnimation):
    (WebCore::ScrollAnimationRubberBand::serviceAnimation):
    (WebCore::ScrollAnimationRubberBand::debugDescription const):
    * platform/mac/ScrollingEffectsController.mm:
    (WebCore::ScrollingEffectsController::startRubberBandAnimation):
    (WebCore::ScrollingEffectsController::startRubberBandAnimationIfNecessary):

    LayoutTests:

    * fast/scrolling/mac/j-shaped-scroll-rubberband-expected.txt: Added.
    * fast/scrolling/mac/j-shaped-scroll-rubberband.html: Added.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288336 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: branches/safari-613-branch/LayoutTests/ChangeLog (288523 => 288524)


--- branches/safari-613-branch/LayoutTests/ChangeLog	2022-01-25 01:56:30 UTC (rev 288523)
+++ branches/safari-613-branch/LayoutTests/ChangeLog	2022-01-25 01:56:35 UTC (rev 288524)
@@ -1,5 +1,60 @@
 2022-01-24  Alan Coon  <[email protected]>
 
+        Cherry-pick r288336. rdar://problem/86558157
+
+    REGRESSION (r284136): A slight horizontal rubberband kills scroll momentum
+    https://bugs.webkit.org/show_bug.cgi?id=234384
+    
+    Reviewed by Tim Horton.
+    
+    Source/WebCore:
+    
+    ScrollAnimationRubberBand subtly changed the behavior of the rubberband animation on the
+    axis that is not the rubberbanding axis. Because it converged on m_targetOffset, it always
+    resulted in no offset on that axis.
+    
+    Fix by restoring the behavior from before r284136, which applies the rubberbanding as a
+    delta from the current offset and no longer uses m_targetOffset, which is removed. It's a
+    bit surprising that this rubberband animation drives a vertical scroll when the gesture is
+    primarily horizontal (normally we'd clamp these deltas to be purely horizontal), but people
+    are used to this behavior so restore it.
+    
+    Test: fast/scrolling/mac/j-shaped-scroll-rubberband.html
+    
+    * platform/ScrollAnimation.h:
+    * platform/ScrollingEffectsController.cpp:
+    (WebCore::ScrollingEffectsController::overscrollAmount):
+    (WebCore::ScrollingEffectsController::scrollOffset):
+    * platform/ScrollingEffectsController.h:
+    * platform/mac/ScrollAnimationRubberBand.h:
+    * platform/mac/ScrollAnimationRubberBand.mm:
+    (WebCore::ScrollAnimationRubberBand::startRubberBandAnimation):
+    (WebCore::ScrollAnimationRubberBand::serviceAnimation):
+    (WebCore::ScrollAnimationRubberBand::debugDescription const):
+    * platform/mac/ScrollingEffectsController.mm:
+    (WebCore::ScrollingEffectsController::startRubberBandAnimation):
+    (WebCore::ScrollingEffectsController::startRubberBandAnimationIfNecessary):
+    
+    LayoutTests:
+    
+    * fast/scrolling/mac/j-shaped-scroll-rubberband-expected.txt: Added.
+    * fast/scrolling/mac/j-shaped-scroll-rubberband.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288336 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-20  Simon Fraser  <[email protected]>
+
+            REGRESSION (r284136): A slight horizontal rubberband kills scroll momentum
+            https://bugs.webkit.org/show_bug.cgi?id=234384
+
+            Reviewed by Tim Horton.
+
+            * fast/scrolling/mac/j-shaped-scroll-rubberband-expected.txt: Added.
+            * fast/scrolling/mac/j-shaped-scroll-rubberband.html: Added.
+
+2022-01-24  Alan Coon  <[email protected]>
+
         Cherry-pick r288266. rdar://problem/87804395
 
     Web Inspector: fully blackboxed stack traces don't show the right top call frame

Added: branches/safari-613-branch/LayoutTests/fast/scrolling/mac/j-shaped-scroll-rubberband-expected.txt (0 => 288524)


--- branches/safari-613-branch/LayoutTests/fast/scrolling/mac/j-shaped-scroll-rubberband-expected.txt	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/fast/scrolling/mac/j-shaped-scroll-rubberband-expected.txt	2022-01-25 01:56:35 UTC (rev 288524)
@@ -0,0 +1,2 @@
+PASS window.scrollY > 0 is true
+

Added: branches/safari-613-branch/LayoutTests/fast/scrolling/mac/j-shaped-scroll-rubberband.html (0 => 288524)


--- branches/safari-613-branch/LayoutTests/fast/scrolling/mac/j-shaped-scroll-rubberband.html	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/fast/scrolling/mac/j-shaped-scroll-rubberband.html	2022-01-25 01:56:35 UTC (rev 288524)
@@ -0,0 +1,126 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        body {
+            height: 5000px;
+        }
+    </style>
+    <script src=""
+    <script src=""
+    <script>
+        var jsTestIsAsync = true;
+
+        function checkForScroll()
+        {
+            shouldBeTrue('window.scrollY > 0');
+            testRunner.notifyDone();
+        }
+
+        async function scrollTest()
+        {
+            // Gesture that starts horizontal then has some upward trajectory at the end.
+            const events = [
+                {
+                    type : "wheel",
+                    viewX : 100,
+                    viewY : 100,
+                    deltaX : 1,
+                    phase : "began"
+                },
+                {
+                    type : "wheel",
+                    deltaX : 4,
+                    deltaY : -1,
+                    phase : "changed"
+                },
+                {
+                    type : "wheel",
+                    viewX : 101, // defeat coalescing
+                    deltaX : 6,
+                    deltaY : -2,
+                    phase : "changed"
+                },
+                {
+                    type : "wheel",
+                    viewX : 100, // defeat coalescing
+                    deltaX : 10,
+                    deltaY : -4,
+                    phase : "changed"
+                },
+                {
+                    type : "wheel",
+                    viewX : 101, // defeat coalescing
+                    deltaX : 8,
+                    deltaY : -6,
+                    phase : "changed"
+                },
+                {
+                    type : "wheel",
+                    phase : "ended"
+                },
+                {
+                    type : "wheel",
+                    viewX : 100, // defeat coalescing
+                    deltaX : 10,
+                    deltaY : -6,
+                    momentumPhase : "began"
+                },
+                {
+                    type : "wheel",
+                    viewX : 101, // defeat coalescing
+                    deltaX : 12,
+                    deltaY : -5,
+                    momentumPhase : "changed"
+                },
+                {
+                    type : "wheel",
+                    viewX : 100, // defeat coalescing
+                    deltaX : 8,
+                    deltaY : -4,
+                    momentumPhase : "changed"
+                },
+                {
+                    type : "wheel",
+                    viewX : 101, // defeat coalescing
+                    deltaX : 6,
+                    deltaY : -2,
+                    momentumPhase : "changed"
+                },
+                {
+                    type : "wheel",
+                    viewX : 100, // defeat coalescing
+                    deltaX : 4,
+                    deltaY : -1,
+                    momentumPhase : "changed"
+                },
+                {
+                    type : "wheel",
+                    momentumPhase : "ended"
+                }
+            ];
+            
+            await UIHelper.mouseWheelSequence({ events });
+            checkForScroll();
+        }
+
+        function startTest()
+        {
+            if (!window.eventSender) {
+                setTimeout(scrollTest, 0);
+                return;
+            }
+
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+
+            setTimeout(scrollTest, 0);
+        }
+        
+        window.addEventListener('load', startTest, false);
+    </script>
+</head>
+<body>
+    <script src=""
+</body>
+</html>

Modified: branches/safari-613-branch/Source/WebCore/ChangeLog (288523 => 288524)


--- branches/safari-613-branch/Source/WebCore/ChangeLog	2022-01-25 01:56:30 UTC (rev 288523)
+++ branches/safari-613-branch/Source/WebCore/ChangeLog	2022-01-25 01:56:35 UTC (rev 288524)
@@ -1,5 +1,83 @@
 2022-01-24  Alan Coon  <[email protected]>
 
+        Cherry-pick r288336. rdar://problem/86558157
+
+    REGRESSION (r284136): A slight horizontal rubberband kills scroll momentum
+    https://bugs.webkit.org/show_bug.cgi?id=234384
+    
+    Reviewed by Tim Horton.
+    
+    Source/WebCore:
+    
+    ScrollAnimationRubberBand subtly changed the behavior of the rubberband animation on the
+    axis that is not the rubberbanding axis. Because it converged on m_targetOffset, it always
+    resulted in no offset on that axis.
+    
+    Fix by restoring the behavior from before r284136, which applies the rubberbanding as a
+    delta from the current offset and no longer uses m_targetOffset, which is removed. It's a
+    bit surprising that this rubberband animation drives a vertical scroll when the gesture is
+    primarily horizontal (normally we'd clamp these deltas to be purely horizontal), but people
+    are used to this behavior so restore it.
+    
+    Test: fast/scrolling/mac/j-shaped-scroll-rubberband.html
+    
+    * platform/ScrollAnimation.h:
+    * platform/ScrollingEffectsController.cpp:
+    (WebCore::ScrollingEffectsController::overscrollAmount):
+    (WebCore::ScrollingEffectsController::scrollOffset):
+    * platform/ScrollingEffectsController.h:
+    * platform/mac/ScrollAnimationRubberBand.h:
+    * platform/mac/ScrollAnimationRubberBand.mm:
+    (WebCore::ScrollAnimationRubberBand::startRubberBandAnimation):
+    (WebCore::ScrollAnimationRubberBand::serviceAnimation):
+    (WebCore::ScrollAnimationRubberBand::debugDescription const):
+    * platform/mac/ScrollingEffectsController.mm:
+    (WebCore::ScrollingEffectsController::startRubberBandAnimation):
+    (WebCore::ScrollingEffectsController::startRubberBandAnimationIfNecessary):
+    
+    LayoutTests:
+    
+    * fast/scrolling/mac/j-shaped-scroll-rubberband-expected.txt: Added.
+    * fast/scrolling/mac/j-shaped-scroll-rubberband.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288336 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-20  Simon Fraser  <[email protected]>
+
+            REGRESSION (r284136): A slight horizontal rubberband kills scroll momentum
+            https://bugs.webkit.org/show_bug.cgi?id=234384
+
+            Reviewed by Tim Horton.
+
+            ScrollAnimationRubberBand subtly changed the behavior of the rubberband animation on the
+            axis that is not the rubberbanding axis. Because it converged on m_targetOffset, it always
+            resulted in no offset on that axis.
+
+            Fix by restoring the behavior from before r284136, which applies the rubberbanding as a
+            delta from the current offset and no longer uses m_targetOffset, which is removed. It's a
+            bit surprising that this rubberband animation drives a vertical scroll when the gesture is
+            primarily horizontal (normally we'd clamp these deltas to be purely horizontal), but people
+            are used to this behavior so restore it.
+
+            Test: fast/scrolling/mac/j-shaped-scroll-rubberband.html
+
+            * platform/ScrollAnimation.h:
+            * platform/ScrollingEffectsController.cpp:
+            (WebCore::ScrollingEffectsController::overscrollAmount):
+            (WebCore::ScrollingEffectsController::scrollOffset):
+            * platform/ScrollingEffectsController.h:
+            * platform/mac/ScrollAnimationRubberBand.h:
+            * platform/mac/ScrollAnimationRubberBand.mm:
+            (WebCore::ScrollAnimationRubberBand::startRubberBandAnimation):
+            (WebCore::ScrollAnimationRubberBand::serviceAnimation):
+            (WebCore::ScrollAnimationRubberBand::debugDescription const):
+            * platform/mac/ScrollingEffectsController.mm:
+            (WebCore::ScrollingEffectsController::startRubberBandAnimation):
+            (WebCore::ScrollingEffectsController::startRubberBandAnimationIfNecessary):
+
+2022-01-24  Alan Coon  <[email protected]>
+
         Cherry-pick r288304. rdar://problem/87836459
 
     [:has() pseudo-class] Ignore :visited inside :has()

Modified: branches/safari-613-branch/Source/WebCore/platform/ScrollAnimation.h (288523 => 288524)


--- branches/safari-613-branch/Source/WebCore/platform/ScrollAnimation.h	2022-01-25 01:56:30 UTC (rev 288523)
+++ branches/safari-613-branch/Source/WebCore/platform/ScrollAnimation.h	2022-01-25 01:56:35 UTC (rev 288524)
@@ -45,6 +45,8 @@
     virtual void scrollAnimationWillStart(ScrollAnimation&) { }
     virtual void scrollAnimationDidEnd(ScrollAnimation&) { }
     virtual ScrollExtents scrollExtentsForAnimation(ScrollAnimation&) = 0;
+    virtual FloatSize overscrollAmount(ScrollAnimation&) = 0;
+    virtual FloatPoint scrollOffset(ScrollAnimation&) = 0;
 };
 
 class ScrollAnimation {

Modified: branches/safari-613-branch/Source/WebCore/platform/ScrollingEffectsController.cpp (288523 => 288524)


--- branches/safari-613-branch/Source/WebCore/platform/ScrollingEffectsController.cpp	2022-01-25 01:56:30 UTC (rev 288523)
+++ branches/safari-613-branch/Source/WebCore/platform/ScrollingEffectsController.cpp	2022-01-25 01:56:35 UTC (rev 288524)
@@ -522,6 +522,20 @@
     return m_client.scrollExtents();
 }
 
+FloatSize ScrollingEffectsController::overscrollAmount(ScrollAnimation&)
+{
+#if HAVE(RUBBER_BANDING)
+    return m_client.stretchAmount();
+#else
+    return { };
+#endif
+}
+
+FloatPoint ScrollingEffectsController::scrollOffset(ScrollAnimation&)
+{
+    return m_client.scrollOffset();
+}
+
 void ScrollingEffectsController::startDeferringWheelEventTestCompletion(WheelEventTestMonitor::DeferReason reason)
 {
     m_client.deferWheelEventTestCompletionForReason(reinterpret_cast<WheelEventTestMonitor::ScrollableAreaIdentifier>(this), reason);

Modified: branches/safari-613-branch/Source/WebCore/platform/ScrollingEffectsController.h (288523 => 288524)


--- branches/safari-613-branch/Source/WebCore/platform/ScrollingEffectsController.h	2022-01-25 01:56:30 UTC (rev 288523)
+++ branches/safari-613-branch/Source/WebCore/platform/ScrollingEffectsController.h	2022-01-25 01:56:35 UTC (rev 288524)
@@ -205,7 +205,7 @@
 
     void startRubberBandAnimationIfNecessary();
 
-    bool startRubberBandAnimation(const FloatPoint& targetOffset, const FloatSize& initialVelocity, const FloatSize& initialOverscroll);
+    bool startRubberBandAnimation(const FloatSize& initialVelocity, const FloatSize& initialOverscroll);
     void stopRubberBandAnimation();
 
     void willStartRubberBandAnimation();
@@ -227,6 +227,8 @@
     void scrollAnimationWillStart(ScrollAnimation&) final;
     void scrollAnimationDidEnd(ScrollAnimation&) final;
     ScrollExtents scrollExtentsForAnimation(ScrollAnimation&) final;
+    FloatSize overscrollAmount(ScrollAnimation&) final;
+    FloatPoint scrollOffset(ScrollAnimation&) final;
 
     void adjustDeltaForSnappingIfNeeded(float& deltaX, float& deltaY);
 

Modified: branches/safari-613-branch/Source/WebCore/platform/mac/ScrollAnimationRubberBand.h (288523 => 288524)


--- branches/safari-613-branch/Source/WebCore/platform/mac/ScrollAnimationRubberBand.h	2022-01-25 01:56:30 UTC (rev 288523)
+++ branches/safari-613-branch/Source/WebCore/platform/mac/ScrollAnimationRubberBand.h	2022-01-25 01:56:35 UTC (rev 288524)
@@ -36,7 +36,7 @@
     virtual ~ScrollAnimationRubberBand();
 
     // targetOffset is the scroll offset when the animation has finished (i.e. scrolled to an edge).
-    bool startRubberBandAnimation(const FloatPoint& targetOffset, const FloatSize& initialVelocity, const FloatSize& initialOverscroll);
+    bool startRubberBandAnimation(const FloatSize& initialVelocity, const FloatSize& initialOverscroll);
 
 private:
     void updateScrollExtents() final;
@@ -47,7 +47,6 @@
 
     bool animateScroll(MonotonicTime);
 
-    FloatPoint m_targetOffset;
     FloatSize m_initialVelocity;
     FloatSize m_initialOverscroll;
 };

Modified: branches/safari-613-branch/Source/WebCore/platform/mac/ScrollAnimationRubberBand.mm (288523 => 288524)


--- branches/safari-613-branch/Source/WebCore/platform/mac/ScrollAnimationRubberBand.mm	2022-01-25 01:56:30 UTC (rev 288523)
+++ branches/safari-613-branch/Source/WebCore/platform/mac/ScrollAnimationRubberBand.mm	2022-01-25 01:56:35 UTC (rev 288524)
@@ -59,9 +59,8 @@
 
 ScrollAnimationRubberBand::~ScrollAnimationRubberBand() = default;
 
-bool ScrollAnimationRubberBand::startRubberBandAnimation(const FloatPoint& targetOffset, const FloatSize& initialVelocity, const FloatSize& initialOverscroll)
+bool ScrollAnimationRubberBand::startRubberBandAnimation(const FloatSize& initialVelocity, const FloatSize& initialOverscroll)
 {
-    m_targetOffset = targetOffset;
     m_initialVelocity = initialVelocity;
     m_initialOverscroll = initialOverscroll;
 
@@ -93,7 +92,9 @@
 
     // We might be rubberbanding away from an edge and back, so wait a frame or two before checking for completion.
     bool animationComplete = rubberBandOffset.isZero() && elapsedTime > 24_ms;
-    m_currentOffset = m_targetOffset + rubberBandOffset;
+    
+    auto scrollDelta = rubberBandOffset - m_client.overscrollAmount(*this);
+    m_currentOffset = m_client.scrollOffset(*this) + scrollDelta;
 
     m_client.scrollAnimationDidUpdate(*this, m_currentOffset);
 
@@ -104,7 +105,7 @@
 String ScrollAnimationRubberBand::debugDescription() const
 {
     TextStream textStream;
-    textStream << "ScrollAnimationRubberBand " << this << " active " << isActive() << " target " << m_targetOffset << " current offset " << currentOffset();
+    textStream << "ScrollAnimationRubberBand " << this << " active " << isActive() << " initial velocity " << m_initialVelocity << " initial overscroll " << m_initialOverscroll;
     return textStream.release();
 }
 

Modified: branches/safari-613-branch/Source/WebCore/platform/mac/ScrollingEffectsController.mm (288523 => 288524)


--- branches/safari-613-branch/Source/WebCore/platform/mac/ScrollingEffectsController.mm	2022-01-25 01:56:30 UTC (rev 288523)
+++ branches/safari-613-branch/Source/WebCore/platform/mac/ScrollingEffectsController.mm	2022-01-25 01:56:35 UTC (rev 288524)
@@ -399,13 +399,13 @@
     updateRubberBandingState();
 }
 
-bool ScrollingEffectsController::startRubberBandAnimation(const FloatPoint& targetOffset, const FloatSize& initialVelocity, const FloatSize& initialOverscroll)
+bool ScrollingEffectsController::startRubberBandAnimation(const FloatSize& initialVelocity, const FloatSize& initialOverscroll)
 {
     if (m_currentAnimation)
         m_currentAnimation->stop();
 
     m_currentAnimation = makeUnique<ScrollAnimationRubberBand>(*this);
-    bool started = downcast<ScrollAnimationRubberBand>(*m_currentAnimation).startRubberBandAnimation(targetOffset, initialVelocity, initialOverscroll);
+    bool started = downcast<ScrollAnimationRubberBand>(*m_currentAnimation).startRubberBandAnimation(initialVelocity, initialOverscroll);
     LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController::startRubberBandAnimation() - animation " << *m_currentAnimation << " started " << started);
     return started;
 }
@@ -464,8 +464,8 @@
     if (!m_client.allowsVerticalScrolling())
         initialVelocity.setHeight(0);
 
-    LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController::startRubberBandAnimationIfNecessary() - rubberBandAnimationRunning " << m_isAnimatingRubberBand << " stretchAmount " << stretchAmount << " contrainedOffset " << contrainedOffset << " initialVelocity " << initialVelocity);
-    startRubberBandAnimation(contrainedOffset, initialVelocity, stretchAmount);
+    LOG_WITH_STREAM(ScrollAnimations, stream << "ScrollingEffectsController::startRubberBandAnimationIfNecessary() - rubberBandAnimationRunning " << m_isAnimatingRubberBand << " stretchAmount " << stretchAmount << " initialVelocity " << initialVelocity);
+    startRubberBandAnimation(initialVelocity, stretchAmount);
 }
 
 bool ScrollingEffectsController::shouldRubberBandOnSide(BoxSide side) const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to