Bug 1109390 part 17 - Add Animation::IsInPlay(); r=jwatt
authorBrian Birtles <birtles@gmail.com>
Fri, 27 Mar 2015 17:54:39 +0900
changeset 266741 ccc27d049cd1d911a258bc0ce99205a990f568e0
parent 266740 d1a7fa0fe2f8f14e4f48b44d36f2d51ce1b9aa96
child 266742 d4306ea579d9a4a5bb3131782fbaed61d1556da9
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs1109390
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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.
dom/animation/Animation.cpp
dom/animation/Animation.h
dom/animation/AnimationPlayer.h
--- a/dom/animation/Animation.cpp
+++ b/dom/animation/Animation.cpp
@@ -224,16 +224,28 @@ Animation::ActiveDuration(const Animatio
     return aTiming.mIterationDuration == zeroDuration
            ? zeroDuration
            : StickyTimeDuration::Forever();
   }
   return StickyTimeDuration(
     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
 {
   if (IsFinishedTransition() ||
       aPlayer.PlayState() == AnimationPlayState::Finished) {
     return false;
   }
--- a/dom/animation/Animation.h
+++ b/dom/animation/Animation.h
@@ -297,16 +297,17 @@ public:
   }
 
   void SetIsFinishedTransition() {
     MOZ_ASSERT(AsTransition(),
                "Calling SetIsFinishedTransition but it's not a transition");
     mIsFinishedTransition = true;
   }
 
+  bool IsInPlay(const AnimationPlayer& aPlayer) const;
   bool IsCurrent(const AnimationPlayer& aPlayer) const;
   bool IsInEffect() const;
 
   const AnimationProperty*
   GetAnimationOfProperty(nsCSSProperty aProperty) const;
   bool HasAnimationOfProperty(nsCSSProperty aProperty) const {
     return GetAnimationOfProperty(aProperty) != nullptr;
   }
--- a/dom/animation/AnimationPlayer.h
+++ b/dom/animation/AnimationPlayer.h
@@ -198,16 +198,20 @@ public:
 
   bool IsPausedOrPausing() const
   {
     return PlayState() == AnimationPlayState::Paused ||
            mPendingState == PendingState::PausePending;
   }
   bool IsRunning() const;
 
+  bool HasInPlaySource() const
+  {
+    return GetSource() && GetSource()->IsInPlay(*this);
+  }
   bool HasCurrentSource() const
   {
     return GetSource() && GetSource()->IsCurrent(*this);
   }
   bool HasInEffectSource() const
   {
     return GetSource() && GetSource()->IsInEffect();
   }