Bug 1547242 - Specify nsIScrollableFrame::LINES for scroll-snap on flinging. r=botond
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Sat, 27 Apr 2019 01:40:09 +0000
changeset 530437 8754c7d0d1167eb3e47d36a616e570ed8188ae96
parent 530436 2ee0a3c1e93985cd4f4eed2ab87b90aedd87e9cb
child 530438 8c9fc50e48c2a04b4167ab45884fd3f7dbaee763
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1547242
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1547242 - Specify nsIScrollableFrame::LINES for scroll-snap on flinging. r=botond Flinging has a direction of its movement, so unlike releasing a drag gesture, we want to ignore snap positions in the opposite direction. See the comment how/why we ignore the snap positions in the opposite direction at the top of CalcSnapPoints::AddEdge(). Differential Revision: https://phabricator.services.mozilla.com/D28989
gfx/layers/apz/src/AsyncPanZoomController.cpp
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -5239,28 +5239,30 @@ void AsyncPanZoomController::ScrollSnapT
   // user would not see any overscroll animation.
   bool flingWillOverscroll =
       IsOverscrolled() && ((velocity.x * mX.GetOverscroll() >= 0) ||
                            (velocity.y * mY.GetOverscroll() >= 0));
   if (flingWillOverscroll) {
     return;
   }
 
-  CSSPoint predictedDestination =
-      Metrics().GetScrollOffset() + predictedDelta / Metrics().GetZoom();
-  APZC_LOG(
-      "%p fling snapping.  friction: %f velocity: %f, %f "
-      "predictedDelta: %f, %f position: %f, %f "
-      "predictedDestination: %f, %f\n",
-      this, friction, velocity.x, velocity.y, (float)predictedDelta.x,
-      (float)predictedDelta.y, (float)Metrics().GetScrollOffset().x,
-      (float)Metrics().GetScrollOffset().y, (float)predictedDestination.x,
-      (float)predictedDestination.y);
-
-  ScrollSnapNear(predictedDestination);
+  CSSPoint startPosition = Metrics().GetScrollOffset();
+  if (MaybeAdjustDeltaForScrollSnapping(nsIScrollableFrame::LINES,
+                                        predictedDelta, startPosition)) {
+    APZC_LOG(
+        "%p fling snapping.  friction: %f velocity: %f, %f "
+        "predictedDelta: %f, %f position: %f, %f "
+        "snapDestination: %f, %f\n",
+        this, friction, velocity.x, velocity.y, (float)predictedDelta.x,
+        (float)predictedDelta.y, (float)Metrics().GetScrollOffset().x,
+        (float)Metrics().GetScrollOffset().y, (float)startPosition.x,
+        (float)startPosition.y);
+
+    SmoothScrollTo(startPosition);
+  }
 }
 
 bool AsyncPanZoomController::MaybeAdjustDeltaForScrollSnapping(
     nsIScrollableFrame::ScrollUnit aUnit, ParentLayerPoint& aDelta,
     CSSPoint& aStartPosition) {
   RecursiveMutexAutoLock lock(mRecursiveMutex);
   CSSToParentLayerScale2D zoom = Metrics().GetZoom();
   CSSPoint destination = Metrics().CalculateScrollRange().ClampPoint(