Bug 1474247 - Factor out Animation::ReschedulePendingAnimations and make it public. r=birtles

The function will be used in the case of KeyframeEffect::SetTarget too.

MozReview-Commit-ID: G6ipjxaIJsW

--HG--
extra : rebase_source : 609fa17d698612df21d9cac469e6997582dcca69
This commit is contained in:
Hiroyuki Ikezoe 2018-07-12 17:05:13 +09:00
parent 4466a3936f
commit dce2768ffd
2 changed files with 37 additions and 22 deletions

View File

@ -189,28 +189,7 @@ Animation::SetEffectNoUpdate(AnimationEffect* aEffect)
nsNodeUtils::AnimationChanged(this);
}
// Reschedule pending pause or pending play tasks.
// If we have a pending animation, it will either be registered
// in the pending animation tracker and have a null pending ready time,
// or, after it has been painted, it will be removed from the tracker
// and assigned a pending ready time.
// After updating the effect we'll typically need to repaint so if we've
// already been assigned a pending ready time, we should clear it and put
// the animation back in the tracker.
if (!mPendingReadyTime.IsNull()) {
mPendingReadyTime.SetNull();
nsIDocument* doc = GetRenderedDocument();
if (doc) {
PendingAnimationTracker* tracker =
doc->GetOrCreatePendingAnimationTracker();
if (mPendingState == PendingState::PlayPending) {
tracker->AddPlayPending(*this);
} else {
tracker->AddPausePending(*this);
}
}
}
ReschedulePendingTasks();
}
UpdateTiming(SeekFlag::NoSeek, SyncNotifyFlag::Async);
@ -1482,6 +1461,27 @@ Animation::ResetPendingTasks()
}
}
void
Animation::ReschedulePendingTasks()
{
if (mPendingReadyTime.IsNull()) {
return;
}
mPendingReadyTime.SetNull();
nsIDocument* doc = GetRenderedDocument();
if (doc) {
PendingAnimationTracker* tracker =
doc->GetOrCreatePendingAnimationTracker();
if (mPendingState == PendingState::PlayPending) {
tracker->AddPlayPending(*this);
} else {
tracker->AddPausePending(*this);
}
}
}
bool
Animation::IsPossiblyOrphanedPendingAnimation() const
{

View File

@ -380,6 +380,21 @@ public:
void NotifyEffectTimingUpdated();
void NotifyGeometricAnimationsStartingThisFrame();
/**
* Reschedule pending pause or pending play tasks when updating the target
* effect.
*
* If we are pending, we will either be registered in the pending animation
* tracker and have a null pending ready time, or, after our effect has been
* painted, we will be removed from the tracker and assigned a pending ready
* time.
*
* When the target effect is updated, we'll typically need to repaint so for
* the latter case where we already have a pending ready time, clear it and put
* ourselves back in the pending animation tracker.
*/
void ReschedulePendingTasks();
/**
* Used by subclasses to synchronously queue a cancel event in situations
* where the Animation may have been cancelled.