Bug 1154615 part 4 - Rename references to players in dom/animation; r=jwatt
authorBrian Birtles <birtles@gmail.com>
Tue, 21 Apr 2015 10:22:09 +0900
changeset 240077 675592491434e6eaff47f551938cff48ebd76443
parent 240076 7d4113af5140aa63060a630f4e3a6f722cd9f575
child 240078 2bb61d7addb344c0ac6eac3a9dad1df564f48c0e
push id28621
push usercbook@mozilla.com
push dateTue, 21 Apr 2015 09:59:54 +0000
treeherdermozilla-central@ef3c6dd09234 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwatt
bugs1154615
milestone40.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 1154615 part 4 - Rename references to players in dom/animation; r=jwatt This patch does not, however, update references to AnimationPlayerCollection/CSSTransitionPlayer etc. which we will fix when we get to layout/style.
dom/animation/Animation.cpp
dom/animation/Animation.h
dom/animation/KeyframeEffect.cpp
dom/animation/KeyframeEffect.h
--- a/dom/animation/Animation.cpp
+++ b/dom/animation/Animation.cpp
@@ -287,45 +287,46 @@ Animation::Tick()
   // resuming.
   if (mPendingState != PendingState::NotPending &&
       !mPendingReadyTime.IsNull() &&
       mPendingReadyTime.Value() <= mTimeline->GetCurrentTime().Value()) {
     FinishPendingAt(mPendingReadyTime.Value());
     mPendingReadyTime.SetNull();
   }
 
-  if (IsPossiblyOrphanedPendingPlayer()) {
+  if (IsPossiblyOrphanedPendingAnimation()) {
     MOZ_ASSERT(mTimeline && !mTimeline->GetCurrentTime().IsNull(),
-               "Orphaned pending players should have an active timeline");
+               "Orphaned pending animtaions should have an active timeline");
     FinishPendingAt(mTimeline->GetCurrentTime().Value());
   }
 
   UpdateTiming();
 }
 
 void
 Animation::TriggerOnNextTick(const Nullable<TimeDuration>& 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(), this player got
-  // started whilst still being in another document's pending player map.
+  // due to the handling of possibly orphaned animations in Tick(), this
+  // animation got started whilst still being in another document's pending
+  // animation map.
   if (PlayState() != AnimationPlayState::Pending) {
     return;
   }
 
   // If aReadyTime.IsNull() we'll detect this in Tick() where we check for
-  // orphaned players and trigger this animation anyway
+  // orphaned animations and trigger this animation anyway
   mPendingReadyTime = aReadyTime;
 }
 
 void
 Animation::TriggerNow()
 {
   MOZ_ASSERT(PlayState() == AnimationPlayState::Pending,
-             "Expected to start a pending player");
+             "Expected to start a pending animation");
   MOZ_ASSERT(mTimeline && !mTimeline->GetCurrentTime().IsNull(),
              "Expected an active timeline");
 
   FinishPendingAt(mTimeline->GetCurrentTime().Value());
 }
 
 Nullable<TimeDuration>
 Animation::GetCurrentOrPendingStartTime() const
@@ -590,23 +591,23 @@ Animation::DoPause()
   tracker->AddPausePending(*this);
 
   UpdateFinishedState();
 }
 
 void
 Animation::ResumeAt(const TimeDuration& aReadyTime)
 {
-  // This method is only expected to be called for a player that is
+  // 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(mPendingState == PendingState::PlayPending,
-             "Expected to resume a play-pending player");
+             "Expected to resume a play-pending animation");
   MOZ_ASSERT(mHoldTime.IsNull() != mStartTime.IsNull(),
-             "A player in the play-pending state should have either a"
+             "An animation in the play-pending state should have either a"
              " resolved hold time or resolved start time (but not both)");
 
   // If we aborted a pending pause operation we will already have a start time
   // we should use. In all other cases, we resolve it from the ready time.
   if (mStartTime.IsNull()) {
     if (mPlaybackRate != 0) {
       mStartTime.SetValue(aReadyTime -
                           (mHoldTime.Value().MultDouble(1 / mPlaybackRate)));
@@ -623,17 +624,17 @@ Animation::ResumeAt(const TimeDuration& 
     mReady->MaybeResolve(this);
   }
 }
 
 void
 Animation::PauseAt(const TimeDuration& aReadyTime)
 {
   MOZ_ASSERT(mPendingState == PendingState::PausePending,
-             "Expected to pause a pause-pending player");
+             "Expected to pause a pause-pending animation");
 
   if (!mStartTime.IsNull()) {
     mHoldTime.SetValue((aReadyTime - mStartTime.Value())
                         .MultDouble(mPlaybackRate));
   }
   mStartTime.SetNull();
   mPendingState = PendingState::NotPending;
 
@@ -766,29 +767,29 @@ Animation::IsFinished() const
   // and we need this much more messy check to see if we're finished.
   Nullable<TimeDuration> currentTime = GetCurrentTime();
   return !currentTime.IsNull() &&
       ((mPlaybackRate > 0.0 && currentTime.Value() >= EffectEnd()) ||
        (mPlaybackRate < 0.0 && currentTime.Value().ToMilliseconds() <= 0.0));
 }
 
 bool
