From 60dc6f547465df77eb3f6b8a44f6d257e78c03e5 Mon Sep 17 00:00:00 2001 From: Botond Ballo Date: Fri, 5 Sep 2014 18:42:03 -0400 Subject: [PATCH] Bug 1063224 - Add a PanStart() method to AsyncPanZoomController. r=kats --HG-- extra : source : c26cacfcd1998dddd2982062c844e10bc5736541 --- gfx/layers/apz/src/AsyncPanZoomController.cpp | 4 ++++ gfx/layers/apz/src/AsyncPanZoomController.h | 10 ++++++++++ gfx/layers/apz/src/Axis.cpp | 4 ++++ gfx/layers/apz/src/Axis.h | 11 ++++++++--- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index d598190858c..1e2a3c98430 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -1726,6 +1726,10 @@ float AsyncPanZoomController::PanDistance() const { return NS_hypot(mX.PanDistance(), mY.PanDistance()); } +ScreenPoint AsyncPanZoomController::PanStart() const { + return ScreenPoint(mX.PanStart(), mY.PanStart()); +} + const ScreenPoint AsyncPanZoomController::GetVelocityVector() { return ScreenPoint(mX.GetVelocity(), mY.GetVelocity()); } diff --git a/gfx/layers/apz/src/AsyncPanZoomController.h b/gfx/layers/apz/src/AsyncPanZoomController.h index d194bd8f1a8..0160adcc846 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.h +++ b/gfx/layers/apz/src/AsyncPanZoomController.h @@ -488,6 +488,16 @@ protected: */ float PanDistance() const; + /** + * Gets the start point of the current touch. + * Like PanDistance(), this only makes sense if a touch is currently + * happening and OnTouchMove() or the equivalent for pan gestures is + * being invoked. + * Unlikely PanDistance(), this function returns a point in local screen + * coordinates. + */ + ScreenPoint PanStart() const; + /** * Gets a vector of the velocities of each axis. */ diff --git a/gfx/layers/apz/src/Axis.cpp b/gfx/layers/apz/src/Axis.cpp index ffecca597b6..0c627178dbf 100644 --- a/gfx/layers/apz/src/Axis.cpp +++ b/gfx/layers/apz/src/Axis.cpp @@ -207,6 +207,10 @@ void Axis::ClearOverscroll() { mOverscroll = 0; } +ScreenCoord Axis::PanStart() const { + return mStartPos; +} + ScreenCoord Axis::PanDistance() const { return fabs(mPos - mStartPos); } diff --git a/gfx/layers/apz/src/Axis.h b/gfx/layers/apz/src/Axis.h index 0dc262243f7..d4800cf4a20 100644 --- a/gfx/layers/apz/src/Axis.h +++ b/gfx/layers/apz/src/Axis.h @@ -118,16 +118,21 @@ public: */ void ClearOverscroll(); + /** + * Gets the starting position of the touch supplied in StartTouch(). + */ + ScreenCoord PanStart() const; + /** * Gets the distance between the starting position of the touch supplied in - * startTouch() and the current touch from the last - * updateWithTouchAtDevicePoint(). + * StartTouch() and the current touch from the last + * UpdateWithTouchAtDevicePoint(). */ ScreenCoord PanDistance() const; /** * Gets the distance between the starting position of the touch supplied in - * startTouch() and the supplied position. + * StartTouch() and the supplied position. */ ScreenCoord PanDistance(ScreenCoord aPos) const;