Bug 699937 - (Cleanup) Remove unused timestamp values [r=Cwiiis]
authorKartikaya Gupta <kgupta@mozilla.com>
Mon, 21 Nov 2011 15:26:45 -0500
changeset 83564 be195eac506c421456ffa85fe6121679ee567b25
parent 83563 88a9701f51350f3ba2331082f20551747d90e050
child 83565 afc56afc464fa187a9126462204d71ea6d5dd6b7
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)
reviewersCwiiis
bugs699937
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 699937 - (Cleanup) Remove unused timestamp values [r=Cwiiis]
mobile/android/base/ui/PanZoomController.java
--- a/mobile/android/base/ui/PanZoomController.java
+++ b/mobile/android/base/ui/PanZoomController.java
@@ -79,17 +79,16 @@ public class PanZoomController
     // values make the animation more accurate, but slower to plot.
     private static final int SUBDIVISION_COUNT = 1000;
     // The distance the user has to pan before we recognize it as such (e.g. to avoid
     // 1-pixel pans between the touch-down and touch-up of a click)
     private static final float PAN_THRESHOLD = 4.0f;
     // Angle from axis within which we stay axis-locked
     private static final double AXIS_LOCK_ANGLE = Math.PI / 15.0; // 12 degrees
 
-    private long mLastTimestamp;
     private Timer mFlingTimer;
     private Axis mX, mY;
     /* The span at the first zoom event (in unzoomed page coordinates). */
     private float mInitialZoomSpan;
     /* The zoom focus at the first zoom event (in unzoomed page coordinates). */
     private PointF mInitialZoomFocus;
 
     private enum PanZoomState {
@@ -161,31 +160,30 @@ public class PanZoomController
     private boolean onTouchMove(MotionEvent event) {
         switch (mState) {
         case NOTHING:
         case FLING:
             // should never happen
             Log.e(LOGTAG, "Received impossible touch move while in " + mState);
             return false;
         case TOUCHING:
-            mLastTimestamp = System.currentTimeMillis();
             if (panDistance(event) < PAN_THRESHOLD)
                 return false;
             // fall through
         case PANNING_HOLD_LOCKED:
             mState = PanZoomState.PANNING_LOCKED;
             // fall through
         case PANNING_LOCKED:
-            track(event, System.currentTimeMillis());
+            track(event);
             return true;
         case PANNING_HOLD:
             mState = PanZoomState.PANNING;
             // fall through
         case PANNING:
-            track(event, System.currentTimeMillis());
+            track(event);
             return true;
         case PINCHING:
             // scale gesture listener will handle this
             return false;
         }
         Log.e(LOGTAG, "Unhandled case " + mState + " in onTouchMove");
         return false;
     }
@@ -201,17 +199,17 @@ public class PanZoomController
             mState = PanZoomState.NOTHING;
             // TODO: send click to gecko
             return false;
         case PANNING:
         case PANNING_LOCKED:
         case PANNING_HOLD:
         case PANNING_HOLD_LOCKED:
             mState = PanZoomState.FLING;
-            fling(System.currentTimeMillis());
+            fling();
             return true;
         case PINCHING:
             int points = event.getPointerCount();
             if (points == 1) {
                 // last touch up
                 mState = PanZoomState.NOTHING;
             } else if (points == 2) {
                 int pointRemovedIndex = event.getActionIndex();
@@ -234,20 +232,17 @@ public class PanZoomController
     }
 
     private float panDistance(MotionEvent move) {
         float dx = mX.firstTouchPos - move.getX(0);
         float dy = mY.firstTouchPos - move.getY(0);
         return (float)Math.sqrt(dx * dx + dy * dy);
     }
 
-    private void track(MotionEvent event, long timestamp) {
-        long timeStep = timestamp - mLastTimestamp;
-        mLastTimestamp = timestamp;
-
+    private void track(MotionEvent event) {
         float x = event.getX(0);
         float y = event.getY(0);
 
         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)) {
@@ -282,20 +277,17 @@ public class PanZoomController
             }
         }
 
         mX.applyEdgeResistance(); mX.displace();
         mY.applyEdgeResistance(); mY.displace();
         updatePosition();
     }
 
-    private void fling(long timestamp) {
-        long timeStep = timestamp - mLastTimestamp;
-        mLastTimestamp = timestamp;
-
+    private void fling() {
         if (mState != PanZoomState.FLING)
             mX.velocity = mY.velocity = 0.0f;
 
         mX.displace(); mY.displace();
         updatePosition();
 
         if (mFlingTimer != null)
             mFlingTimer.cancel();
@@ -630,17 +622,16 @@ public class PanZoomController
 
         GeckoApp.mAppContext.hidePluginViews();
         return true;
     }
 
     @Override
     public void onScaleEnd(ScaleGestureDetector detector) {
         mState = PanZoomState.PANNING_HOLD_LOCKED;
-        mLastTimestamp = System.currentTimeMillis();
         mX.firstTouchPos = mX.touchPos = detector.getFocusX();
         mY.firstTouchPos = mY.touchPos = detector.getFocusY();
 
         GeckoApp.mAppContext.showPluginViews();
     }
 
     @Override
     public void onLongPress(MotionEvent motionEvent) {