diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 25d042569af..c0bc1628ad3 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -530,13 +530,13 @@ AsyncPanZoomController::AsyncPanZoomController(uint64_t aLayersId, mSharingFrameMetricsAcrossProcesses(false), mMonitor("AsyncPanZoomController"), mTouchActionPropertyEnabled(gfxPrefs::TouchActionEnabled()), + mState(NOTHING), mContentResponseTimeoutTask(nullptr), mX(MOZ_THIS_IN_INITIALIZER_LIST()), mY(MOZ_THIS_IN_INITIALIZER_LIST()), mPanDirRestricted(false), mZoomConstraints(false, false, MIN_ZOOM, MAX_ZOOM), mLastSampleTime(GetFrameTime()), - mState(NOTHING), mLastAsyncScrollTime(GetFrameTime()), mLastAsyncScrollOffset(0, 0), mCurrentAsyncScrollOffset(0, 0), diff --git a/gfx/layers/apz/src/AsyncPanZoomController.h b/gfx/layers/apz/src/AsyncPanZoomController.h index 2fcd39e4563..0798835c054 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.h +++ b/gfx/layers/apz/src/AsyncPanZoomController.h @@ -319,6 +319,29 @@ public: bool IsPannable() const; protected: + enum PanZoomState { + NOTHING, /* no touch-start events received */ + FLING, /* all touches removed, but we're still scrolling page */ + TOUCHING, /* one touch-start event received */ + + PANNING, /* panning the frame */ + PANNING_LOCKED_X, /* touch-start followed by move (i.e. panning with axis lock) X axis */ + PANNING_LOCKED_Y, /* as above for Y axis */ + + CROSS_SLIDING_X, /* Panning disabled while user does a horizontal gesture + on a vertically-scrollable view. This used for the + Windows Metro "cross-slide" gesture. */ + CROSS_SLIDING_Y, /* as above for Y axis */ + + PINCHING, /* nth touch-start, where n > 1. this mode allows pan and zoom */ + ANIMATING_ZOOM, /* animated zoom to a new rect */ + WAITING_CONTENT_RESPONSE, /* a state halfway between NOTHING and TOUCHING - the user has + put a finger down, but we don't yet know if a touch listener has + prevented the default actions yet and the allowed touch behavior + was not set yet. we still need to abort animations. */ + SNAP_BACK, /* snap-back animation to relieve overscroll */ + }; + // Protected destructor, to discourage deletion outside of Release(): ~AsyncPanZoomController(); @@ -519,29 +542,6 @@ protected: void FireAsyncScrollOnTimeout(); private: - enum PanZoomState { - NOTHING, /* no touch-start events received */ - FLING, /* all touches removed, but we're still scrolling page */ - TOUCHING, /* one touch-start event received */ - - PANNING, /* panning the frame */ - PANNING_LOCKED_X, /* touch-start followed by move (i.e. panning with axis lock) X axis */ - PANNING_LOCKED_Y, /* as above for Y axis */ - - CROSS_SLIDING_X, /* Panning disabled while user does a horizontal gesture - on a vertically-scrollable view. This used for the - Windows Metro "cross-slide" gesture. */ - CROSS_SLIDING_Y, /* as above for Y axis */ - - PINCHING, /* nth touch-start, where n > 1. this mode allows pan and zoom */ - ANIMATING_ZOOM, /* animated zoom to a new rect */ - WAITING_CONTENT_RESPONSE, /* a state halfway between NOTHING and TOUCHING - the user has - put a finger down, but we don't yet know if a touch listener has - prevented the default actions yet and the allowed touch behavior - was not set yet. we still need to abort animations. */ - SNAP_BACK, /* snap-back animation to relieve overscroll */ - }; - // State related to a single touch block. Does not persist across touch blocks. struct TouchBlockState { @@ -690,6 +690,10 @@ protected: // (e.g. with the gtest framework). bool mTouchActionPropertyEnabled; + // Stores the state of panning and zooming this frame. This is protected by + // |mMonitor|; that is, it should be held whenever this is updated. + PanZoomState mState; + private: // Metrics of the container layer corresponding to this APZC. This is // stored here so that it is accessible from the UI/controller thread. @@ -732,10 +736,6 @@ private: // to allow panning by moving multiple fingers (thus moving the focus point). ParentLayerPoint mLastZoomFocus; - // Stores the state of panning and zooming this frame. This is protected by - // |mMonitor|; that is, it should be held whenever this is updated. - PanZoomState mState; - // The last time and offset we fire the mozbrowserasyncscroll event when // compositor has sampled the content transform for this frame. TimeStamp mLastAsyncScrollTime; diff --git a/gfx/tests/gtest/TestAsyncPanZoomController.cpp b/gfx/tests/gtest/TestAsyncPanZoomController.cpp index 5c3c69bab05..7dbeadda6a2 100644 --- a/gfx/tests/gtest/TestAsyncPanZoomController.cpp +++ b/gfx/tests/gtest/TestAsyncPanZoomController.cpp @@ -139,6 +139,11 @@ public: ReentrantMonitorAutoEnter lock(mMonitor); return mFrameMetrics; } + + void AssertStateIsReset() { + ReentrantMonitorAutoEnter lock(mMonitor); + EXPECT_EQ(NOTHING, mState); + } }; class TestAPZCTreeManager : public APZCTreeManager { @@ -841,6 +846,7 @@ TEST_F(AsyncPanZoomControllerTester, ShortPress) { EXPECT_CALL(*mcc, HandleSingleTap(CSSPoint(10, 10), 0, apzc->GetGuid())).Times(1); mcc->RunDelayedTask(); + apzc->AssertStateIsReset(); apzc->Destroy(); } @@ -865,6 +871,7 @@ TEST_F(AsyncPanZoomControllerTester, MediumPress) { EXPECT_CALL(*mcc, HandleSingleTap(CSSPoint(10, 10), 0, apzc->GetGuid())).Times(1); mcc->RunDelayedTask(); + apzc->AssertStateIsReset(); apzc->Destroy(); } @@ -934,6 +941,7 @@ DoLongPressTest(bool aShouldUseTouchAction, uint32_t aBehavior) { apzc->ContentReceivedTouch(false); check.Call("postHandleLongTapUp"); + apzc->AssertStateIsReset(); apzc->Destroy(); } @@ -1020,6 +1028,7 @@ DoLongPressPreventDefaultTest(bool aShouldUseTouchAction, uint32_t aBehavior) { EXPECT_EQ(ScreenPoint(), pointOut); EXPECT_EQ(ViewTransform(), viewTransformOut); + apzc->AssertStateIsReset(); apzc->Destroy(); }