Bug 927349 part 2 - Add AnimationPlayer::mIsPending and return "pending" from AnimationPlayer::PlayState(); r=jwatt
authorBrian Birtles <birtles@gmail.com>
Thu, 18 Dec 2014 08:42:41 +0900
changeset 220284 95eeca2c7e32eb2b3354afb66af27d5f8034e345
parent 220283 323f4574fd3146f08af271015bc85b3fe8b3cd39
child 220285 df1375d0e714721f061fdc425992d2d662bd86dd
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
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 2 - Add AnimationPlayer::mIsPending and return "pending" from AnimationPlayer::PlayState(); r=jwatt This patch adds a member for tracking if a player is currently pending or not and uses this to return the "pending" state from PlayState(). We don't currently set mIsPending to true yet, however. Additionally, this patch updates AnimationPlayer::ComposeStyle to set aNeedsRefreshes to true when the player is pending. This is used by the appropriate animation/transition manager to determine if it should continue to observe the refresh driver or not.
dom/animation/AnimationPlayer.cpp
dom/animation/AnimationPlayer.h
--- a/dom/animation/AnimationPlayer.cpp
+++ b/dom/animation/AnimationPlayer.cpp
@@ -6,16 +6,17 @@
 #include "AnimationPlayer.h"
 #include "AnimationUtils.h"
 #include "mozilla/dom/AnimationPlayerBinding.h"
 #include "AnimationCommon.h" // For AnimationPlayerCollection,
                              // CommonAnimationManager
 #include "nsIDocument.h" // For nsIDocument
 #include "nsIPresShell.h" // For nsIPresShell
 #include "nsLayoutUtils.h" // For PostRestyleEvent (remove after bug 1073336)
+#include "PendingPlayerTracker.h" // For PendingPlayerTracker
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(AnimationPlayer, mTimeline,
                                       mSource, mReady)
 NS_IMPL_CYCLE_COLLECTING_ADDREF(AnimationPlayer)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(AnimationPlayer)
@@ -46,16 +47,20 @@ AnimationPlayer::GetCurrentTime() const
     }
   }
   return result;
 }
 
 AnimationPlayState
 AnimationPlayer::PlayState() const
 {
+  if (mIsPending) {
+    return AnimationPlayState::Pending;
+  }
+
   Nullable<TimeDuration> currentTime = GetCurrentTime();
   if (currentTime.IsNull()) {
     return AnimationPlayState::Idle;
   }
 
   if (mStartTime.IsNull()) {
     return AnimationPlayState::Paused;
   }
@@ -197,17 +202,18 @@ AnimationPlayer::ComposeStyle(nsRefPtr<c
                               nsCSSPropertySet& aSetProperties,
                               bool& aNeedsRefreshes)
 {
   if (!mSource || mSource->IsFinishedTransition()) {
     return;
   }
 
   AnimationPlayState playState = PlayState();
-  if (playState == AnimationPlayState::Running) {
+  if (playState == AnimationPlayState::Running ||
+      playState == AnimationPlayState::Pending) {
     aNeedsRefreshes = true;
   }
 
   mSource->ComposeStyle(aStyleRule, aSetProperties);
 
   mIsPreviousStateFinished = (playState == AnimationPlayState::Finished);
 }
 
--- a/dom/animation/AnimationPlayer.h
+++ b/dom/animation/AnimationPlayer.h
@@ -42,16 +42,17 @@ class AnimationPlayer : public nsISuppor
                         public nsWrapperCache
 {
 protected:
   virtual ~AnimationPlayer() { }
 
 public:
   explicit AnimationPlayer(AnimationTimeline* aTimeline)
     : mTimeline(aTimeline)
+    , mIsPending(false)
     , mIsRunningOnCompositor(false)
     , mIsPreviousStateFinished(false)
   {
   }
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(AnimationPlayer)
 
@@ -144,16 +145,22 @@ protected:
   Nullable<TimeDuration> mStartTime; // Timeline timescale
   Nullable<TimeDuration> mHoldTime;  // Player timescale
 
   // A Promise that is replaced with a new object on each call to Play()
   // (and in future Pause()) and fulfilled when Play() is successfully
   // completed. The initial object is created lazily by GetReady().
   nsRefPtr<Promise> mReady;
 
+  // Indicates if the player is in the pending state. We use this rather
+  // than checking if this player is tracked by a PendingPlayerTracker.
+  // This is because the PendingPlayerTracker is associated with the source
+  // content's document but we need to know if we're pending even if the
+  // source content loses association with its document.
+  bool mIsPending;
   bool mIsRunningOnCompositor;
   // Indicates whether we were in the finished state during our
   // most recent unthrottled sample (our last ComposeStyle call).
   // FIXME: When we implement the finished promise (bug 1074630) we can
   // probably remove this and check if the promise has been settled yet
   // or not instead.
   bool mIsPreviousStateFinished; // Spec calls this "previous finished state"
 };