Bug 927349 part 3 - Cancel a pending play when pause is called; r=jwatt

This patch updates the pause procedure for AnimationPlayer so that if there is
a pending play it will be cancelled.

At the same it removes the existing check for a redundant call to Pause when we
are already paused. This check is not necessary since if we are already paused
the method will have no effect anyway.

Finally, this patch updates the comment about going to the pending state while
pausing since this will happen in bug 1109390.
This commit is contained in:
Brian Birtles 2014-12-18 08:42:41 +09:00
parent e13569f368
commit 3a6cb969ee

View File

@ -245,15 +245,33 @@ AnimationPlayer::DoPlay()
void
AnimationPlayer::DoPause()
{
if (IsPaused()) {
return;
// Cancel a pending play
if (mIsPending) {
nsIDocument* doc = GetRenderedDocument();
if (doc) {
PendingPlayerTracker* tracker = doc->GetPendingPlayerTracker();
if (tracker) {
tracker->RemovePlayPending(*this);
}
}
mIsPending = false;
// Resolve the ready promise since we currently only use it for
// players that are waiting to play. Later (in bug 1109390), we will
// use this for players waiting to pause as well and then we won't
// want to resolve it just yet.
if (mReady) {
mReady->MaybeResolve(this);
}
}
// Mark this as no longer running on the compositor so that next time
// we update animations we won't throttle them and will have a chance
// to remove the animation from any layer it might be on.
mIsRunningOnCompositor = false;
// Bug 927349 - check for null result here and go to pending state
// Bug 1109390 - check for null result here and go to pending state
mHoldTime = GetCurrentTime();
mStartTime.SetNull();
}