Bug 1298886 - Convert the PinchGestureInput span fields from float to ParentLayerCoord. r?botond draft
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 23 Sep 2016 15:17:15 -0400
changeset 417186 ab6510b316a302a39345ad3a2f782edc4599b7ce
parent 416981 60cc643978c7020926fe4145761e26945fcd5c37
child 417187 16d8ae7f878814352b88435d821d591945986deb
push id30358
push userkgupta@mozilla.com
push dateFri, 23 Sep 2016 19:18:18 +0000
reviewersbotond
bugs1298886
milestone52.0a1
Bug 1298886 - Convert the PinchGestureInput span fields from float to ParentLayerCoord. r?botond MozReview-Commit-ID: HcnMTY7KTnP
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