Bug 1259296 - Make sure APZ smooth scroll animations end at their exact destination scroll offset. r=kats draft
authorBotond Ballo <botond@mozilla.com>
Mon, 04 Apr 2016 17:47:33 -0400
changeset 348681 3dbbf506be2c4fe2ee9b9a04d604b1869ba5e909
parent 348680 a9468a25f1b937c49c5f801069d2cdc2cd610bdd
child 348690 55c31b628e2e30b92947702a527de9c779000668
child 348695 e48c87aed3e8d8b857d0646d4b5daa5f247f2502
child 349476 b9f9bbb7a11a976ff696c28b026d292a8f90d0e1
push id14875
push userbballo@mozilla.com
push dateThu, 07 Apr 2016 21:45:38 +0000
reviewerskats
bugs1259296
milestone48.0a1
Bug 1259296 - Make sure APZ smooth scroll animations end at their exact destination scroll offset. r=kats This avoids getting "stuck" at a scroll snap point with wheel scrolling. MozReview-Commit-ID: 587UC8u1bv0
gfx/layers/apz/src/AsyncPanZoomController.cpp
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -732,16 +732,24 @@ public:
    * frame. Returns true if the smooth scroll should be advanced by one frame,
    * or false if the smooth scroll has ended.
    */
   bool DoSample(FrameMetrics& aFrameMetrics, const TimeDuration& aDelta) {
     nsPoint oneParentLayerPixel =
       CSSPoint::ToAppUnits(ParentLayerPoint(1, 1) / aFrameMetrics.GetZoom());
     if (mXAxisModel.IsFinished(oneParentLayerPixel.x) &&
         mYAxisModel.IsFinished(oneParentLayerPixel.y)) {
+      // Set the scroll offset to the exact destination. If we allow the scroll
+      // offset to end up being a bit off from the destination, we can get
+      // artefacts like "scroll to the next snap point in this direction"
+      // scrolling to the snap point we're already supposed to be at.
+      aFrameMetrics.SetScrollOffset(
+          aFrameMetrics.CalculateScrollRange().ClampPoint(
+              CSSPoint::FromAppUnits(nsPoint(mXAxisModel.GetDestination(),
+                                             mYAxisModel.GetDestination()))));
       return false;
     }
 
     mXAxisModel.Simulate(aDelta);
     mYAxisModel.Simulate(aDelta);
 
     CSSPoint position = CSSPoint::FromAppUnits(nsPoint(mXAxisModel.GetPosition(),
                                                        mYAxisModel.GetPosition()));