Bug 1109390 part 18 - Rename AnimationPlayer::IsRunning to IsPlaying and reuse IsInPlay definition; r=jwatt
authorBrian Birtles <birtles@gmail.com>
Fri, 27 Mar 2015 18:01:00 +0900
changeset 265280 d4306ea579d9a4a5bb3131782fbaed61d1556da9
parent 265279 ccc27d049cd1d911a258bc0ce99205a990f568e0
child 265281 782c5106390699150a110d812eb479ff8ab044bb
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [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 18 - Rename AnimationPlayer::IsRunning to IsPlaying and reuse IsInPlay definition; r=jwatt This patch renames the confusing IsRunning method since IsRunning() is *not* the same as (PlayState() == AnimationPlayState::Running). It also removes the old definition to make better re-use of PlayState() and IsInPlay().
dom/animation/AnimationPlayer.cpp
dom/animation/AnimationPlayer.h
layout/base/nsDisplayList.cpp
layout/style/AnimationCommon.cpp
--- a/dom/animation/AnimationPlayer.cpp
+++ b/dom/animation/AnimationPlayer.cpp
@@ -346,29 +346,16 @@ AnimationPlayer::Cancel()
   }
 
   mHoldTime.SetNull();
   mStartTime.SetNull();
 
   UpdateSourceContent();
 }
 
-bool
-AnimationPlayer::IsRunning() const
-{
-  if (IsPausedOrPausing() ||
-      !GetSource() ||
-      GetSource()->IsFinishedTransition()) {
-    return false;
-  }
-
-  ComputedTiming computedTiming = GetSource()->GetComputedTiming();
-  return computedTiming.mPhase == ComputedTiming::AnimationPhase_Active;
-}
-
 void
 AnimationPlayer::UpdateRelevance()
 {
   bool wasRelevant = mIsRelevant;
   mIsRelevant = HasCurrentSource() || HasInEffectSource();
 
   // Notify animation observers.
   if (wasRelevant && !mIsRelevant) {
--- a/dom/animation/AnimationPlayer.h
+++ b/dom/animation/AnimationPlayer.h
@@ -196,31 +196,44 @@ public:
     return mSource ? mSource->Name() : EmptyString();
   }
 
   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();
   }
 
+  /**
+   * "Playing" is different to "running". An animation in its delay phase is
+   * still running but we only consider it playing when it is in its active
+   * interval. This definition is used for fetching the animations that are
+   * are candidates for running on the compositor (since we don't ship
+   * animations to the compositor when they are in their delay phase or
+   * paused).
+   */
+  bool IsPlaying() const
+  {
+    return HasInPlaySource() && // Check we are in the active interval
+           PlayState() == AnimationPlayState::Running; // And not paused
+  }
+
   bool IsRelevant() const { return mIsRelevant; }
   void UpdateRelevance();
 
   void SetIsRunningOnCompositor() { mIsRunningOnCompositor = true; }
   void ClearIsRunningOnCompositor() { mIsRunningOnCompositor = false; }
 
   // Returns true if this animation does not currently need to update
   // style on the main thread (e.g. because it is empty, or is
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -406,23 +406,21 @@ AddAnimationForProperty(nsIFrame* aFrame
 static void
 AddAnimationsForProperty(nsIFrame* aFrame, nsCSSProperty aProperty,
                          AnimationPlayerPtrArray& aPlayers,
                          Layer* aLayer, AnimationData& aData,
                          bool aPending)
 {
   for (size_t playerIdx = 0; playerIdx < aPlayers.Length(); playerIdx++) {
     AnimationPlayer* player = aPlayers[playerIdx];
-    if (!player->IsRunning()) {
+    if (!player->IsPlaying()) {
       continue;
     }
     dom::Animation* anim = player->GetSource();
-    if (!anim) {
-      continue;
-    }
+    MOZ_ASSERT(anim, "A playing player should have a source animation");
     const AnimationProperty* property =
       anim->GetAnimationOfProperty(aProperty);
     if (!property) {
       continue;
     }
 
     if (!property->mWinsInCascade) {
       // We have an animation or transition, but it isn't actually
--- a/layout/style/AnimationCommon.cpp
+++ b/layout/style/AnimationCommon.cpp
@@ -552,37 +552,42 @@ AnimationPlayerCollection::CanPerformOnC
       message.Append(")");
       LogAsyncAnimationFailure(message, mElement);
     }
     return false;
   }
 
   for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
     const AnimationPlayer* player = mPlayers[playerIdx];
-    if (!player->IsRunning() || !player->GetSource()) {
+    if (!player->IsPlaying()) {
       continue;
     }
+
     const Animation* anim = player->GetSource();
+    MOZ_ASSERT(anim, "A playing player should have a source animation");
+
     for (size_t propIdx = 0, propEnd = anim->Properties().Length();
          propIdx != propEnd; ++propIdx) {
       if (IsGeometricProperty(anim->Properties()[propIdx].mProperty)) {
         aFlags = CanAnimateFlags(aFlags | CanAnimate_HasGeometricProperty);
         break;
       }
     }
   }
 
   bool existsProperty = false;
   for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
     const AnimationPlayer* player = mPlayers[playerIdx];
-    if (!player->IsRunning() || !player->GetSource()) {
+    if (!player->IsPlaying()) {
       continue;
     }
 
     const Animation* anim = player->GetSource();
+    MOZ_ASSERT(anim, "A playing player should have a source animation");
+
     existsProperty = existsProperty || anim->Properties().Length() > 0;
 
     for (size_t propIdx = 0, propEnd = anim->Properties().Length();
          propIdx != propEnd; ++propIdx) {
       const AnimationProperty& prop = anim->Properties()[propIdx];
       if (!CanAnimatePropertyOnCompositor(mElement,
                                           prop.mProperty,
                                           aFlags) ||