Bug 1203009 part 1 - Rename sequence number to animation index; r=heycam
authorBrian Birtles <birtles@gmail.com>
Tue, 15 Sep 2015 11:20:26 +0900
changeset 295300 f9b2ef0b494612c8ae22cb486a848f3649c55c06
parent 295299 ddb002f98a4a735d7292bc41504431f3248298a3
child 295301 5196bf0855ad3c9317f58faf727c0203d9963b0d
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1203009
milestone43.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 1203009 part 1 - Rename sequence number to animation index; r=heycam The Web Animations specification has replaced the term "sequence number" with references to a global animation list. This patch applies similar naming to our animation structures.
dom/animation/Animation.cpp
dom/animation/Animation.h
layout/style/nsAnimationManager.cpp
layout/style/nsAnimationManager.h
layout/style/nsTransitionManager.cpp
layout/style/nsTransitionManager.h
--- a/dom/animation/Animation.cpp
+++ b/dom/animation/Animation.cpp
@@ -17,17 +17,17 @@
 #include "nsLayoutUtils.h" // For PostRestyleEvent (remove after bug 1073336)
 #include "nsThreadUtils.h" // For nsRunnableMethod and nsRevocableEventPtr
 #include "PendingAnimationTracker.h" // For PendingAnimationTracker
 
 namespace mozilla {
 namespace dom {
 
 // Static members
-uint64_t Animation::sNextSequenceNum = 0;
+uint64_t Animation::sNextAnimationIndex = 0;
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED(Animation, DOMEventTargetHelper,
                                    mTimeline,
                                    mEffect,
                                    mReady,
                                    mFinished)
 
 NS_IMPL_ADDREF_INHERITED(Animation, DOMEventTargetHelper)
@@ -513,24 +513,24 @@ Animation::UpdateRelevance()
     nsNodeUtils::AnimationAdded(this);
   }
 }
 
 bool
 Animation::HasLowerCompositeOrderThan(const Animation& aOther) const
 {
   // We only ever sort non-idle animations so we don't ever expect
-  // mSequenceNum to be set to kUnsequenced
-  MOZ_ASSERT(mSequenceNum != kUnsequenced &&
-             aOther.mSequenceNum != kUnsequenced,
+  // mAnimationIndex to be set to kNoIndex
+  MOZ_ASSERT(mAnimationIndex != kNoIndex &&
+             aOther.mAnimationIndex != kNoIndex,
              "Animations to compare should not be idle");
-  MOZ_ASSERT(mSequenceNum != aOther.mSequenceNum || &aOther == this,
-             "Sequence numbers should be unique");
+  MOZ_ASSERT(mAnimationIndex != aOther.mAnimationIndex || &aOther == this,
+             "Animation indices should be unique");
 
-  return mSequenceNum < aOther.mSequenceNum;
+  return mAnimationIndex < aOther.mAnimationIndex;
 }
 
 bool
 Animation::CanThrottle() const
 {
   // This method answers the question, "Can we get away with NOT updating
   // style on the main thread for this animation on this tick?"
 
@@ -837,23 +837,23 @@ Animation::PauseAt(const TimeDuration& a
   if (mReady) {
     mReady->MaybeResolve(this);
   }
 }
 
 void
 Animation::UpdateTiming(SeekFlag aSeekFlag, SyncNotifyFlag aSyncNotifyFlag)
 {
-  // Update the sequence number each time we transition in or out of the
+  // Update the animation index each time we transition in or out of the
   // idle state
   if (!IsUsingCustomCompositeOrder()) {
     if (PlayState() == AnimationPlayState::Idle) {
-      mSequenceNum = kUnsequenced;
-    } else if (mSequenceNum == kUnsequenced) {
-      mSequenceNum = sNextSequenceNum++;
+      mAnimationIndex = kNoIndex;
+    } else if (mAnimationIndex == kNoIndex) {
+      mAnimationIndex = sNextAnimationIndex++;
     }
   }
 
   // We call UpdateFinishedState before UpdateEffect because the former
   // can change the current time, which is used by the latter.
   UpdateFinishedState(aSeekFlag, aSyncNotifyFlag);
   UpdateEffect();
 
--- a/dom/animation/Animation.h
+++ b/dom/animation/Animation.h
@@ -52,17 +52,17 @@ class Animation
 protected:
   virtual ~Animation() {}
 
 public:
   explicit Animation(nsIGlobalObject* aGlobal)
     : DOMEventTargetHelper(aGlobal)
     , mPlaybackRate(1.0)
     , mPendingState(PendingState::NotPending)
-    , mSequenceNum(kUnsequenced)
+    , mAnimationIndex(kNoIndex)
     , mIsRunningOnCompositor(false)
     , mFinishedAtLastComposeStyle(false)
     , mIsRelevant(false)
     , mFinishedIsResolved(false)
   {
   }
 
   NS_DECL_ISUPPORTS_INHERITED
@@ -400,23 +400,27 @@ protected:
   // waiting to enter when it finished pending). We use this rather than
   // 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;
 
-  static uint64_t sNextSequenceNum;
-  static const uint64_t kUnsequenced = UINT64_MAX;
+  static uint64_t sNextAnimationIndex;
+  static const uint64_t kNoIndex = UINT64_MAX;
 
-  // The sequence number assigned to this animation. This is kUnsequenced
-  // while the animation is in the idle state and is updated each time
-  // the animation transitions out of the idle state.
-  uint64_t mSequenceNum;
+  // The relative position of this animation within the global animation list.
+  // This is kNoIndex while the animation is in the idle state and is updated
+  // each time the animation transitions out of the idle state.
+  //
+  // Note that subclasses such as CSSTransition and CSSAnimation may repurpose
+  // this member to implement their own brand of sorting. As a result, it is
+  // possible for two different objects to have the same index.
+  uint64_t mAnimationIndex;
 
   bool mIsRunningOnCompositor;
   bool mFinishedAtLastComposeStyle;
   // Indicates that the animation should be exposed in an element's
   // getAnimations() list.
   bool mIsRelevant;
 
   nsRevocableEventPtr<nsRunnableMethod<Animation>> mFinishNotificationTask;
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -157,17 +157,17 @@ CSSAnimation::HasLowerCompositeOrderThan
   MOZ_ASSERT(mOwningElement.IsSet() && otherAnimation->OwningElement().IsSet(),
              "Animations using custom composite order should have an "
              "owning element");
   if (!mOwningElement.Equals(otherAnimation->OwningElement())) {
     return mOwningElement.LessThan(otherAnimation->OwningElement());
   }
 
   // 4. (Same element and pseudo): Sort by position in animation-name
-  return mSequenceNum < otherAnimation->mSequenceNum;
+  return mAnimationIndex < otherAnimation->mAnimationIndex;
 }
 
 void
 CSSAnimation::QueueEvents()
 {
   if (!mEffect) {
     return;
   }
--- a/layout/style/nsAnimationManager.h
+++ b/layout/style/nsAnimationManager.h
@@ -93,17 +93,17 @@ public:
   virtual void PlayFromJS(ErrorResult& aRv) override;
 
   void PlayFromStyle();
   void PauseFromStyle();
   void CancelFromStyle() override
   {
     mOwningElement = OwningElementRef();
     Animation::CancelFromStyle();
-    MOZ_ASSERT(mSequenceNum == kUnsequenced);
+    MOZ_ASSERT(mAnimationIndex == kNoIndex);
   }
 
   void Tick() override;
   void QueueEvents();
   bool HasEndEventToQueue() const override;
 
   bool IsStylePaused() const { return mIsStylePaused; }
 
@@ -111,23 +111,23 @@ public:
   bool IsUsingCustomCompositeOrder() const override
   {
     return mOwningElement.IsSet();
   }
 
   void SetAnimationIndex(uint64_t aIndex)
   {
     MOZ_ASSERT(IsUsingCustomCompositeOrder());
-    mSequenceNum = aIndex;
+    mAnimationIndex = aIndex;
   }
   void CopyAnimationIndex(const CSSAnimation& aOther)
   {
     MOZ_ASSERT(IsUsingCustomCompositeOrder() &&
                aOther.IsUsingCustomCompositeOrder());
-    mSequenceNum = aOther.mSequenceNum;
+    mAnimationIndex = aOther.mAnimationIndex;
   }
 
   // Returns the element or pseudo-element whose animation-name property
   // this CSSAnimation corresponds to (if any). This is used for determining
   // the relative composite order of animations generated from CSS markup.
   //
   // Typically this will be the same as the target element of the keyframe
   // effect associated with this animation. However, it can differ in the
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -200,18 +200,18 @@ CSSTransition::HasLowerCompositeOrderTha
   MOZ_ASSERT(mOwningElement.IsSet() && otherTransition->OwningElement().IsSet(),
              "Transitions using custom composite order should have an owning "
              "element");
   if (!mOwningElement.Equals(otherTransition->OwningElement())) {
     return mOwningElement.LessThan(otherTransition->OwningElement());
   }
 
   // 4. (Same element and pseudo): Sort by transition generation
-  if (mSequenceNum != otherTransition->mSequenceNum) {
-    return mSequenceNum < otherTransition->mSequenceNum;
+  if (mAnimationIndex != otherTransition->mAnimationIndex) {
+    return mAnimationIndex < otherTransition->mAnimationIndex;
   }
 
   // 5. (Same transition generation): Sort by transition property
   return nsCSSProps::GetStringValue(TransitionProperty()) <
          nsCSSProps::GetStringValue(otherTransition->TransitionProperty());
 }
 
 ////////////////////////// nsTransitionManager ////////////////////////////
--- a/layout/style/nsTransitionManager.h
+++ b/layout/style/nsTransitionManager.h
@@ -110,33 +110,33 @@ public:
     // play() should not throw when LimitBehavior is Continue
     MOZ_ASSERT(!rv.Failed(), "Unexpected exception playing transition");
   }
 
   void CancelFromStyle() override
   {
     mOwningElement = OwningElementRef();
     Animation::CancelFromStyle();
-    MOZ_ASSERT(mSequenceNum == kUnsequenced);
+    MOZ_ASSERT(mAnimationIndex == kNoIndex);
   }
 
   void Tick() override;
 
   nsCSSProperty TransitionProperty() const;
 
   bool HasLowerCompositeOrderThan(const Animation& aOther) const override;
   bool IsUsingCustomCompositeOrder() const override
   {
     return mOwningElement.IsSet();
   }
 
   void SetCreationSequence(uint64_t aIndex)
   {
     MOZ_ASSERT(IsUsingCustomCompositeOrder());
-    mSequenceNum = aIndex;
+    mAnimationIndex = aIndex;
   }
 
   // Returns the element or pseudo-element whose transition-property property
   // this CSSTransition corresponds to (if any). This is used for determining
   // the relative composite order of transitions generated from CSS markup.
   //
   // Typically this will be the same as the target element of the keyframe
   // effect associated with this transition. However, it can differ in the