Bug 927349 part 3 - Cancel a pending play when pause is called; r=jwatt
authorBrian Birtles <birtles@gmail.com>
Thu, 18 Dec 2014 08:42:41 +0900
changeset 220285 df1375d0e714721f061fdc425992d2d662bd86dd
parent 220284 95eeca2c7e32eb2b3354afb66af27d5f8034e345
child 220286 7441537d3f5ba558acddc11b4e0c166e2de58624
push id27983
push usercbook@mozilla.com
push dateThu, 18 Dec 2014 12:51:14 +0000
treeherdermozilla-central@9bb8b0b4daae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs927349, 1109390
milestone37.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 927349 part 3 - Cancel a pending play when pause is called; r=jwatt This patch updates the pause procedure for AnimationPlayer so that if there is a pending play it will be cancelled. At the same it removes the existing check for a redundant call to Pause when we are already paused. This check is not necessary since if we are already paused the method will have no effect anyway. Finally, this patch updates the comment about going to the pending state while pausing since this will happen in bug 1109390.
dom/animation/AnimationPlayer.cpp
--- a/dom/animation/AnimationPlayer.cpp
+++ b/dom/animation/AnimationPlayer.cpp
@@ -240,25 +240,43 @@ AnimationPlayer::DoPlay()
   }
 
   ResolveStartTime();
 }
 
 void
 AnimationPlayer::DoPause()
 {
-  if (IsPaused()) {
-    return;
+  // Cancel a pending play
+  if (mIsPending) {
+    nsIDocument* doc = GetRenderedDocument();
+    if (doc) {
+      PendingPlayerTracker* tracker = doc->GetPendingPlayerTracker();
+      if (tracker) {
+        tracker->RemovePlayPending(*this);
+      }
+    }
+
+    mIsPending = false;
+
+    // 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);
+    }
   }
+
   // Mark this as no longer running on the compositor so that next time
   // we update animations we won't throttle them and will have a chance
   // to remove the animation from any layer it might be on.
   mIsRunningOnCompositor = false;
 
-  // Bug 927349 - check for null result here and go to pending state
+  // Bug 1109390 - check for null result here and go to pending state
   mHoldTime = GetCurrentTime();
   mStartTime.SetNull();
 }
 
 void
 AnimationPlayer::FlushStyle() const
 {
   nsIDocument* doc = GetRenderedDocument();