Bug 1046055 part 3 - Add AnimationPlayerCollection::HasCurrentAnimationsForProperty; r=dbaron

This patch adds another method to AnimationPlayerCollection alongside
HasCurrentAnimations that returns true if there is a player in the collection
with current source content that targets the specified property.

At the same time it also makes the original HasCurrentAnimations a const method.
This commit is contained in:
Brian Birtles 2014-10-02 15:14:13 +09:00
parent 2349318ce3
commit 6f723f8f19
2 changed files with 20 additions and 4 deletions

View File

@ -719,7 +719,7 @@ AnimationPlayerCollection::UpdateAnimationGeneration(
}
bool
AnimationPlayerCollection::HasCurrentAnimations()
AnimationPlayerCollection::HasCurrentAnimations() const
{
for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
if (mPlayers[playerIdx]->HasCurrentSource()) {
@ -730,4 +730,18 @@ AnimationPlayerCollection::HasCurrentAnimations()
return false;
}
bool
AnimationPlayerCollection::HasCurrentAnimationsForProperty(nsCSSProperty
aProperty) const
{
for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
const Animation* anim = mPlayers[playerIdx]->GetSource();
if (anim && anim->IsCurrent() && anim->HasAnimationOfProperty(aProperty)) {
return true;
}
}
return false;
}
}

View File

@ -304,9 +304,11 @@ struct AnimationPlayerCollection : public PRCList
// Update mAnimationGeneration to nsCSSFrameConstructor's count
void UpdateAnimationGeneration(nsPresContext* aPresContext);
// Returns true if there is an animation in the before or active phase
// at the current time.
bool HasCurrentAnimations();
// Returns true if there is an animation that has yet to finish.
bool HasCurrentAnimations() const;
// Returns true if there is an animation of the specified property that
// has yet to finish.
bool HasCurrentAnimationsForProperty(nsCSSProperty aProperty) const;
// The refresh time associated with mStyleRule.
TimeStamp mStyleRuleRefreshTime;