Bug 1500565 - Avoid start a fling animation with infinite velocity. r=kats
authorBotond Ballo <botond@mozilla.com>
Thu, 25 Oct 2018 00:53:32 +0000
changeset 491248 58b7faab3b8ddb63bbba684aea4ee1883af5d418
parent 491247 1c2698dc96cb707f7979e5eadef311fc0f4c8c35
child 491249 76d5b62fb151f9d28edd7a626c7757ec8fdeda47
child 491260 62d141436b6fe23e04086c2bd2ee5d371926ab67
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewerskats
bugs1500565
milestone65.0a1
Bug 1500565 - Avoid start a fling animation with infinite velocity. r=kats Differential Revision: https://phabricator.services.mozilla.com/D9729
gfx/layers/apz/src/AsyncPanZoomController.cpp
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -3078,17 +3078,21 @@ ParentLayerPoint AsyncPanZoomController:
   }
   if (mY.CanScroll()) {
     mY.SetVelocity(mY.GetVelocity() + aHandoffState.mVelocity.y);
     residualVelocity.y = 0;
   }
 
   // If we're not scrollable in at least one of the directions in which we
   // were handed velocity, don't start a fling animation.
-  if (GetVelocityVector().Length() < gfxPrefs::APZFlingMinVelocityThreshold()) {
+  // The |IsFinite()| condition should only fail when running some tests
+  // that generate events faster than the clock resolution.
+  ParentLayerPoint velocity = GetVelocityVector();
+  if (!velocity.IsFinite() ||
+      velocity.Length() < gfxPrefs::APZFlingMinVelocityThreshold()) {
     // Relieve overscroll now if needed, since we will not transition to a fling
     // animation and then an overscroll animation, and relieve it then.
     aHandoffState.mChain->SnapBackOverscrolledApzc(this);
     return residualVelocity;
   }
 
   // If there's a scroll snap point near the predicted fling destination,
   // scroll there using a smooth scroll animation. Otherwise, start a