Bug 1074054 part 1 - Add Animation::IsInEffect; r=dbaron
authorBrian Birtles <birtles@gmail.com>
Thu, 02 Oct 2014 15:14:14 +0900
changeset 208351 3a4ecfff302a300e8165265eabca94f95d95dfda
parent 208350 dedaffb8297a9167a9677c531edbac427ded6b53
child 208352 35e518128ca302874769f17abcee7f754dae9d30
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersdbaron
bugs1074054, 1046055
milestone35.0a1
Bug 1074054 part 1 - Add Animation::IsInEffect; r=dbaron This patch adds a utility method to return if an animation is "in effect" or not as defined by Web Animations: http://w3c.github.io/web-animations/#in-effect It also moves the utility method for querying if an animation is "current" (IsCurrent) to the .cpp file since it is fairly long. (Bug 1046055 makes one of the callers of IsCurrent inline-able which should offset any cost introduced by this no longer being inline-able.)
dom/animation/Animation.cpp
dom/animation/Animation.h
--- a/dom/animation/Animation.cpp
+++ b/dom/animation/Animation.cpp
@@ -223,16 +223,39 @@ Animation::ActiveDuration(const Animatio
            ? zeroDuration
            : StickyTimeDuration::Forever();
   }
   return StickyTimeDuration(
     aTiming.mIterationDuration.MultDouble(aTiming.mIterationCount));
 }
 
 bool
+Animation::IsCurrent() const
+{
+  if (IsFinishedTransition()) {
+    return false;
+  }
+
+  ComputedTiming computedTiming = GetComputedTiming();
+  return computedTiming.mPhase == ComputedTiming::AnimationPhase_Before ||
+         computedTiming.mPhase == ComputedTiming::AnimationPhase_Active;
+}
+
+bool
+Animation::IsInEffect() const
+{
+  if (IsFinishedTransition()) {
+    return false;
+  }
+
+  ComputedTiming computedTiming = GetComputedTiming();
+  return computedTiming.mTimeFraction != ComputedTiming::kNullTimeFraction;
+}
+
+bool
 Animation::HasAnimationOfProperty(nsCSSProperty aProperty) const
 {
   for (size_t propIdx = 0, propEnd = mProperties.Length();
        propIdx != propEnd; ++propIdx) {
     if (aProperty == mProperties[propIdx].mProperty) {
       return true;
     }
   }
--- a/dom/animation/Animation.h
+++ b/dom/animation/Animation.h
@@ -219,25 +219,18 @@ public:
   }
 
   void SetIsFinishedTransition() {
     MOZ_ASSERT(AsTransition(),
                "Calling SetIsFinishedTransition but it's not a transition");
     mIsFinishedTransition = true;
   }
 
-  bool IsCurrent() const {
-    if (IsFinishedTransition()) {
-      return false;
-    }
-
-    ComputedTiming computedTiming = GetComputedTiming();
-    return computedTiming.mPhase == ComputedTiming::AnimationPhase_Before ||
-           computedTiming.mPhase == ComputedTiming::AnimationPhase_Active;
-  }
+  bool IsCurrent() const;
+  bool IsInEffect() const;
 
   enum {
     LAST_NOTIFICATION_NONE = uint64_t(-1),
     LAST_NOTIFICATION_END = uint64_t(-2)
   };
   uint64_t LastNotification() const { return mLastNotification; }
   void SetLastNotification(uint64_t aLastNotification) {
     mLastNotification = aLastNotification;