Bug 1298886 - Convert the PinchGestureInput span fields from float to ParentLayerCoord. r=botond
authorKartikaya Gupta <kgupta@mozilla.com>
Sat, 24 Sep 2016 09:46:01 -0400
changeset 358065 3437f7cc1db20cee2193a43c2f21c4ec633e7753
parent 358064 84d9e6f19e27f2ecb4fcd737c2e14c472bda5f4e
child 358066 bd20b9ac007d7e0416133744606c8dcd747dc1c9
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-beta@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1298886
milestone52.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 1298886 - Convert the PinchGestureInput span fields from float to ParentLayerCoord. r=botond MozReview-Commit-ID: 1Odp9ml6reK
gfx/layers/apz/src/GestureEventListener.cpp
gfx/layers/apz/src/GestureEventListener.h
widget/InputData.cpp
widget/InputData.h
--- a/gfx/layers/apz/src/GestureEventListener.cpp
+++ b/gfx/layers/apz/src/GestureEventListener.cpp
@@ -39,17 +39,17 @@ static bool sLongTapEnabled = true;
 
 ParentLayerPoint GetCurrentFocus(const MultiTouchInput& aEvent)
 {
   const ParentLayerPoint& firstTouch = aEvent.mTouches[0].mLocalScreenPoint;
   const ParentLayerPoint& secondTouch = aEvent.mTouches[1].mLocalScreenPoint;
   return (firstTouch + secondTouch) / 2;
 }
 
-float GetCurrentSpan(const MultiTouchInput& aEvent)
+ParentLayerCoord GetCurrentSpan(const MultiTouchInput& aEvent)
 {
   const ParentLayerPoint& firstTouch = aEvent.mTouches[0].mLocalScreenPoint;
   const ParentLayerPoint& secondTouch = aEvent.mTouches[1].mLocalScreenPoint;
   ParentLayerPoint delta = secondTouch - firstTouch;
   return delta.Length();
 }
 
 TapGestureInput CreateTapEvent(const MultiTouchInput& aTouch, TapGestureInput::TapGestureType aType)
