Bug 711453 - Avoid potentially corrupting the fling velocity. r=pcwalton
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 19 Dec 2011 09:26:41 -0500
changeset 84606 e6179f497b7468f5873cc532b596761f3e4ca003
parent 84605 a55e32a938ea9326b64fa23583ef4fecddfaec04
child 84652 e2194521b6c0b3ffb932466cf1c15cbc63851d26
child 84676 92bf605a98492e86790e793fd876711884cbb9fa
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspcwalton
bugs711453
milestone11.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 711453 - Avoid potentially corrupting the fling velocity. r=pcwalton
mobile/android/base/ui/PanZoomController.java
--- a/mobile/android/base/ui/PanZoomController.java
+++ b/mobile/android/base/ui/PanZoomController.java
@@ -397,16 +397,22 @@ public class PanZoomController
     }
 
     private float clampByFactor(float oldValue, float newValue, float factor) {
         float maxChange = Math.abs(oldValue * factor);
         return Math.min(oldValue + maxChange, Math.max(oldValue - maxChange, newValue));
     }
 
     private void track(float x, float y, float lastX, float lastY, float timeDelta) {
+        if (FloatUtils.fuzzyEquals(timeDelta, 0)) {
+            // probably a duplicate event, ignore it. using a zero timeDelta will mess
+            // up our velocity
+            return;
+        }
+
         if (mState == PanZoomState.PANNING_LOCKED) {
             // check to see if we should break the axis lock
             double angle = Math.atan2(y - mY.firstTouchPos, x - mX.firstTouchPos); // range [-pi, pi]
             angle = Math.abs(angle); // range [0, pi]
             if (angle < AXIS_LOCK_ANGLE || angle > (Math.PI - AXIS_LOCK_ANGLE)) {
                 // lock to x-axis
                 mX.locked = false;
                 mY.locked = true;