Bug 962243 - Implement PINCH to TOUCHING transition in APZC. r=botond
authorDmitry Rozhkov <dmitry.rozhkov@jolla.com>
Sun, 22 Nov 2015 08:57:45 -0500
changeset 307838 b12a19262a28af01c1db5d5e73783b95eb9e9d93
parent 307837 8ff7083db0ea1bae54c3de676a90e688e428eab3
child 307839 dddbad2aa1aea05d1d1d5aade5a63797c36292d3
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs962243
milestone45.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 962243 - Implement PINCH to TOUCHING transition in APZC. r=botond
gfx/layers/apz/src/AsyncPanZoomController.cpp
gfx/layers/apz/src/GestureEventListener.cpp
widget/InputData.h
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -1543,16 +1543,24 @@ nsEventStatus AsyncPanZoomController::On
     // things) to handle it.
     RequestSnap();
 
     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);
+    SetState(TOUCHING);
+  }
+
   return nsEventStatus_eConsumeNoDefault;
 }
 
 bool
 AsyncPanZoomController::ConvertToGecko(const ScreenIntPoint& aPoint, CSSPoint* aOut)
 {
   if (APZCTreeManager* treeManagerLocal = GetApzcTreeManager()) {
     Matrix4x4 transformScreenToGecko = treeManagerLocal->GetScreenToApzcTransform(this) 
--- a/gfx/layers/apz/src/GestureEventListener.cpp
+++ b/gfx/layers/apz/src/GestureEventListener.cpp
@@ -96,16 +96,23 @@ nsEventStatus GestureEventListener::Hand
 
     if (aEvent.mTouches.Length() == 1) {
       rv = HandleInputTouchSingleStart();
     } else {
       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;
+        }
+      }
+    }
     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++) {
         if (aEvent.mTouches[i].mIdentifier == mTouches[j].mIdentifier) {
           mTouches.RemoveElementAt(j);
           break;
@@ -370,20 +377,26 @@ 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);
+      if (mTouches.Length() == 1) {
+        // As user still keeps one finger down the event's focus point should
+        // contain meaningful data.
+        point = mTouches[0].mScreenPoint;
+      }
       PinchGestureInput pinchEvent(PinchGestureInput::PINCHGESTURE_END,
                                    mLastTouchInput.mTime,
                                    mLastTouchInput.mTimeStamp,
-                                   ScreenPoint(),
+                                   point,
                                    1.0f,
                                    1.0f,
                                    mLastTouchInput.modifiers);
       mAsyncPanZoomController->HandleGestureEvent(pinchEvent);
     }
 
     rv = nsEventStatus_eConsumeNoDefault;
 
--- a/widget/InputData.h
+++ b/widget/InputData.h
@@ -450,16 +450,19 @@ public:
 
   PinchGestureType mType;
 
   // Center point of the pinch gesture. That is, if there are two fingers on the
   // screen, it is their midpoint. In the case of more than two fingers, the
   // point is implementation-specific, but can for example be the midpoint
   // between the very first and very last touch. This is in device pixels and
   // are the coordinates on the screen of this midpoint.
+  // For PINCHGESTURE_END events, this instead will hold the coordinates of
+  // 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