Bug 1448439 - Allow the concrete type of fling animations to be determined dynamically. r=kats

MozReview-Commit-ID: EBscYyxdlwr

--HG--
extra : rebase_source : 19de9aa3c6d1482ace56ce6a4314fe2538a760a7
This commit is contained in:
Botond Ballo 2018-04-17 19:53:26 -04:00
Родитель 0e5e89ecea
Коммит 7db51a6a16
5 изменённых файлов: 27 добавлений и 8 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -22,6 +22,9 @@ public:
return this;
}
virtual AsyncPanZoomAnimation* CreateFlingAnimation(AsyncPanZoomController& aApzc,
const FlingHandoffState& aHandoffState) override;
java::StackScroller::GlobalRef mOverScroller;
TimeStamp mLastFling;
};

Просмотреть файл

@ -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);
}

Просмотреть файл

@ -69,6 +69,8 @@ class PlatformSpecificStateBase {
public:
virtual ~PlatformSpecificStateBase() = default;
virtual AndroidSpecificState* AsAndroidSpecificState() { return nullptr; }
virtual AsyncPanZoomAnimation* CreateFlingAnimation(AsyncPanZoomController& aApzc,
const FlingHandoffState& aHandoffState);
};
/*

Просмотреть файл

@ -30,7 +30,6 @@ namespace layers {
class GenericFlingAnimation: public AsyncPanZoomAnimation {
public:
GenericFlingAnimation(AsyncPanZoomController& aApzc,
PlatformSpecificStateBase* aPlatformSpecificState,
const RefPtr<const OverscrollHandoffChain>& aOverscrollHandoffChain,
bool aFlingIsHandedOff,
const RefPtr<const AsyncPanZoomController>& aScrolledApzc)