Bug 1109390 part 16 - Update IsCurrent to take a player parameter; r=jwatt
authorBrian Birtles <birtles@gmail.com>
Fri, 27 Mar 2015 17:44:38 +0900
changeset 266740 d1a7fa0fe2f8f14e4f48b44d36f2d51ce1b9aa96
parent 266739 5fe056ac390795b2c5a19e3fec0773fcf5502099
child 266741 ccc27d049cd1d911a258bc0ce99205a990f568e0
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 16 - Update IsCurrent to take a player parameter; r=jwatt In preparation for introducing IsInPlay (where "in play" is a term in the Web Animations spec), this patch aligns the existing IsCurrent with the definition in the spec that says an animation effect is only current if it is attached to an animation (player in our current naming) that is not finished. In order to ensure that we need to pass the animation/player into the method. This actually changes the behavior of IsCurrent since now we will return false for animations that are finished. As far as I can tell, all the call sites that are requesting current animations should only be concerned with animations that are actually running. If not, they need to be adjusted to look for animations that are either current or in effect.
dom/animation/Animation.cpp
dom/animation/Animation.h
dom/animation/AnimationPlayer.h
layout/style/AnimationCommon.cpp
--- a/dom/animation/Animation.cpp
+++ b/dom/animation/Animation.cpp
@@ -224,20 +224,22 @@ Animation::ActiveDuration(const Animatio
     return aTiming.mIterationDuration == zeroDuration
            ? zeroDuration
            : StickyTimeDuration::Forever();
   }
   return StickyTimeDuration(
     aTiming.mIterationDuration.MultDouble(aTiming.mIterationCount));
 }
 
+// http://w3c.github.io/web-animations/#current
 bool
-Animation::IsCurrent() const
+Animation::IsCurrent(const AnimationPlayer& aPlayer) const
 {
-  if (IsFinishedTransition()) {
+  if (IsFinishedTransition() ||
+      aPlayer.PlayState() == AnimationPlayState::Finished) {
     return false;
   }
 
   ComputedTiming computedTiming = GetComputedTiming();
   return computedTiming.mPhase == ComputedTiming::AnimationPhase_Before ||
          computedTiming.mPhase == ComputedTiming::AnimationPhase_Active;
 }
 
--- a/dom/animation/Animation.h
+++ b/dom/animation/Animation.h
@@ -297,17 +297,17 @@ public:
   }
 
   void SetIsFinishedTransition() {
     MOZ_ASSERT(AsTransition(),
                "Calling SetIsFinishedTransition but it's not a transition");
     mIsFinishedTransition = true;
   }
 
-  bool IsCurrent() 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;
   }
   const InfallibleTArray<AnimationProperty>& Properties() const {
--- a/dom/animation/AnimationPlayer.h
+++ b/dom/animation/AnimationPlayer.h
@@ -200,17 +200,17 @@ public:
   {
     return PlayState() == AnimationPlayState::Paused ||
            mPendingState == PendingState::PausePending;
   }
   bool IsRunning() const;
 
   bool HasCurrentSource() const
   {
-    return GetSource() && GetSource()->IsCurrent();
+    return GetSource() && GetSource()->IsCurrent(*this);
   }
   bool HasInEffectSource() const
   {
     return GetSource() && GetSource()->IsInEffect();
   }
 
   bool IsRelevant() const { return mIsRelevant; }
   void UpdateRelevance();
--- a/layout/style/AnimationCommon.cpp
+++ b/layout/style/AnimationCommon.cpp
@@ -849,18 +849,21 @@ AnimationPlayerCollection::HasCurrentAni
   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)) {
+    const AnimationPlayer& player = *mPlayers[playerIdx];
+    const Animation* anim = player.GetSource();
+    if (anim &&
+        anim->IsCurrent(player) &&
+        anim->HasAnimationOfProperty(aProperty)) {
       return true;
     }
   }
 
   return false;
 }
 
 }