Bug 721125 - Prevent the edge resistance from being negative, which can wreak havoc on the viewport. r=pcwalton
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 31 Jan 2012 00:42:40 -0500
changeset 87035 4b41e38a1f131e29c491ba26ee4cea0d89f53899
parent 87034 042092c83f226993dc822bc8d16c0db6b547018c
child 87036 2fa163bb05d764c56d243c345d003cd39567c3a2
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspcwalton
bugs721125
milestone12.0a1
Bug 721125 - Prevent the edge resistance from being negative, which can wreak havoc on the viewport. r=pcwalton
mobile/android/base/ui/Axis.java
--- a/mobile/android/base/ui/Axis.java
+++ b/mobile/android/base/ui/Axis.java
@@ -180,17 +180,22 @@ abstract class Axis {
     }
 
     /*
      * Returns the resistance, as a multiplier, that should be taken into account when
      * tracking or pinching.
      */
     float getEdgeResistance() {
         float excess = getExcess();
-        return (excess > 0.0f) ? SNAP_LIMIT - excess / getViewportLength() : 1.0f;
+        if (excess > 0.0f) {
+            // excess can be greater than viewport length, but the resistance
+            // must never drop below 0.0
+            return Math.max(0.0f, SNAP_LIMIT - excess / getViewportLength());
+        }
+        return 1.0f;
     }
 
     /* Returns the velocity. If the axis is locked, returns 0. */
     float getRealVelocity() {
         return (mLocked || !scrollable()) ? 0.0f : mVelocity;
     }
 
     void startPan() {