Bug 1093298 - Ignore calls to AsyncPanZoomAnimation::Sample() with a negative time duration. r=kats

This commit is contained in:
Botond Ballo 2014-11-17 13:18:16 -05:00
Родитель 670f12a2d1
Коммит 3e52bb8e18
2 изменённых файлов: 21 добавлений и 26 удалений

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

@ -533,21 +533,9 @@ public:
* frame. Returns true if the fling animation should be advanced by one frame,
* or false if there is no fling or the fling has ended.
*/
virtual bool Sample(FrameMetrics& aFrameMetrics,
const TimeDuration& aDelta) MOZ_OVERRIDE
virtual bool DoSample(FrameMetrics& aFrameMetrics,
const TimeDuration& aDelta) MOZ_OVERRIDE
{
// If the fling is handed off to our APZC from a child, on the first call to
// Sample() aDelta might be negative because it's computed as the sample time
// from SampleContentTransformForFrame() minus our APZC's mLastSampleTime
// which is the time the child handed off the fling from its call to
// SampleContentTransformForFrame() with the same sample time. If we allow
// the negative aDelta to be processed, it will yield a displacement in the
// direction opposite to the fling, which can cause us to overscroll and
// hand off the fling to _our_ parent, which effectively kills the fling.
if (aDelta.ToMilliseconds() <= 0) {
return true;
}
float friction = gfxPrefs::APZFlingFriction();
float threshold = gfxPrefs::APZFlingStoppedThreshold();
@ -655,8 +643,8 @@ public:
, mEndZoom(aEndZoom)
{}
virtual bool Sample(FrameMetrics& aFrameMetrics,
const TimeDuration& aDelta) MOZ_OVERRIDE
virtual bool DoSample(FrameMetrics& aFrameMetrics,
const TimeDuration& aDelta) MOZ_OVERRIDE
{
mDuration += aDelta;
double animPosition = mDuration / mTotalDuration;
@ -712,8 +700,8 @@ public:
mApzc.mY.SetVelocity(aVelocity.y);
}
virtual bool Sample(FrameMetrics& aFrameMetrics,
const TimeDuration& aDelta) MOZ_OVERRIDE
virtual bool DoSample(FrameMetrics& aFrameMetrics,
const TimeDuration& aDelta) MOZ_OVERRIDE
{
// Can't inline these variables due to short-circuit evaluation.
bool continueX = mApzc.mX.SampleOverscrollAnimation(aDelta);
@ -747,12 +735,7 @@ public:
* frame. Returns true if the smooth scroll should be advanced by one frame,
* or false if the smooth scroll has ended.
*/
bool Sample(FrameMetrics& aFrameMetrics, const TimeDuration& aDelta) {
if (aDelta.ToMilliseconds() <= 0) {
return true;
}
bool DoSample(FrameMetrics& aFrameMetrics, const TimeDuration& aDelta) {
if (mXAxisModel.IsFinished() && mYAxisModel.IsFinished()) {
return false;
}

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

@ -1125,8 +1125,20 @@ public:
: mRepaintInterval(aRepaintInterval)
{ }
virtual bool Sample(FrameMetrics& aFrameMetrics,
const TimeDuration& aDelta) = 0;
virtual bool DoSample(FrameMetrics& aFrameMetrics,
const TimeDuration& aDelta) = 0;
bool Sample(FrameMetrics& aFrameMetrics,
const TimeDuration& aDelta) {
// In some situations, particularly when handoff is involved, it's possible
// for |aDelta| to be negative on the first call to sample. Ignore such a
// sample here, to avoid each derived class having to deal with this case.
if (aDelta.ToMilliseconds() <= 0) {
return true;
}
return DoSample(aFrameMetrics, aDelta);
}
/**
* Get the deferred tasks in |mDeferredTasks|. See |mDeferredTasks|