Title: [287714] trunk/Source/WebCore
Revision
287714
Author
[email protected]
Date
2022-01-06 12:51:35 -0800 (Thu, 06 Jan 2022)

Log Message

A gentle momentum scroll into an edge sometimes fails to rubberband, stopping abruptly
https://bugs.webkit.org/show_bug.cgi?id=234896

Reviewed by Tim Horton.

During the momentum phase of a scroll gesture we can hit the edge and try to determine that
we should start a rubberband animation. If, at this time, we happen to be at the edge, then
we'd fail to start the animation and the momentum would appear to stop abruptly.

Two fixes were needed. First,
ScrollingEffectsController::startRubberBandAnimationIfNecessary() looks at whether we're
currently stretched, but we might be passing through the edge on the way into a rubberband,
so also need to check for a stretch force.

Second, ScrollAnimationRubberBand needs to not stop prematurely if, in its first callback,
it's still at the edge even though it's animating into a rubberband. The easy fix here is to
just avoid completion during the first few frames.

I was unable to make a reliable layout test for this.

* platform/mac/ScrollAnimationRubberBand.mm:
(WebCore::ScrollAnimationRubberBand::serviceAnimation):
* platform/mac/ScrollingEffectsController.mm:
(WebCore::ScrollingEffectsController::startRubberBandAnimationIfNecessary):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (287713 => 287714)


--- trunk/Source/WebCore/ChangeLog	2022-01-06 20:32:42 UTC (rev 287713)
+++ trunk/Source/WebCore/ChangeLog	2022-01-06 20:51:35 UTC (rev 287714)
@@ -1,3 +1,30 @@
+2022-01-06  Simon Fraser  <[email protected]>
+
+        A gentle momentum scroll into an edge sometimes fails to rubberband, stopping abruptly
+        https://bugs.webkit.org/show_bug.cgi?id=234896
+
+        Reviewed by Tim Horton.
+
+        During the momentum phase of a scroll gesture we can hit the edge and try to determine that
+        we should start a rubberband animation. If, at this time, we happen to be at the edge, then
+        we'd fail to start the animation and the momentum would appear to stop abruptly.
+
+        Two fixes were needed. First,
+        ScrollingEffectsController::startRubberBandAnimationIfNecessary() looks at whether we're
+        currently stretched, but we might be passing through the edge on the way into a rubberband,
+        so also need to check for a stretch force.
+
+        Second, ScrollAnimationRubberBand needs to not stop prematurely if, in its first callback,
+        it's still at the edge even though it's animating into a rubberband. The easy fix here is to
+        just avoid completion during the first few frames.
+
+        I was unable to make a reliable layout test for this.
+
+        * platform/mac/ScrollAnimationRubberBand.mm:
+        (WebCore::ScrollAnimationRubberBand::serviceAnimation):
+        * platform/mac/ScrollingEffectsController.mm:
+        (WebCore::ScrollingEffectsController::startRubberBandAnimationIfNecessary):
+
 2022-01-06  Tim Nguyen  <[email protected]>
 
         Unprefix -webkit-print-color-adjust CSS property

Modified: trunk/Source/WebCore/platform/mac/ScrollAnimationRubberBand.mm (287713 => 287714)


--- trunk/Source/WebCore/platform/mac/ScrollAnimationRubberBand.mm	2022-01-06 20:32:42 UTC (rev 287713)
+++ trunk/Source/WebCore/platform/mac/ScrollAnimationRubberBand.mm	2022-01-06 20:51:35 UTC (rev 287714)
@@ -91,7 +91,8 @@
         roundToDevicePixelTowardZero(elasticDeltaForTimeDelta(m_initialOverscroll.height(), -m_initialVelocity.height(), elapsedTime))
     };
 
-    bool animationComplete = rubberBandOffset.isZero();
+    // 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;
 
     m_client.scrollAnimationDidUpdate(*this, m_currentOffset);

Modified: trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm (287713 => 287714)


--- trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm	2022-01-06 20:32:42 UTC (rev 287713)
+++ trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm	2022-01-06 20:51:35 UTC (rev 287714)
@@ -447,7 +447,7 @@
     bool willOverscroll = targetOffset != contrainedOffset;
 
     auto stretchAmount = m_client.stretchAmount();
-    if (stretchAmount.isZero() && !willOverscroll)
+    if (stretchAmount.isZero() && !willOverscroll && m_stretchScrollForce.isZero())
         return;
 
     auto initialVelocity = m_momentumVelocity;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to