Bug 1109390 part 13 - Cancel pending pauses as well as pending plays; r=jwatt
authorBrian Birtles <birtles@gmail.com>
Fri, 27 Mar 2015 15:56:45 +0900
changeset 266399 7d8a20857b50140f0b10f13f4f44b51ad19b57be
parent 266398 bd35c507997e26e65ebb9cffd656fc8ec3c72224
child 266400 a9ae40ed6d0c1083ce6b39bba1747599a2941bef
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 13 - Cancel pending pauses as well as pending plays; r=jwatt This patch simply updates the method that cancels pending plays to also cancel pending pauses. As it stands, for some of places where this is called it might not be appropriate to cancel pending pauses but we will adjust each of these call sites one-by-one in subsequent patches in this series.
dom/animation/AnimationPlayer.cpp
dom/animation/AnimationPlayer.h
--- a/dom/animation/AnimationPlayer.cpp
+++ b/dom/animation/AnimationPlayer.cpp
@@ -56,17 +56,17 @@ AnimationPlayer::SetStartTime(const Null
   if (!aNewStartTime.IsNull()) {
     if (mPlaybackRate != 0.0) {
       mHoldTime.SetNull();
     }
   } else {
     mHoldTime = previousCurrentTime;
   }
 
-  CancelPendingPlay();
+  CancelPendingTasks();
   if (mReady) {
     // We may have already resolved mReady, but in that case calling
     // MaybeResolve is a no-op, so that's okay.
     mReady->MaybeResolve(this);
   }
 
   UpdateSourceContent();
   PostUpdate();
@@ -329,17 +329,17 @@ AnimationPlayer::GetCurrentOrPendingStar
   result.SetValue(mPendingReadyTime.Value() - mHoldTime.Value());
   return result;
 }
 
 void
 AnimationPlayer::Cancel()
 {
   if (mPendingState != PendingState::NotPending) {
-    CancelPendingPlay();
+    CancelPendingTasks();
     if (mReady) {
       mReady->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
     }
   }
 
   mHoldTime.SetNull();
   mStartTime.SetNull();
 
@@ -461,17 +461,17 @@ AnimationPlayer::DoPlay()
   // so notify source content.
   UpdateSourceContent();
 }
 
 void
 AnimationPlayer::DoPause()
 {
   if (mPendingState == PendingState::PlayPending) {
-    CancelPendingPlay();
+    CancelPendingTasks();
     // Resolve the ready promise since we currently only use it for
     // players that are waiting to play. Later (in bug 1109390), we will
     // use this for players waiting to pause as well and then we won't
     // want to resolve it just yet.
     if (mReady) {
       mReady->MaybeResolve(this);
     }
   }
@@ -536,27 +536,31 @@ AnimationPlayer::PostUpdate()
 {
   AnimationPlayerCollection* collection = GetCollection();
   if (collection) {
     collection->NotifyPlayerUpdated();
   }
 }
 
 void
-AnimationPlayer::CancelPendingPlay()
+AnimationPlayer::CancelPendingTasks()
 {
   if (mPendingState == PendingState::NotPending) {
     return;
   }
 
   nsIDocument* doc = GetRenderedDocument();
   if (doc) {
     PendingPlayerTracker* tracker = doc->GetPendingPlayerTracker();
     if (tracker) {
-      tracker->RemovePlayPending(*this);
+      if (mPendingState == PendingState::PlayPending) {
+        tracker->RemovePlayPending(*this);
+      } else {
+        tracker->RemovePausePending(*this);
+      }
     }
   }
 
   mPendingState = PendingState::NotPending;
   mPendingReadyTime.SetNull();
 }
 
 bool
--- a/dom/animation/AnimationPlayer.h
+++ b/dom/animation/AnimationPlayer.h
@@ -237,20 +237,22 @@ public:
 protected:
   void DoPlay();
   void DoPause();
   void ResumeAt(const TimeDuration& aResumeTime);
 
   void UpdateSourceContent();
   void FlushStyle() const;
   void PostUpdate();
-  // Remove this player from the pending player tracker and reset
-  // mPendingState as necessary. The caller is responsible for resolving or
-  // aborting the mReady promise as necessary.
-  void CancelPendingPlay();
+  /**
+   * Remove this player from the pending player tracker and reset
+   * mPendingState as necessary. The caller is responsible for resolving or
+   * aborting the mReady promise as necessary.
+   */
+  void CancelPendingTasks();
 
   bool IsPossiblyOrphanedPendingPlayer() const;
   StickyTimeDuration SourceContentEnd() const;
 
   nsIDocument* GetRenderedDocument() const;
   nsPresContext* GetPresContext() const;
   virtual css::CommonAnimationManager* GetAnimationManager() const = 0;
   AnimationPlayerCollection* GetCollection() const;