Bug 1109390 part 12 - Update IsPaused to handle pause-pending players as well; r=jwatt
authorBrian Birtles <birtles@gmail.com>
Fri, 27 Mar 2015 15:56:45 +0900
changeset 266398 bd35c507997e26e65ebb9cffd656fc8ec3c72224
parent 266397 7d0f03b20dbe4a34b5e0b50bc6114478459c3473
child 266399 7d8a20857b50140f0b10f13f4f44b51ad19b57be
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 12 - Update IsPaused to handle pause-pending players as well; r=jwatt IsPaused is used in nsAnimationManager to detect if a newly created animation should be paused. It is also used inside AnimationPlayer::IsRunning which is used to determine what animations to send to the compositor (we don't send paused animations to the compositor). In all these cases we want to treat paused animations and pause-pending animations alike. This patch updates IsPaused to include also pause-pending animations. At the same time it renames IsPaused to IsPausedOrPausing to reflect the change in behavior. This patch also adjusts a few nearby one-line functions to put the opening brace on a new line since apparently this is what the coding style says to do.
dom/animation/AnimationPlayer.cpp
dom/animation/AnimationPlayer.h
layout/style/nsAnimationManager.cpp
--- a/dom/animation/AnimationPlayer.cpp
+++ b/dom/animation/AnimationPlayer.cpp
@@ -344,17 +344,19 @@ AnimationPlayer::Cancel()
   mStartTime.SetNull();
 
   UpdateSourceContent();
 }
 
 bool
 AnimationPlayer::IsRunning() const
 {
-  if (IsPaused() || !GetSource() || GetSource()->IsFinishedTransition()) {
+  if (IsPausedOrPausing() ||
+      !GetSource() ||
+      GetSource()->IsFinishedTransition()) {
     return false;
   }
 
   ComputedTiming computedTiming = GetSource()->GetComputedTiming();
   return computedTiming.mPhase == ComputedTiming::AnimationPhase_Active;
 }
 
 void
--- a/dom/animation/AnimationPlayer.h
+++ b/dom/animation/AnimationPlayer.h
@@ -186,27 +186,34 @@ public:
    * This method returns the start time, if resolved. Otherwise, if we have
    * a pending ready time, it returns the corresponding start time. If neither
    * of those are available, it returns null.
    */
   Nullable<TimeDuration> GetCurrentOrPendingStartTime() const;
 
   void Cancel();
 
-  const nsString& Name() const {
+  const nsString& Name() const
+  {
     return mSource ? mSource->Name() : EmptyString();
   }
 
-  bool IsPaused() const { return PlayState() == AnimationPlayState::Paused; }
+  bool IsPausedOrPausing() const
+  {
+    return PlayState() == AnimationPlayState::Paused ||
+           mPendingState == PendingState::PausePending;
+  }
   bool IsRunning() const;
 
-  bool HasCurrentSource() const {
+  bool HasCurrentSource() const
+  {
     return GetSource() && GetSource()->IsCurrent();
   }
-  bool HasInEffectSource() const {
+  bool HasInEffectSource() const
+  {
     return GetSource() && GetSource()->IsInEffect();
   }
 
   bool IsRelevant() const { return mIsRelevant; }
   void UpdateRelevance();
 
   void SetIsRunningOnCompositor() { mIsRunningOnCompositor = true; }
   void ClearIsRunningOnCompositor() { mIsRunningOnCompositor = false; }
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -343,21 +343,22 @@ nsAnimationManager::CheckAnimationRule(n
 
         // Handle changes in play state.
         // CSSAnimationPlayer takes care of override behavior so that,
         // for example, if the author has called pause(), that will
         // override the animation-play-state.
         // (We should check newPlayer->IsStylePaused() but that requires
         //  downcasting to CSSAnimationPlayer and we happen to know that
         //  newPlayer will only ever be paused by calling PauseFromStyle
-        //  making IsPaused synonymous in this case.)
-        if (!oldPlayer->IsStylePaused() && newPlayer->IsPaused()) {
+        //  making IsPausedOrPausing synonymous in this case.)
+        if (!oldPlayer->IsStylePaused() && newPlayer->IsPausedOrPausing()) {
           oldPlayer->PauseFromStyle();
           animationChanged = true;
-        } else if (oldPlayer->IsStylePaused() && !newPlayer->IsPaused()) {
+        } else if (oldPlayer->IsStylePaused() &&
+                   !newPlayer->IsPausedOrPausing()) {
           oldPlayer->PlayFromStyle();
           animationChanged = true;
         }
 
         if (animationChanged) {
           nsNodeUtils::AnimationChanged(oldPlayer);
         }