diff --git a/dom/animation/Animation.cpp b/dom/animation/Animation.cpp index 352e562a10a..47d8fbcaa8d 100644 --- a/dom/animation/Animation.cpp +++ b/dom/animation/Animation.cpp @@ -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 diff --git a/dom/animation/Animation.h b/dom/animation/Animation.h index cb9c270231c..45a028a5372 100644 --- a/dom/animation/Animation.h +++ b/dom/animation/Animation.h @@ -302,6 +302,7 @@ public: mIsFinishedTransition = true; } + bool IsInPlay(const AnimationPlayer& aPlayer) const; bool IsCurrent(const AnimationPlayer& aPlayer) const; bool IsInEffect() const; diff --git a/dom/animation/AnimationPlayer.h b/dom/animation/AnimationPlayer.h index c4955179fde..4c4e8e2d7a8 100644 --- a/dom/animation/AnimationPlayer.h +++ b/dom/animation/AnimationPlayer.h @@ -203,6 +203,10 @@ public: } bool IsRunning() const; + bool HasInPlaySource() const + { + return GetSource() && GetSource()->IsInPlay(*this); + } bool HasCurrentSource() const { return GetSource() && GetSource()->IsCurrent(*this);