Bug 1304729 - When transitioning from a pinch to a pan, make sure we start the pan with the correct coordinates. r=botond draft
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 22 Sep 2016 14:54:01 -0400
changeset 417090 8f274c32c95659bdef97c3dd94dee4bfa0ae2e97
parent 417089 ab1718c770489431443ab0bc47ca46733524f018
child 417091 4b0ecb4296a5266d2cc028d1728550f0a18356ff
push id30332
push userkgupta@mozilla.com
push dateFri, 23 Sep 2016 16:03:26 +0000
reviewersbotond
bugs1304729
milestone52.0a1
Bug 1304729 - When transitioning from a pinch to a pan, make sure we start the pan with the correct coordinates. r=botond MozReview-Commit-ID: CC4gPT2jubR
gfx/layers/apz/src/AsyncPanZoomController.cpp
gfx/layers/apz/src/GestureEventListener.cpp
gfx/layers/apz/test/gtest/InputUtils.h
widget/InputData.cpp
widget/InputData.h
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -1437,18 +1437,18 @@ nsEventStatus AsyncPanZoomController::On
     ScheduleComposite();
     RequestContentRepaint();
     UpdateSharedCompositorFrameMetrics();
   }
 
   // Non-negative focus point would indicate that one finger is still down
   if (aEvent.mFocusPoint.x != -1 && aEvent.mFocusPoint.y != -1) {
     mPanDirRestricted = false;
-    mX.StartTouch(aEvent.mFocusPoint.x, aEvent.mTime);
-    mY.StartTouch(aEvent.mFocusPoint.y, aEvent.mTime);
+    mX.StartTouch(aEvent.mLocalFocusPoint.x, aEvent.mTime);
+    mY.StartTouch(aEvent.mLocalFocusPoint.y, aEvent.mTime);
     SetState(TOUCHING);
   } else {
     // Otherwise, handle the fingers being lifted.
     ReentrantMonitorAutoEnter lock(mMonitor);
 
     // We can get into a situation where we are overscrolled at the end of a
     // pinch if we go into overscroll with a two-finger pan, and then turn
     // that into a pinch by increasing the span sufficiently. In such a case,
--- a/gfx/layers/apz/src/GestureEventListener.cpp
+++ b/gfx/layers/apz/src/GestureEventListener.cpp
@@ -100,16 +100,17 @@ nsEventStatus GestureEventListener::Hand
       rv = HandleInputTouchMultiStart();
     }
     break;
   case MultiTouchInput::MULTITOUCH_MOVE:
     for (size_t i = 0; i < aEvent.mTouches.Length(); i++) {
       for (size_t j = 0; j < mTouches.Length(); j++) {
         if (aEvent.mTouches[i].mIdentifier == mTouches[j].mIdentifier) {
           mTouches[j].mScreenPoint = aEvent.mTouches[i].mScreenPoint;
+          mTouches[j].mLocalScreenPoint = aEvent.mTouches[i].mLocalScreenPoint;
         }
       }
     }
     rv = HandleInputTouchMove();
     break;
   case MultiTouchInput::MULTITOUCH_END:
     for (size_t i = 0; i < aEvent.mTouches.Length(); i++) {
       for (size_t j = 0; j < mTouches.Length(); j++) {
@@ -380,21 +381,21 @@ nsEventStatus GestureEventListener::Hand
     if (mTouches.Length() < 2) {
       SetState(GESTURE_NONE);
     }
     break;
 
   case GESTURE_PINCH:
     if (mTouches.Length() < 2) {
       SetState(GESTURE_NONE);
-      ScreenPoint point(-1, -1);
+      ParentLayerPoint point(-1, -1);
       if (mTouches.Length() == 1) {
         // As user still keeps one finger down the event's focus point should
         // contain meaningful data.
-        point = mTouches[0].mScreenPoint;
+        point = mTouches[0].mLocalScreenPoint;
       }
       PinchGestureInput pinchEvent(PinchGestureInput::PINCHGESTURE_END,
                                    mLastTouchInput.mTime,
                                    mLastTouchInput.mTimeStamp,
                                    point,
                                    1.0f,
                                    1.0f,
                                    mLastTouchInput.modifiers);
--- a/gfx/layers/apz/test/gtest/InputUtils.h
+++ b/gfx/layers/apz/test/gtest/InputUtils.h
@@ -46,19 +46,20 @@ CreateSingleTouchData(int32_t aIdentifie
   return CreateSingleTouchData(aIdentifier, ScreenIntPoint(aX, aY));
 }
 
 PinchGestureInput
 CreatePinchGestureInput(PinchGestureInput::PinchGestureType aType,
                         const ScreenIntPoint& aFocus,
                         float aCurrentSpan, float aPreviousSpan)
 {
-  PinchGestureInput result(aType, 0, TimeStamp(), aFocus,
+  ParentLayerPoint localFocus(aFocus.x, aFocus.y);
+  PinchGestureInput result(aType, 0, TimeStamp(), localFocus,
                            aCurrentSpan, aPreviousSpan, 0);
-  result.mLocalFocusPoint = ParentLayerPoint(aFocus.x, aFocus.y);
+  result.mFocusPoint = aFocus;
   return result;
 }
 
 template<class InputReceiver>
 void
 SetDefaultAllowedTouchBehavior(const RefPtr<InputReceiver>& aTarget,
                                uint64_t aInputBlockId,
                                int touchPoints = 1)
--- a/widget/InputData.cpp
+++ b/widget/InputData.cpp
@@ -562,29 +562,16 @@ PanGestureInput::UserMultipliedLocalPanD
 
 PinchGestureInput::PinchGestureInput()
   : InputData(PINCHGESTURE_INPUT)
 {
 }
 
 PinchGestureInput::PinchGestureInput(PinchGestureType aType, uint32_t aTime,
                                      TimeStamp aTimeStamp,
-                                     const ScreenPoint& aFocusPoint,
-                                     float aCurrentSpan, float aPreviousSpan,
-                                     Modifiers aModifiers)
-  : InputData(PINCHGESTURE_INPUT, aTime, aTimeStamp, aModifiers)
-  , mType(aType)
-  , mFocusPoint(aFocusPoint)
-  , mCurrentSpan(aCurrentSpan)
-  , mPreviousSpan(aPreviousSpan)
-{
-}
-
-PinchGestureInput::PinchGestureInput(PinchGestureType aType, uint32_t aTime,
-                                     TimeStamp aTimeStamp,
                                      const ParentLayerPoint& aLocalFocusPoint,
                                      float aCurrentSpan, float 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
@@ -423,24 +423,17 @@ public:
     PINCHGESTURE_START,
     PINCHGESTURE_SCALE,
     PINCHGESTURE_END,
 
     // Used as an upper bound for ContiguousEnumSerializer
     PINCHGESTURE_SENTINEL,
   };
 
-  // Construct a tap gesture from a Screen point.
-  // mLocalFocusPoint remains (0,0) unless it's set later.
-  PinchGestureInput(PinchGestureType aType, uint32_t aTime,
-                    TimeStamp aTimeStamp, const ScreenPoint& aFocusPoint,
-                    float aCurrentSpan, float aPreviousSpan,
-                    Modifiers aModifiers);
-
-  // Construct a tap gesture from a ParentLayer point.
+  // 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);
 
   bool TransformToLocal(const ScreenToParentLayerMatrix4x4& aTransform);
 
   // Warning, this class is serialized and sent over IPC. Any change to its