Title: [288336] trunk
Revision
288336
Author
[email protected]
Date
2022-01-20 17:23:53 -0800 (Thu, 20 Jan 2022)

Log Message

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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (288335 => 288336)


--- trunk/LayoutTests/ChangeLog	2022-01-21 01:13:00 UTC (rev 288335)
+++ trunk/LayoutTests/ChangeLog	2022-01-21 01:23:53 UTC (rev 288336)
@@ -1,3 +1,13 @@
+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-20  Rob Buis  <[email protected]>
 
         Mark range boundary point containers

Added: trunk/LayoutTests/fast/scrolling/mac/j-shaped-scroll-rubberband-expected.txt (0 => 288336)


--- trunk/LayoutTests/fast/scrolling/mac/j-shaped-scroll-rubberband-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/j-shaped-scroll-rubberband-expected.txt	2022-01-21 01:23:53 UTC (rev 288336)
@@ -0,0 +1,2 @@
+PASS window.scrollY > 0 is true
+

Added: trunk/LayoutTests/fast/scrolling/mac/j-shaped-scroll-rubberband.html (0 => 288336)


--- trunk/LayoutTests/fast/scrolling/mac/j-shaped-scroll-rubberband.html	                        (rev 0)
+++ trunk/LayoutTests/fast/scrolling/mac/j-shaped-scroll-rubberband.html	2022-01-21 01:23:53 UTC (rev 288336)
@@ -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: trunk/Source/WebCore/ChangeLog (288335 => 288336)


--- trunk/Source/WebCore/ChangeLog	2022-01-21 01:13:00 UTC (rev 288335)
+++ trunk/Source/WebCore/ChangeLog	2022-01-21 01:23:53 UTC (rev 288336)
@@ -1,3 +1,36 @@
+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-20  Tyler Wilcock  <[email protected]>
 
         AXCoreObject::childrenIDs can be simplified and more efficient by using map

Modified: trunk/Source/WebCore/platform/ScrollAnimation.h (288335 => 288336)


--- trunk/Source/WebCore/platform/ScrollAnimation.h	2022-01-21 01:13:00 UTC (rev 288335)
+++ trunk/Source/WebCore/platform/ScrollAnimation.h	2022-01-21 01:23:53 UTC (rev 288336)
@@ -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: trunk/Source/WebCore/platform/ScrollingEffectsController.cpp (288335 => 288336)


--- trunk/Source/WebCore/platform/ScrollingEffectsController.cpp	2022-01-21 01:13:00 UTC (rev 288335)
+++ trunk/Source/WebCore/platform/ScrollingEffectsController.cpp	2022-01-21 01:23:53 UTC (rev 288336)
@@ -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: trunk/Source/WebCore/platform/ScrollingEffectsController.h (288335 => 288336)


--- trunk/Source/WebCore/platform/ScrollingEffectsController.h	2022-01-21 01:13:00 UTC (rev 288335)
+++ trunk/Source/WebCore/platform/ScrollingEffectsController.h	2022-01-21 01:23:53 UTC (rev 288336)
@@ -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: trunk/Source/WebCore/platform/mac/ScrollAnimationRubberBand.h (288335 => 288336)


--- trunk/Source/WebCore/platform/mac/ScrollAnimationRubberBand.h	2022-01-21 01:13:00 UTC (rev 288335)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimationRubberBand.h	2022-01-21 01:23:53 UTC (rev 288336)
@@ -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: trunk/Source/WebCore/platform/mac/ScrollAnimationRubberBand.mm (288335 => 288336)


--- trunk/Source/WebCore/platform/mac/ScrollAnimationRubberBand.mm	2022-01-21 01:13:00 UTC (rev 288335)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimationRubberBand.mm	2022-01-21 01:23:53 UTC (rev 288336)
@@ -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: trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm (288335 => 288336)


--- trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm	2022-01-21 01:13:00 UTC (rev 288335)
+++ trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm	2022-01-21 01:23:53 UTC (rev 288336)
@@ -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