@@ -266,17 +266,17 @@ nsEventStatus GestureEventListener::Hand
   }
 
   case GESTURE_MULTI_TOUCH_DOWN: {
     if (mLastTouchInput.mTouches.Length() < 2) {
       NS_WARNING("Wrong input: less than 2 moving points in GESTURE_MULTI_TOUCH_DOWN state");
       break;
     }
 
-    float currentSpan = GetCurrentSpan(mLastTouchInput);
+    ParentLayerCoord currentSpan = GetCurrentSpan(mLastTouchInput);
 
     mSpanChange += fabsf(currentSpan - mPreviousSpan);
     if (mSpanChange > PINCH_START_THRESHOLD) {
       SetState(GESTURE_PINCH);
       PinchGestureInput pinchEvent(PinchGestureInput::PINCHGESTURE_START,
                                    mLastTouchInput.mTime,
                                    mLastTouchInput.mTimeStamp,
                                    GetCurrentFocus(mLastTouchInput),
@@ -298,17 +298,17 @@ nsEventStatus GestureEventListener::Hand
   case GESTURE_PINCH: {
     if (mLastTouchInput.mTouches.Length() < 2) {
       NS_WARNING("Wrong input: less than 2 moving points in GESTURE_PINCH state");
       // Prevent APZC::OnTouchMove() from handling this wrong input
       rv = nsEventStatus_eConsumeNoDefault;
       break;
     }
 
-    float currentSpan = GetCurrentSpan(mLastTouchInput);
+    ParentLayerCoord currentSpan = GetCurrentSpan(mLastTouchInput);
 
     PinchGestureInput pinchEvent(PinchGestureInput::PINCHGESTURE_SCALE,
                                  mLastTouchInput.mTime,
                                  mLastTouchInput.mTimeStamp,
                                  GetCurrentFocus(mLastTouchInput),
                                  currentSpan,
                                  mPreviousSpan,
                                  mLastTouchInput.modifiers);
--- a/gfx/layers/apz/src/GestureEventListener.h
+++ b/gfx/layers/apz/src/GestureEventListener.h
@@ -166,23 +166,23 @@ private:
   GestureState mState;
 
   /**
    * Total change in span since we detected a pinch gesture. Only used when we
    * are in the |GESTURE_WAITING_PINCH| state and need to know how far zoomed
    * out we are compared to our original pinch span. Note that this does _not_
    * continue to be updated once we jump into the |GESTURE_PINCH| state.
    */
-  float mSpanChange;
+  ParentLayerCoord mSpanChange;
 
   /**
    * Previous span calculated for the purposes of setting inside a
    * PinchGestureInput.
    */
-  float mPreviousSpan;
+  ParentLayerCoord mPreviousSpan;
 
   /**
    * Cached copy of the last touch input.
    */
   MultiTouchInput mLastTouchInput;
 
   /**
    * Cached copy of the last tap gesture input.
--- a/widget/InputData.cpp
+++ b/widget/InputData.cpp
@@ -563,17 +563,18 @@ PanGestureInput::UserMultipliedLocalPanD
 PinchGestureInput::PinchGestureInput()
   : InputData(PINCHGESTURE_INPUT)
 {
 }
 
 PinchGestureInput::PinchGestureInput(PinchGestureType aType, uint32_t aTime,
                                      TimeStamp aTimeStamp,
                                      const ParentLayerPoint& aLocalFocusPoint,
-                                     float aCurrentSpan, float aPreviousSpan,
+                                     ParentLayerCoord aCurrentSpan,
+                                     ParentLayerCoord aPreviousSpan,
                                      Modifiers aModifiers)
   : InputData(PINCHGESTURE_INPUT, aTime, aTimeStamp, aModifiers)
   , mType(aType)
   , mLocalFocusPoint(aLocalFocusPoint)
   , mCurrentSpan(aCurrentSpan)
   , mPreviousSpan(aPreviousSpan)
 {
 }
--- a/widget/InputData.h
+++ b/widget/InputData.h
@@ -426,18 +426,19 @@ public:
 
     // Used as an upper bound for ContiguousEnumSerializer
     PINCHGESTURE_SENTINEL,
   };
 
   // Construct a pinch gesture from a ParentLayer point.
   // mFocusPoint remains (0,0) unless it's set later.
   PinchGestureInput(PinchGestureType aType, uint32_t aTime, TimeStamp aTimeStamp,
-                    const ParentLayerPoint& aLocalFocusPoint, float aCurrentSpan,
-                    float aPreviousSpan, Modifiers aModifiers);
+                    const ParentLayerPoint& aLocalFocusPoint,
+                    ParentLayerCoord aCurrentSpan,
+                    ParentLayerCoord aPreviousSpan, Modifiers aModifiers);
 
   bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
 
   // Warning, this class is serialized and sent over IPC. Any change to its
   // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
   PinchGestureType mType;
 
   // Center point of the pinch gesture. That is, if there are two fingers on the
@@ -449,25 +450,23 @@ public:
   // the remaining finger, if there is one. If there isn't one then it will
   // store -1, -1.
   ScreenPoint mFocusPoint;
 
   // |mFocusPoint| transformed to the local coordinates of the APZC targeted
   // by the hit. This is set and used by APZ.
   ParentLayerPoint mLocalFocusPoint;
 
-  // The distance in device pixels (though as a float for increased precision
-  // and because it is the distance along both the x and y axis) between the
-  // touches responsible for the pinch gesture.
-  float mCurrentSpan;
+  // The distance between the touches responsible for the pinch gesture.
+  ParentLayerCoord mCurrentSpan;
 
   // The previous |mCurrentSpan| in the PinchGestureInput preceding this one.
   // This is only really relevant during a PINCHGESTURE_SCALE because when it is
   // of this type then there must have been a history of spans.
-  float mPreviousSpan;
+  ParentLayerCoord mPreviousSpan;
 };
 
 /**
  * Encapsulation class for tap events. In general, these will be generated by
  * a gesture listener by looking at SingleTouchData/MultiTouchInput instances and
  * determining whether or not the user was trying to do a gesture.
  */
 class TapGestureInput : public InputData