diff --git a/gfx/layers/apz/src/AndroidAPZ.cpp b/gfx/layers/apz/src/AndroidAPZ.cpp index 6821edf16df9..0ce148552d47 100644 --- a/gfx/layers/apz/src/AndroidAPZ.cpp +++ b/gfx/layers/apz/src/AndroidAPZ.cpp @@ -43,6 +43,17 @@ AndroidSpecificState::AndroidSpecificState() { mOverScroller = scroller; } +AsyncPanZoomAnimation* +AndroidSpecificState::CreateFlingAnimation(AsyncPanZoomController& aApzc, + const FlingHandoffState& aHandoffState) { + return new AndroidFlingAnimation(aApzc, + this, + aHandoffState.mChain, + aHandoffState.mIsHandoff, + aHandoffState.mScrolledApzc); +} + + const float BOUNDS_EPSILON = 1.0f; // This function is used to convert the scroll offset from a float to an integer diff --git a/gfx/layers/apz/src/AndroidAPZ.h b/gfx/layers/apz/src/AndroidAPZ.h index 47ca3d1ef451..180a9ce40bee 100644 --- a/gfx/layers/apz/src/AndroidAPZ.h +++ b/gfx/layers/apz/src/AndroidAPZ.h @@ -22,6 +22,9 @@ public: return this; } + virtual AsyncPanZoomAnimation* CreateFlingAnimation(AsyncPanZoomController& aApzc, + const FlingHandoffState& aHandoffState) override; + java::StackScroller::GlobalRef mOverScroller; TimeStamp mLastFling; }; diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 1b8cf7c2773d..4afc57567fd4 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -118,11 +118,9 @@ using mozilla::gfx::PointTyped; #ifdef MOZ_WIDGET_ANDROID typedef WidgetOverscrollEffect OverscrollEffect; typedef AndroidSpecificState PlatformSpecificState; -typedef AndroidFlingAnimation FlingAnimation; #else typedef GenericOverscrollEffect OverscrollEffect; typedef PlatformSpecificStateBase PlatformSpecificState; // no extra state, just use the base class -typedef GenericFlingAnimation FlingAnimation; #endif /** @@ -516,6 +514,16 @@ static bool IsCloseToVertical(float aAngle, float aThreshold) // Counter used to give each APZC a unique id static uint32_t sAsyncPanZoomControllerCount = 0; +AsyncPanZoomAnimation* +PlatformSpecificStateBase::CreateFlingAnimation(AsyncPanZoomController& aApzc, + const FlingHandoffState& aHandoffState) +{ + return new GenericFlingAnimation(aApzc, + aHandoffState.mChain, + aHandoffState.mIsHandoff, + aHandoffState.mScrolledApzc); +} + TimeStamp AsyncPanZoomController::GetFrameTime() const { @@ -3011,11 +3019,7 @@ ParentLayerPoint AsyncPanZoomController::AttemptFling(const FlingHandoffState& a ScrollSnapToDestination(); if (mState != SMOOTH_SCROLL) { SetState(FLING); - FlingAnimation *fling = new FlingAnimation(*this, - GetPlatformSpecificState(), - aHandoffState.mChain, - aHandoffState.mIsHandoff, - aHandoffState.mScrolledApzc); + AsyncPanZoomAnimation* fling = GetPlatformSpecificState()->CreateFlingAnimation(*this, aHandoffState); StartAnimation(fling); } diff --git a/gfx/layers/apz/src/AsyncPanZoomController.h b/gfx/layers/apz/src/AsyncPanZoomController.h index 74d97fe594ee..6922469df4ac 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.h +++ b/gfx/layers/apz/src/AsyncPanZoomController.h @@ -69,6 +69,8 @@ class PlatformSpecificStateBase { public: virtual ~PlatformSpecificStateBase() = default; virtual AndroidSpecificState* AsAndroidSpecificState() { return nullptr; } + virtual AsyncPanZoomAnimation* CreateFlingAnimation(AsyncPanZoomController& aApzc, + const FlingHandoffState& aHandoffState); }; /* diff --git a/gfx/layers/apz/src/GenericFlingAnimation.h b/gfx/layers/apz/src/GenericFlingAnimation.h index 01fe77e35de9..812da7f2f285 100644 --- a/gfx/layers/apz/src/GenericFlingAnimation.h +++ b/gfx/layers/apz/src/GenericFlingAnimation.h @@ -30,7 +30,6 @@ namespace layers { class GenericFlingAnimation: public AsyncPanZoomAnimation { public: GenericFlingAnimation(AsyncPanZoomController& aApzc, - PlatformSpecificStateBase* aPlatformSpecificState, const RefPtr& aOverscrollHandoffChain, bool aFlingIsHandedOff, const RefPtr& aScrolledApzc)