From ea73c31149478deba6e5513848cb624911402f51 Mon Sep 17 00:00:00 2001 From: Brian Birtles Date: Fri, 27 Mar 2015 15:56:45 +0900 Subject: [PATCH] Bug 1109390 part 8 - Rename Start* methods in AnimationPlayer to Trigger*; r=jwatt --- dom/animation/AnimationPlayer.cpp | 11 +++++------ dom/animation/AnimationPlayer.h | 27 +++++++++++++++++--------- dom/animation/PendingPlayerTracker.cpp | 16 +++++++-------- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/dom/animation/AnimationPlayer.cpp b/dom/animation/AnimationPlayer.cpp index 9fc5cbfc35e..647a413df9d 100644 --- a/dom/animation/AnimationPlayer.cpp +++ b/dom/animation/AnimationPlayer.cpp @@ -284,12 +284,11 @@ AnimationPlayer::Tick() } void -AnimationPlayer::StartOnNextTick(const Nullable& aReadyTime) +AnimationPlayer::TriggerOnNextTick(const Nullable& aReadyTime) { // Normally we expect the play state to be pending but it's possible that, - // due to the handling of possibly orphaned players in Tick() [coming - // in a later patch in this series], this player got started whilst still - // being in another document's pending player map. + // due to the handling of possibly orphaned players in Tick(), this player got + // started whilst still being in another document's pending player map. if (PlayState() != AnimationPlayState::Pending) { return; } @@ -300,7 +299,7 @@ AnimationPlayer::StartOnNextTick(const Nullable& aReadyTime) } void -AnimationPlayer::StartNow() +AnimationPlayer::TriggerNow() { MOZ_ASSERT(PlayState() == AnimationPlayState::Pending, "Expected to start a pending player"); @@ -449,7 +448,7 @@ AnimationPlayer::DoPlay() nsIDocument* doc = GetRenderedDocument(); if (!doc) { - StartOnNextTick(Nullable()); + TriggerOnNextTick(Nullable()); return; } diff --git a/dom/animation/AnimationPlayer.h b/dom/animation/AnimationPlayer.h index f284bcc958c..8a065e89c6f 100644 --- a/dom/animation/AnimationPlayer.h +++ b/dom/animation/AnimationPlayer.h @@ -107,6 +107,8 @@ public: void Tick(); /** + * Set the time to use for starting or pausing a pending player. + * * Typically, when a player is played, it does not start immediately but is * added to a table of pending players on the document of its source content. * In the meantime it sets its hold time to the time from which playback @@ -119,9 +121,9 @@ public: * players do start, they can be timed from the point when painting * completed. * - * After calling StartOnNextTick, players remain in the pending state until + * After calling TriggerOnNextTick, players remain in the pending state until * the next refresh driver tick. At that time they transition out of the - * pending state using the time passed to StartOnNextTick as the effective + * pending state using the time passed to TriggerOnNextTick as the effective * time at which they resumed. * * This approach means that any setup time required for performing the @@ -145,20 +147,27 @@ public: * between triggering an animation and its effective start is unacceptably * long. * + * For pausing, we apply the same asynchronous approach. This is so that we + * synchronize with animations that are running on the compositor. Otherwise + * if the main thread lags behind the compositor there will be a noticeable + * jump backwards when the main thread takes over. Even though main thread + * animations could be paused immediately, we do it asynchronously for + * consistency and so that animations paused together end up in step. + * * Note that the caller of this method is responsible for removing the player * from any PendingPlayerTracker it may have been added to. */ - void StartOnNextTick(const Nullable& aReadyTime); + void TriggerOnNextTick(const Nullable& aReadyTime); - // Testing only: Start a pending player using the current timeline time. - // This is used to support existing tests that expect animations to begin - // immediately. Ideally we would rewrite the those tests and get rid of this - // method, but there are a lot of them. + // Testing only: Start or pause a pending player using the current timeline + // time. This is used to support existing tests that expect animations to + // begin immediately. Ideally we would rewrite the those tests and get rid of + // this method, but there are a lot of them. // - // As with StartOnNextTick, the caller of this method is responsible for + // As with TriggerOnNextTick, the caller of this method is responsible for // removing the player from any PendingPlayerTracker it may have been added // to. - void StartNow(); + void TriggerNow(); /** * When StartOnNextTick is called, we store the ready time but we don't apply diff --git a/dom/animation/PendingPlayerTracker.cpp b/dom/animation/PendingPlayerTracker.cpp index d35897bd306..1577bd59875 100644 --- a/dom/animation/PendingPlayerTracker.cpp +++ b/dom/animation/PendingPlayerTracker.cpp @@ -48,8 +48,8 @@ PendingPlayerTracker::IsWaiting(const dom::AnimationPlayer& aPlayer, } PLDHashOperator -StartPlayerAtTime(nsRefPtrHashKey* aKey, - void* aReadyTime) +TriggerPlayerAtTime(nsRefPtrHashKey* aKey, + void* aReadyTime) { dom::AnimationPlayer* player = aKey->GetKey(); dom::AnimationTimeline* timeline = player->Timeline(); @@ -57,7 +57,7 @@ StartPlayerAtTime(nsRefPtrHashKey* aKey, // When the timeline's refresh driver is under test control, its values // have no correspondance to wallclock times so we shouldn't try to convert // aReadyTime (which is a wallclock time) to a timeline value. Instead, the - // animation player will be started when the refresh driver is next + // animation player will be started/paused when the refresh driver is next // advanced since this will trigger a call to TriggerPendingPlayersNow. if (timeline->IsUnderTestControl()) { return PL_DHASH_NEXT; @@ -65,7 +65,7 @@ StartPlayerAtTime(nsRefPtrHashKey* aKey, Nullable readyTime = timeline->ToTimelineTime(*static_cast(aReadyTime)); - player->StartOnNextTick(readyTime); + player->TriggerOnNextTick(readyTime); return PL_DHASH_REMOVE; } @@ -74,21 +74,21 @@ void PendingPlayerTracker::TriggerPendingPlayersOnNextTick(const TimeStamp& aReadyTime) { - mPlayPendingSet.EnumerateEntries(StartPlayerAtTime, + mPlayPendingSet.EnumerateEntries(TriggerPlayerAtTime, const_cast(&aReadyTime)); } PLDHashOperator -StartPlayerNow(nsRefPtrHashKey* aKey, void*) +TriggerPlayerNow(nsRefPtrHashKey* aKey, void*) { - aKey->GetKey()->StartNow(); + aKey->GetKey()->TriggerNow(); return PL_DHASH_NEXT; } void PendingPlayerTracker::TriggerPendingPlayersNow() { - mPlayPendingSet.EnumerateEntries(StartPlayerNow, nullptr); + mPlayPendingSet.EnumerateEntries(TriggerPlayerNow, nullptr); mPlayPendingSet.Clear(); }