Bug 1019999 - Clear overscroll if snap-back animation is cancelled. r=kats

--HG--
extra : source : 20ace5785615d1cc7d0edbe7e09f8691166c6166
This commit is contained in:
Botond Ballo 2014-06-06 13:58:48 -04:00
parent 0ae54304d5
commit fc6ec3cd46
4 changed files with 28 additions and 1 deletions

View File

@ -505,6 +505,16 @@ public:
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;
};
@ -1684,7 +1694,12 @@ void AsyncPanZoomController::StartAnimation(AsyncPanZoomAnimation* aAnimation)
void AsyncPanZoomController::CancelAnimation() {
ReentrantMonitorAutoEnter lock(mMonitor);
SetState(NOTHING);
mAnimation = nullptr;
if (mAnimation) {
mAnimation->Cancel();
mAnimation = nullptr;
// mAnimation->Cancel() may have done something that requires a repaint.
RequestContentRepaint();
}
}
void AsyncPanZoomController::SetCompositorParent(CompositorParent* aCompositorParent) {

View File

@ -1032,6 +1032,9 @@ public:
virtual bool Sample(FrameMetrics& aFrameMetrics,
const TimeDuration& aDelta) = 0;
// Called if the animation is cancelled before it ends.
virtual void Cancel() {}
/**
* Get the deferred tasks in |mDeferredTasks|. See |mDeferredTasks|
* for more information.

View File

@ -177,6 +177,10 @@ bool Axis::IsOverscrolled() const {
return mOverscroll != 0;
}
void Axis::ClearOverscroll() {
mOverscroll = 0;
}
float Axis::PanDistance() {
return fabsf(mPos - mStartPos);
}

View File

@ -109,6 +109,11 @@ public:
*/
bool IsOverscrolled() const;
/**
* Clear any overscroll amount on this axis.
*/
void ClearOverscroll();
/**
* Gets the distance between the starting position of the touch supplied in
* startTouch() and the current touch from the last