author | Brian Birtles <birtles@gmail.com> |
Fri, 09 Jan 2015 07:57:58 +0900 | |
changeset 222724 | dfba5219541ff18c96f1b43e52f4d54bd4bc707d |
parent 222723 | 15f5148fe5892f1267f298ea6a09d8a6f64dc647 |
child 222725 | 73091940bedfc769250e199d9489e3545ccf235e |
push id | 53710 |
push user | bbirtles@mozilla.com |
push date | Thu, 08 Jan 2015 22:58:29 +0000 |
treeherder | mozilla-inbound@95267af607c3 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jwatt |
bugs | 1112480 |
milestone | 37.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
|
dom/animation/AnimationPlayer.cpp | file | annotate | diff | comparison | revisions | |
dom/animation/AnimationPlayer.h | file | annotate | diff | comparison | revisions |
--- a/dom/animation/AnimationPlayer.cpp +++ b/dom/animation/AnimationPlayer.cpp @@ -138,49 +138,22 @@ AnimationPlayer::Tick() // animation now. UpdateSourceContent(); } void AnimationPlayer::StartNow() { - // This method is only expected to be called for an animation that is - // waiting to play. We can easily adapt it to handle other states - // but it's currently not necessary. MOZ_ASSERT(PlayState() == AnimationPlayState::Pending, "Expected to start a pending player"); - MOZ_ASSERT(!mHoldTime.IsNull(), - "A player in the pending state should have a resolved hold time"); - - Nullable<TimeDuration> readyTime = mTimeline->GetCurrentTime(); + MOZ_ASSERT(mTimeline && !mTimeline->GetCurrentTime().IsNull(), + "Expected an active timeline"); - // FIXME (bug 1096776): If readyTime.IsNull(), we should return early here. - // This will leave mIsPending = true but the caller will remove us from the - // PendingPlayerTracker if we were added there. - // Then, in Tick(), if we have: - // - a resolved timeline, and - // - mIsPending = true, and - // - *no* document or we are *not* in the PendingPlayerTracker - // then we should call StartNow. - // - // For now, however, we don't support inactive/missing timelines so - // |readyTime| should be resolved. - MOZ_ASSERT(!readyTime.IsNull(), "Missing or inactive timeline"); - - mStartTime.SetValue(readyTime.Value() - mHoldTime.Value()); - mHoldTime.SetNull(); - mIsPending = false; - - UpdateSourceContent(); - PostUpdate(); - - if (mReady) { - mReady->MaybeResolve(this); - } + ResumeAt(mTimeline->GetCurrentTime().Value()); } void AnimationPlayer::Cancel() { if (mIsPending) { CancelPendingPlay(); if (mReady) { @@ -309,16 +282,39 @@ AnimationPlayer::DoPause() mIsRunningOnCompositor = false; // Bug 1109390 - check for null result here and go to pending state mHoldTime = GetCurrentTime(); mStartTime.SetNull(); } void +AnimationPlayer::ResumeAt(const TimeDuration& aResumeTime) +{ + // This method is only expected to be called for a player that is + // waiting to play. We can easily adapt it to handle other states + // but it's currently not necessary. + MOZ_ASSERT(PlayState() == AnimationPlayState::Pending, + "Expected to resume a pending player"); + MOZ_ASSERT(!mHoldTime.IsNull(), + "A player in the pending state should have a resolved hold time"); + + mStartTime.SetValue(aResumeTime - mHoldTime.Value()); + mHoldTime.SetNull(); + mIsPending = false; + + UpdateSourceContent(); + PostUpdate(); + + if (mReady) { + mReady->MaybeResolve(this); + } +} + +void AnimationPlayer::UpdateSourceContent() { if (mSource) { mSource->SetParentTime(GetCurrentTime()); } } void
--- a/dom/animation/AnimationPlayer.h +++ b/dom/animation/AnimationPlayer.h @@ -150,16 +150,17 @@ public: // is running and has source content to sample). void ComposeStyle(nsRefPtr<css::AnimValuesStyleRule>& aStyleRule, nsCSSPropertySet& aSetProperties, bool& aNeedsRefreshes); protected: void DoPlay(); void DoPause(); + void ResumeAt(const TimeDuration& aResumeTime); void UpdateSourceContent(); void FlushStyle() const; void PostUpdate(); // Remove this player from the pending player tracker and resets mIsPending // as necessary. The caller is responsible for resolving or aborting the // mReady promise as necessary. void CancelPendingPlay();