Bug 1070745 part 3 - Convert AnimationPlayer mPlayState to an mPaused bool; r=birtles
authorDavid Zbarsky <dzbarsky@gmail.com>
Mon, 20 Oct 2014 13:55:43 +0900
changeset 211166 5a78f9e22770e8fc382e9d3d4405bc8ce30c0dcf
parent 211165 00ec97d72ebf458668ffe0a5ffba8073265ee02b
child 211167 e279fb6525b8c404b88edc36c7b50ce6535216f2
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbirtles
bugs1070745
milestone36.0a1
Bug 1070745 part 3 - Convert AnimationPlayer mPlayState to an mPaused bool; r=birtles We only need to store if an animation is paused or not, hence a bool is sufficient. Furthermore, the convenience of using the same type as the specified style of animation-play-state will disappear once pausing behavior is wrapped up behind Play() and Pause() methods.
dom/animation/AnimationPlayer.cpp
dom/animation/AnimationPlayer.h
layout/style/nsAnimationManager.cpp
--- a/dom/animation/AnimationPlayer.cpp
+++ b/dom/animation/AnimationPlayer.cpp
@@ -51,17 +51,17 @@ AnimationPlayer::PlayFromJS()
   // TODO (flush styles etc.)
 
   Play();
 }
 
 void
 AnimationPlayer::PauseFromJS()
 {
-  Play();
+  Pause();
 
   // TODO (flush styles etc.)
 }
 
 void
 AnimationPlayer::SetSource(Animation* aSource)
 {
   if (mSource) {
--- a/dom/animation/AnimationPlayer.h
+++ b/dom/animation/AnimationPlayer.h
@@ -26,17 +26,17 @@ namespace dom {
 
 class AnimationPlayer MOZ_FINAL : public nsWrapperCache
 {
 protected:
   virtual ~AnimationPlayer() { }
 
 public:
   explicit AnimationPlayer(AnimationTimeline* aTimeline)
-    : mPlayState(NS_STYLE_ANIMATION_PLAY_STATE_RUNNING)
+    : mIsPaused(false)
     , mIsRunningOnCompositor(false)
     , mTimeline(aTimeline)
   {
   }
 
   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(AnimationPlayer)
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(AnimationPlayer)
 
@@ -59,19 +59,17 @@ public:
 
   void SetSource(Animation* aSource);
   void Tick();
 
   const nsString& Name() const {
     return mSource ? mSource->Name() : EmptyString();
   }
 
-  bool IsPaused() const {
-    return mPlayState == NS_STYLE_ANIMATION_PLAY_STATE_PAUSED;
-  }
+  bool IsPaused() const { return mIsPaused; }
 
   bool IsRunning() const;
 
   bool HasCurrentSource() const {
     return GetSource() && GetSource()->IsCurrent();
   }
   bool HasInEffectSource() const {
     return GetSource() && GetSource()->IsInEffect();
@@ -79,17 +77,17 @@ public:
 
   // Return the duration since the start time of the player, taking into
   // account the pause state.  May be negative or null.
   Nullable<TimeDuration> GetCurrentTimeDuration() const;
 
   // The beginning of the delay period.
   Nullable<TimeDuration> mStartTime;
   Nullable<TimeDuration> mHoldTime;
-  uint8_t mPlayState;
+  bool mIsPaused;
   bool mIsRunningOnCompositor;
 
   nsRefPtr<AnimationTimeline> mTimeline;
   nsRefPtr<Animation> mSource;
 };
 
 } // namespace dom
 } // namespace mozilla
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -319,17 +319,17 @@ nsAnimationManager::CheckAnimationRule(n
             if (now.IsNull()) {
               oldPlayer->mStartTime.SetNull();
             } else {
               oldPlayer->mStartTime.SetValue(now.Value() -
                                                oldPlayer->mHoldTime.Value());
             }
             oldPlayer->mHoldTime.SetNull();
           }
-          oldPlayer->mPlayState = newPlayer->mPlayState;
+          oldPlayer->mIsPaused = newPlayer->mIsPaused;
 
           // Replace new animation with the (updated) old one and remove the
           // old one from the array so we don't try to match it any more.
           //
           // Although we're doing this while iterating this is safe because
           // we're not changing the length of newPlayers and we've finished
           // iterating over the list of old iterations.
           newPlayer = nullptr;
@@ -454,17 +454,18 @@ nsAnimationManager::BuildAnimations(nsSt
     timing.mFillMode = src.GetFillMode();
 
     nsRefPtr<Animation> destAnim =
       new Animation(mPresContext->Document(), aTarget,
                     aStyleContext->GetPseudoType(), timing, src.GetName());
     dest->SetSource(destAnim);
 
     dest->mStartTime = now;
-    dest->mPlayState = src.GetPlayState();
+    dest->mIsPaused =
+      src.GetPlayState() == NS_STYLE_ANIMATION_PLAY_STATE_PAUSED;
     if (dest->IsPaused()) {
       dest->mHoldTime.SetValue(TimeDuration(0));
     }
 
     // While current drafts of css3-animations say that later keyframes
     // with the same key entirely replace earlier ones (no cascading),
     // this is a bad idea and contradictory to the rest of CSS.  So
     // we're going to keep all the keyframes for each key and then do