From 0e04f56656a1473fe48941debcee565f90b65668 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Thu, 22 Sep 2016 14:54:01 -0400 Subject: [PATCH] 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 | 4 ++-- gfx/layers/apz/src/GestureEventListener.cpp | 5 +++-- gfx/layers/apz/test/gtest/InputUtils.h | 5 +++-- widget/InputData.cpp | 13 ------------- widget/InputData.h | 9 +-------- 5 files changed, 9 insertions(+), 27 deletions(-) diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 239bb99cd850..02da520dad30 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -1442,8 +1442,8 @@ nsEventStatus AsyncPanZoomController::OnScaleEnd(const PinchGestureInput& aEvent // 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. diff --git a/gfx/layers/apz/src/GestureEventListener.cpp b/gfx/layers/apz/src/GestureEventListener.cpp index bb3a7621b411..9727fbf9ebb1 100644 --- a/gfx/layers/apz/src/GestureEventListener.cpp +++ b/gfx/layers/apz/src/GestureEventListener.cpp @@ -105,6 +105,7 @@ nsEventStatus GestureEventListener::HandleInputEvent(const MultiTouchInput& aEve 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; } } } @@ -385,11 +386,11 @@ nsEventStatus GestureEventListener::HandleInputTouchEnd() 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, diff --git a/gfx/layers/apz/test/gtest/InputUtils.h b/gfx/layers/apz/test/gtest/InputUtils.h index 36bb760ee621..a1bd2851e276 100644 --- a/gfx/layers/apz/test/gtest/InputUtils.h +++ b/gfx/layers/apz/test/gtest/InputUtils.h @@ -51,9 +51,10 @@ 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; } diff --git a/widget/InputData.cpp b/widget/InputData.cpp index fa0c6492dc27..b67c48192b02 100644 --- a/widget/InputData.cpp +++ b/widget/InputData.cpp @@ -565,19 +565,6 @@ PinchGestureInput::PinchGestureInput() { } -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, diff --git a/widget/InputData.h b/widget/InputData.h index 637cb2b6a2e4..7cba2921fa3d 100644 --- a/widget/InputData.h +++ b/widget/InputData.h @@ -428,14 +428,7 @@ public: 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,