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.
This commit is contained in:
Brian Birtles 2015-09-15 11:20:26 +09:00
parent b6f42cf002
commit 8397a722f4
6 changed files with 30 additions and 26 deletions

View File

@ -22,7 +22,7 @@ namespace mozilla {
namespace dom {
// Static members
uint64_t Animation::sNextSequenceNum = 0;
uint64_t Animation::sNextAnimationIndex = 0;
NS_IMPL_CYCLE_COLLECTION_INHERITED(Animation, DOMEventTargetHelper,
mTimeline,
@ -518,14 +518,14 @@ 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
@ -842,13 +842,13 @@ Animation::PauseAt(const TimeDuration& aReadyTime)
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++;
}
}

View File

@ -57,7 +57,7 @@ public:
: DOMEventTargetHelper(aGlobal)
, mPlaybackRate(1.0)
, mPendingState(PendingState::NotPending)
, mSequenceNum(kUnsequenced)
, mAnimationIndex(kNoIndex)
, mIsRunningOnCompositor(false)
, mFinishedAtLastComposeStyle(false)
, mIsRelevant(false)
@ -405,13 +405,17 @@ protected:
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;

View File

@ -162,7 +162,7 @@ CSSAnimation::HasLowerCompositeOrderThan(const Animation& aOther) const
}
// 4. (Same element and pseudo): Sort by position in animation-name
return mSequenceNum < otherAnimation->mSequenceNum;
return mAnimationIndex < otherAnimation->mAnimationIndex;
}
void

View File

@ -98,7 +98,7 @@ public:
{
mOwningElement = OwningElementRef();
Animation::CancelFromStyle();
MOZ_ASSERT(mSequenceNum == kUnsequenced);
MOZ_ASSERT(mAnimationIndex == kNoIndex);
}
void Tick() override;
@ -116,13 +116,13 @@ public:
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

View File

@ -205,8 +205,8 @@ CSSTransition::HasLowerCompositeOrderThan(const Animation& aOther) const
}
// 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

View File

@ -115,7 +115,7 @@ public:
{
mOwningElement = OwningElementRef();
Animation::CancelFromStyle();
MOZ_ASSERT(mSequenceNum == kUnsequenced);
MOZ_ASSERT(mAnimationIndex == kNoIndex);
}
void Tick() override;
@ -131,7 +131,7 @@ public:
void SetCreationSequence(uint64_t aIndex)
{
MOZ_ASSERT(IsUsingCustomCompositeOrder());
mSequenceNum = aIndex;
mAnimationIndex = aIndex;
}
// Returns the element or pseudo-element whose transition-property property