Bug 1109390 part 14 - Update AnimationPlayer::DoPlay to re-use the ready promise appropriately; r=jwatt
authorBrian Birtles <birtles@gmail.com>
Fri, 27 Mar 2015 15:56:45 +0900
changeset 266400 a9ae40ed6d0c1083ce6b39bba1747599a2941bef
parent 266399 7d8a20857b50140f0b10f13f4f44b51ad19b57be
child 266401 ecac23a4d71331b943e636d1f668555b83294d22
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 14 - Update AnimationPlayer::DoPlay to re-use the ready promise appropriately; r=jwatt
dom/animation/AnimationPlayer.cpp
--- a/dom/animation/AnimationPlayer.cpp
+++ b/dom/animation/AnimationPlayer.cpp
@@ -420,37 +420,45 @@ AnimationPlayer::ComposeStyle(nsRefPtr<c
 
 void
 AnimationPlayer::DoPlay()
 {
   // FIXME: When we implement finishing behavior (bug 1074630) we will
   // need to pass a flag so that when we start playing due to a change in
   // animation-play-state we *don't* trigger finishing behavior.
 
+  bool reuseReadyPromise = false;
+  if (mPendingState != PendingState::NotPending) {
+    CancelPendingTasks();
+    reuseReadyPromise = true;
+  }
+
   Nullable<TimeDuration> currentTime = GetCurrentTime();
   if (mPlaybackRate > 0.0 &&
       (currentTime.IsNull())) {
     mHoldTime.SetValue(TimeDuration(0));
   } else if (mPlaybackRate < 0.0 &&
              (currentTime.IsNull())) {
     mHoldTime.SetValue(TimeDuration(SourceContentEnd()));
   } else if (mPlaybackRate == 0.0 && currentTime.IsNull()) {
     mHoldTime.SetValue(TimeDuration(0));
   }
 
   if (mHoldTime.IsNull()) {
     return;
   }
 
-  // Clear ready promise. We'll create a new one lazily.
-  mReady = nullptr;
-
   // Clear the start time until we resolve a new one
   mStartTime.SetNull();
 
+  if (!reuseReadyPromise) {
+    // Clear ready promise. We'll create a new one lazily.
+    mReady = nullptr;
+  }
+
   mPendingState = PendingState::PlayPending;
 
   nsIDocument* doc = GetRenderedDocument();
   if (!doc) {
     TriggerOnNextTick(Nullable<TimeDuration>());
     return;
   }