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.
This commit is contained in:
David Zbarsky 2014-10-20 13:55:43 +09:00
parent 62a1aab1e3
commit 6a83000768
3 changed files with 7 additions and 8 deletions

View File

@ -56,7 +56,7 @@ AnimationPlayer::PlayFromJS()
void
AnimationPlayer::PauseFromJS()
{
Play();
Pause();
// TODO (flush styles etc.)
}

View File

@ -31,7 +31,7 @@ protected:
public:
explicit AnimationPlayer(AnimationTimeline* aTimeline)
: mPlayState(NS_STYLE_ANIMATION_PLAY_STATE_RUNNING)
: mIsPaused(false)
, mIsRunningOnCompositor(false)
, mTimeline(aTimeline)
{
@ -64,9 +64,7 @@ public:
return mSource ? mSource->Name() : EmptyString();
}
bool IsPaused() const {
return mPlayState == NS_STYLE_ANIMATION_PLAY_STATE_PAUSED;
}
bool IsPaused() const { return mIsPaused; }
bool IsRunning() const;
@ -84,7 +82,7 @@ public:
// The beginning of the delay period.
Nullable<TimeDuration> mStartTime;
Nullable<TimeDuration> mHoldTime;
uint8_t mPlayState;
bool mIsPaused;
bool mIsRunningOnCompositor;
nsRefPtr<AnimationTimeline> mTimeline;

View File

@ -324,7 +324,7 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
}
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.
@ -459,7 +459,8 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
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));
}