Bug 1109390 part 17 - Add Animation::IsInPlay(); r=jwatt

This patch adds a method for testing if an animation is "in play" which is
a term defined in the Web Animations spec. This is in preparation for removing
some slightly redundant code in IsRunning and aligning better with the spec.
This commit is contained in:
Brian Birtles 2015-03-27 17:54:39 +09:00
parent dea70a395d
commit 0c22048a6a
3 changed files with 17 additions and 0 deletions

View File

@ -229,6 +229,18 @@ Animation::ActiveDuration(const AnimationTiming& aTiming)
aTiming.mIterationDuration.MultDouble(aTiming.mIterationCount));
}
// http://w3c.github.io/web-animations/#in-play
bool
Animation::IsInPlay(const AnimationPlayer& aPlayer) const
{
if (IsFinishedTransition() ||
aPlayer.PlayState() == AnimationPlayState::Finished) {
return false;
}
return GetComputedTiming().mPhase == ComputedTiming::AnimationPhase_Active;
}
// http://w3c.github.io/web-animations/#current
bool
Animation::IsCurrent(const AnimationPlayer& aPlayer) const

View File

@ -302,6 +302,7 @@ public:
mIsFinishedTransition = true;
}
bool IsInPlay(const AnimationPlayer& aPlayer) const;
bool IsCurrent(const AnimationPlayer& aPlayer) const;
bool IsInEffect() const;

View File

@ -203,6 +203,10 @@ public:
}
bool IsRunning() const;
bool HasInPlaySource() const
{
return GetSource() && GetSource()->IsInPlay(*this);
}
bool HasCurrentSource() const
{
return GetSource() && GetSource()->IsCurrent(*this);