Bug 1123523 - Part 3: Store a flag on AnimationPlayer for whether it is exposed by Element.getAnimationPlayers(). r=birtles

This commit is contained in:
Cameron McCormack 2015-03-14 16:34:40 +11:00
parent b4ce1a289c
commit 7edb0d374f
4 changed files with 23 additions and 2 deletions

View File

@ -231,6 +231,7 @@ AnimationPlayer::SetSource(Animation* aSource)
if (mSource) {
mSource->SetParentTime(GetCurrentTime());
}
UpdateRelevance();
}
void
@ -316,6 +317,8 @@ AnimationPlayer::Cancel()
mHoldTime.SetNull();
mStartTime.SetNull();
UpdateSourceContent();
}
bool
@ -329,6 +332,12 @@ AnimationPlayer::IsRunning() const
return computedTiming.mPhase == ComputedTiming::AnimationPhase_Active;
}
void
AnimationPlayer::UpdateRelevance()
{
mIsRelevant = HasCurrentSource() || HasInEffectSource();
}
bool
AnimationPlayer::CanThrottle() const
{
@ -459,6 +468,7 @@ AnimationPlayer::UpdateSourceContent()
{
if (mSource) {
mSource->SetParentTime(GetCurrentTime());
UpdateRelevance();
}
}

View File

@ -56,6 +56,7 @@ public:
, mIsPending(false)
, mIsRunningOnCompositor(false)
, mIsPreviousStateFinished(false)
, mIsRelevant(false)
{
}
@ -191,6 +192,9 @@ public:
return GetSource() && GetSource()->IsInEffect();
}
bool IsRelevant() const { return mIsRelevant; }
void UpdateRelevance();
void SetIsRunningOnCompositor() { mIsRunningOnCompositor = true; }
void ClearIsRunningOnCompositor() { mIsRunningOnCompositor = false; }
@ -256,6 +260,9 @@ protected:
// probably remove this and check if the promise has been settled yet
// or not instead.
bool mIsPreviousStateFinished; // Spec calls this "previous finished state"
// Indicates that the player should be exposed in an element's
// getAnimationPlayers() list.
bool mIsRelevant;
};
} // namespace dom

View File

@ -3188,7 +3188,7 @@ Element::GetAnimationPlayers(nsTArray<nsRefPtr<AnimationPlayer> >& aPlayers)
playerIdx < collection->mPlayers.Length();
playerIdx++) {
AnimationPlayer* player = collection->mPlayers[playerIdx];
if (player->HasCurrentSource() || player->HasInEffectSource()) {
if (player->IsRelevant()) {
aPlayers.AppendElement(player);
}
}

View File

@ -350,6 +350,10 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
newPlayer = nullptr;
newPlayers.ReplaceElementAt(newIdx, oldPlayer);
collection->mPlayers.RemoveElementAt(oldIdx);
// We've touched the old animation's timing properties, so this
// could update the old player's relevance.
oldPlayer->UpdateRelevance();
}
}
} else {