зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1030221 - Make sure to clear overscroll if we cancel a fling. r=drs
This commit is contained in:
Родитель
9a0452ea47
Коммит
abe4af6deb
|
@ -415,13 +415,34 @@ GetFrameTime() {
|
|||
return sFrameTime;
|
||||
}
|
||||
|
||||
class FlingAnimation: public AsyncPanZoomAnimation {
|
||||
// This is a base class for animations that can deal with
|
||||
// overscroll states. In particular, it ensures that overscroll
|
||||
// states are cleared when the animation is cancelled.
|
||||
class OverscrollableAnimation: public AsyncPanZoomAnimation {
|
||||
public:
|
||||
OverscrollableAnimation(AsyncPanZoomController& aApzc,
|
||||
const TimeDuration& aRepaintInterval = TimeDuration::Forever())
|
||||
: AsyncPanZoomAnimation(aRepaintInterval)
|
||||
, mApzc(aApzc)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void Cancel() MOZ_OVERRIDE
|
||||
{
|
||||
mApzc.mX.ClearOverscroll();
|
||||
mApzc.mY.ClearOverscroll();
|
||||
}
|
||||
|
||||
protected:
|
||||
AsyncPanZoomController& mApzc;
|
||||
};
|
||||
|
||||
class FlingAnimation: public OverscrollableAnimation {
|
||||
public:
|
||||
FlingAnimation(AsyncPanZoomController& aApzc,
|
||||
bool aApplyAcceleration,
|
||||
bool aAllowOverscroll)
|
||||
: AsyncPanZoomAnimation(TimeDuration::FromMilliseconds(gfxPrefs::APZFlingRepaintInterval()))
|
||||
, mApzc(aApzc)
|
||||
: OverscrollableAnimation(aApzc, TimeDuration::FromMilliseconds(gfxPrefs::APZFlingRepaintInterval()))
|
||||
, mAllowOverscroll(aAllowOverscroll)
|
||||
{
|
||||
TimeStamp now = GetFrameTime();
|
||||
|
@ -570,7 +591,6 @@ private:
|
|||
+ (aSupplemental * gfxPrefs::APZFlingAccelSupplementalMultiplier());
|
||||
}
|
||||
|
||||
AsyncPanZoomController& mApzc;
|
||||
bool mAllowOverscroll;
|
||||
};
|
||||
|
||||
|
@ -633,10 +653,12 @@ private:
|
|||
CSSToScreenScale mEndZoom;
|
||||
};
|
||||
|
||||
class OverscrollSnapBackAnimation: public AsyncPanZoomAnimation {
|
||||
class OverscrollSnapBackAnimation: public OverscrollableAnimation {
|
||||
public:
|
||||
OverscrollSnapBackAnimation(AsyncPanZoomController& aApzc)
|
||||
: mApzc(aApzc) {}
|
||||
: OverscrollableAnimation(aApzc)
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool Sample(FrameMetrics& aFrameMetrics,
|
||||
const TimeDuration& aDelta) MOZ_OVERRIDE
|
||||
|
@ -646,19 +668,6 @@ public:
|
|||
bool continueY = mApzc.mY.SampleSnapBack(aDelta);
|
||||
return continueX || continueY;
|
||||
}
|
||||
|
||||
virtual void Cancel() MOZ_OVERRIDE
|
||||
{
|
||||
// If the snap-back animation is cancelled for some reason, we need to
|
||||
// clear the overscroll, otherwise the user would be stuck in the
|
||||
// overscrolled state (since touch blocks beginning in an overscrolled
|
||||
// state are ignored).
|
||||
mApzc.mX.ClearOverscroll();
|
||||
mApzc.mY.ClearOverscroll();
|
||||
}
|
||||
|
||||
private:
|
||||
AsyncPanZoomController& mApzc;
|
||||
};
|
||||
|
||||
void
|
||||
|
@ -1746,6 +1755,7 @@ void AsyncPanZoomController::StartAnimation(AsyncPanZoomAnimation* aAnimation)
|
|||
|
||||
void AsyncPanZoomController::CancelAnimation() {
|
||||
ReentrantMonitorAutoEnter lock(mMonitor);
|
||||
APZC_LOG("%p running CancelAnimation in state %d\n", this, mState);
|
||||
SetState(NOTHING);
|
||||
if (mAnimation) {
|
||||
mAnimation->Cancel();
|
||||
|
|
|
@ -806,6 +806,7 @@ public:
|
|||
bool TakeOverFling(ScreenPoint aVelocity);
|
||||
|
||||
private:
|
||||
friend class OverscrollableAnimation;
|
||||
friend class FlingAnimation;
|
||||
friend class OverscrollSnapBackAnimation;
|
||||
// The initial velocity of the most recent fling.
|
||||
|
|
Загрузка…
Ссылка в новой задаче