-Animation::IsPossiblyOrphanedPendingPlayer() const
+Animation::IsPossiblyOrphanedPendingAnimation() const
 {
   // Check if we are pending but might never start because we are not being
   // tracked.
   //
   // This covers the following cases:
   //
   // * We started playing but our effect's target element was orphaned
   //   or bound to a different document.
   //   (note that for the case of our effect changing we should handle
   //   that in SetEffect)
   // * We started playing but our timeline became inactive.
-  //   In this case the pending player tracker will drop us from its hashmap
+  //   In this case the pending animation tracker will drop us from its hashmap
   //   when we have been painted.
   // * When we started playing we couldn't find a PendingAnimationTracker to
   //   register with (perhaps the effect had no document) so we simply
   //   set mPendingState in DoPlay and relied on this method to catch us on the
   //   next tick.
 
   // If we're not pending we're ok.
   if (mPendingState == PendingState::NotPending) {
@@ -868,21 +869,22 @@ Animation::GetPresContext() const
 
 AnimationPlayerCollection*
 Animation::GetCollection() const
 {
   css::CommonAnimationManager* manager = GetAnimationManager();
   if (!manager) {
     return nullptr;
   }
-  MOZ_ASSERT(mEffect, "A player with an animation manager must have an effect");
+  MOZ_ASSERT(mEffect,
+             "An animation with an animation manager must have an effect");
 
   Element* targetElement;
   nsCSSPseudoElements::Type targetPseudoType;
   mEffect->GetTarget(targetElement, targetPseudoType);
   MOZ_ASSERT(targetElement,
-             "A player with an animation manager must have a target");
+             "An animation with an animation manager must have a target");
 
   return manager->GetAnimations(targetElement, targetPseudoType, false);
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/animation/Animation.h
+++ b/dom/animation/Animation.h
@@ -113,76 +113,76 @@ public:
   // in future we will likely have to flush style in
   // CSSAnimationPlayer::PauseFromJS so we leave it for now.
   void PauseFromJS() { Pause(); }
 
   void SetEffect(KeyframeEffectReadonly* aEffect);
   void Tick();
 
   /**
-   * Set the time to use for starting or pausing a pending player.
+   * Set the time to use for starting or pausing a pending animation.
    *
-   * 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 effect.
+   * Typically, when an animation is played, it does not start immediately but
+   * is added to a table of pending animations on the document of its effect.
    * In the meantime it sets its hold time to the time from which playback
    * should begin.
    *
-   * When the document finishes painting, any pending players in its table
+   * When the document finishes painting, any pending animations in its table
    * are marked as being ready to start by calling StartOnNextTick.
    * The moment when the paint completed is also recorded, converted to a
    * timeline time, and passed to StartOnTick. This is so that when these
-   * players do start, they can be timed from the point when painting
+   * animations do start, they can be timed from the point when painting
    * completed.
    *
-   * 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 TriggerOnNextTick as the effective
-   * time at which they resumed.
+   * After calling TriggerOnNextTick, animations 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 TriggerOnNextTick as the
+   * effective time at which they resumed.
    *
    * This approach means that any setup time required for performing the
    * initial paint of an animation such as layerization is not deducted from
    * the running time of the animation. Without this we can easily drop the
    * first few frames of an animation, or, on slower devices, the whole
    * animation.
    *
    * Furthermore:
    *
-   * - Starting the player immediately when painting finishes is problematic
-   *   because the start time of the player will be ahead of its timeline
+   * - Starting the animation immediately when painting finishes is problematic
+   *   because the start time of the animation will be ahead of its timeline
    *   (since the timeline time is based on the refresh driver time).
-   *   That's a problem because the player is playing but its timing suggests
-   *   it starts in the future. We could update the timeline to match the start
-   *   time of the player but then we'd also have to update the timing and style
-   *   of all animations connected to that timeline or else be stuck in an
-   *   inconsistent state until the next refresh driver tick.
+   *   That's a problem because the animation is playing but its timing
+   *   suggests it starts in the future. We could update the timeline to match
+   *   the start time of the animation but then we'd also have to update the
+   *   timing and style of all animations connected to that timeline or else be
+   *   stuck in an inconsistent state until the next refresh driver tick.
    *
    * - If we simply use the refresh driver time on its next tick, the lag
    *   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 PendingAnimationTracker it may have been added to.
+   * Note that the caller of this method is responsible for removing the
+   * animation from any PendingAnimationTracker it may have been added to.
    */
   void TriggerOnNextTick(const Nullable<TimeDuration>& aReadyTime);
 
-  // Testing only: Start or pause a pending player using the current timeline
+  // Testing only: Start or pause a pending animation 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 TriggerOnNextTick, the caller of this method is responsible for
-  // removing the player from any PendingAnimationTracker it may have been added
-  // to.
+  // removing the animation from any PendingAnimationTracker it may have been
+  // added to.
   void TriggerNow();
 
   /**
    * When StartOnNextTick is called, we store the ready time but we don't apply
    * it until the next tick. In the meantime, GetStartTime() will return null.
    *
    * However, if we build layer animations again before the next tick, we
    * should initialize them with the start time that GetStartTime() will return
@@ -249,21 +249,21 @@ public:
   void SetIsRunningOnCompositor() { mIsRunningOnCompositor = true; }
   void ClearIsRunningOnCompositor() { mIsRunningOnCompositor = false; }
 
   // Returns true if this animation does not currently need to update
   // style on the main thread (e.g. because it is empty, or is
   // running on the compositor).
   bool CanThrottle() const;
 
-  // Updates |aStyleRule| with the animation values of this player's effect,
+  // Updates |aStyleRule| with the animation values of this animation's effect,
   // if any.
   // Any properties already contained in |aSetProperties| are not changed. Any
   // properties that are changed are added to |aSetProperties|.
-  // |aNeedsRefreshes| will be set to true if this player expects to update
+  // |aNeedsRefreshes| will be set to true if this animation expects to update
   // the style rule on the next refresh driver tick as well (because it
   // is running and has an effect to sample).
   void ComposeStyle(nsRefPtr<css::AnimValuesStyleRule>& aStyleRule,
                     nsCSSPropertySet& aSetProperties,
                     bool& aNeedsRefreshes);
 
 protected:
   void DoPlay(LimitBehavior aLimitBehavior);
@@ -282,59 +282,59 @@ protected:
   }
 
   void UpdateTiming();
   void UpdateFinishedState(bool aSeekFlag = false);
   void UpdateEffect();
   void FlushStyle() const;
   void PostUpdate();
   /**
-   * Remove this player from the pending player tracker and reset
+   * Remove this animation from the pending animation tracker and reset
    * mPendingState as necessary. The caller is responsible for resolving or
    * aborting the mReady promise as necessary.
    */
   void CancelPendingTasks();
 
   bool IsFinished() const;
 
-  bool IsPossiblyOrphanedPendingPlayer() const;
+  bool IsPossiblyOrphanedPendingAnimation() const;
   StickyTimeDuration EffectEnd() const;
 
   nsIDocument* GetRenderedDocument() const;
   nsPresContext* GetPresContext() const;
   virtual css::CommonAnimationManager* GetAnimationManager() const = 0;
   AnimationPlayerCollection* GetCollection() const;
 
   nsRefPtr<DocumentTimeline> mTimeline;
   nsRefPtr<KeyframeEffectReadonly> mEffect;
   // The beginning of the delay period.
   Nullable<TimeDuration> mStartTime; // Timeline timescale
-  Nullable<TimeDuration> mHoldTime;  // Player timescale
+  Nullable<TimeDuration> mHoldTime;  // Animation timescale
   Nullable<TimeDuration> mPendingReadyTime; // Timeline timescale
-  Nullable<TimeDuration> mPreviousCurrentTime; // Player timescale
+  Nullable<TimeDuration> mPreviousCurrentTime; // Animation timescale
   double mPlaybackRate;
 
   // A Promise that is replaced on each call to Play() (and in future Pause())
   // and fulfilled when Play() is successfully completed.
   // This object is lazily created by GetReady.
   // See http://w3c.github.io/web-animations/#current-ready-promise
   nsRefPtr<Promise> mReady;
 
   // A Promise that is resolved when we reach the end of the effect, or
   // 0 when playing backwards. The Promise is replaced if the animation is
   // finished but then a state change makes it not finished.
   // This object is lazily created by GetFinished.
   // See http://w3c.github.io/web-animations/#current-finished-promise
   nsRefPtr<Promise> mFinished;
 
-  // Indicates if the player is in the pending state (and what state it is
+  // Indicates if the animation is in the pending state (and what state it is
   // waiting to enter when it finished pending). We use this rather than
-  // checking if this player is tracked by a PendingAnimationTracker because the
-  // player will continue to be pending even after it has been removed from the
-  // PendingAnimationTracker while it is waiting for the next tick
+  // checking if this animation is tracked by a PendingAnimationTracker because
+  // the animation will continue to be pending even after it has been removed
+  // from the PendingAnimationTracker while it is waiting for the next tick
   // (see TriggerOnNextTick for details).
   enum class PendingState { NotPending, PlayPending, PausePending };
   PendingState mPendingState;
 
   bool mIsRunningOnCompositor;
   // Indicates whether we were in the finished state during our
   // most recent unthrottled sample (our last ComposeStyle call).
   bool mIsPreviousStateFinished; // Spec calls this "previous finished state"
--- a/dom/animation/KeyframeEffect.cpp
+++ b/dom/animation/KeyframeEffect.cpp
@@ -229,32 +229,32 @@ KeyframeEffectReadonly::ActiveDuration(c
            : StickyTimeDuration::Forever();
   }
   return StickyTimeDuration(
     aTiming.mIterationDuration.MultDouble(aTiming.mIterationCount));
 }
 
 // http://w3c.github.io/web-animations/#in-play
 bool
-KeyframeEffectReadonly::IsInPlay(const Animation& aPlayer) const
+KeyframeEffectReadonly::IsInPlay(const Animation& aAnimation) const
 {
   if (IsFinishedTransition() ||
-      aPlayer.PlayState() == AnimationPlayState::Finished) {
+      aAnimation.PlayState() == AnimationPlayState::Finished) {
     return false;
   }
 
   return GetComputedTiming().mPhase == ComputedTiming::AnimationPhase_Active;
 }
 
 // http://w3c.github.io/web-animations/#current
 bool
-KeyframeEffectReadonly::IsCurrent(const Animation& aPlayer) const
+KeyframeEffectReadonly::IsCurrent(const Animation& aAnimation) const
 {
   if (IsFinishedTransition() ||
-      aPlayer.PlayState() == AnimationPlayState::Finished) {
+      aAnimation.PlayState() == AnimationPlayState::Finished) {
     return false;
   }
 
   ComputedTiming computedTiming = GetComputedTiming();
   return computedTiming.mPhase == ComputedTiming::AnimationPhase_Before ||
          computedTiming.mPhase == ComputedTiming::AnimationPhase_Active;
 }
 
--- a/dom/animation/KeyframeEffect.h
+++ b/dom/animation/KeyframeEffect.h
@@ -301,18 +301,18 @@ public:
   }
 
   void SetIsFinishedTransition(bool aIsFinished) {
     MOZ_ASSERT(AsTransition(),
                "Calling SetIsFinishedTransition but it's not a transition");
     mIsFinishedTransition = aIsFinished;
   }
 
-  bool IsInPlay(const Animation& aPlayer) const;
-  bool IsCurrent(const Animation& aPlayer) const;
+  bool IsInPlay(const Animation& aAnimation) const;
+  bool IsCurrent(const Animation& aAnimation) const;
   bool IsInEffect() const;
 
   const AnimationProperty*
   GetAnimationOfProperty(nsCSSProperty aProperty) const;
   bool HasAnimationOfProperty(nsCSSProperty aProperty) const {
     return GetAnimationOfProperty(aProperty) != nullptr;
   }
   bool HasAnimationOfProperties(const nsCSSProperty* aProperties,