Bug 1040543 part 6 - Rename mAnimations to mPlayers and likewise for similar local variables; r=bz

Now that we have both AnimationPlayer and Animation in use we need to clarify
which object we are referring to. This patch renames a number of member and
local variables to better reflect whether they point to an AnimationPlayer or an
Animation.

This patch is mostly renaming only with one exception. Since we are touching
a number of local variables used in loops (for looping over the array of
animation players) we take the opportunity to replace a number of instances of
uint32_t with size_t since that is the preferred type for array indices now.
This commit is contained in:
Brian Birtles 2014-08-10 17:06:48 +10:00
parent feea3d3911
commit ca53da1e82
7 changed files with 153 additions and 147 deletions

View File

@ -2878,12 +2878,12 @@ Element::GetAnimationPlayers(nsTArray<nsRefPtr<AnimationPlayer> >& aPlayers)
if (!collection) {
continue;
}
for (size_t animIdx = 0;
animIdx < collection->mAnimations.Length();
animIdx++) {
AnimationPlayer* anim = collection->mAnimations[animIdx];
if (anim->IsCurrent()) {
aPlayers.AppendElement(anim);
for (size_t playerIdx = 0;
playerIdx < collection->mPlayers.Length();
playerIdx++) {
AnimationPlayer* player = collection->mPlayers[playerIdx];
if (player->IsCurrent()) {
aPlayers.AppendElement(player);
}
}
}

View File

@ -331,7 +331,7 @@ ToTimingFunction(ComputedTimingFunction& aCTF)
static void
AddAnimationForProperty(nsIFrame* aFrame, nsCSSProperty aProperty,
AnimationPlayer* ea, Layer* aLayer,
AnimationPlayer* aPlayer, Layer* aLayer,
AnimationData& aData, bool aPending)
{
NS_ASSERTION(aLayer->AsContainerLayer(), "Should only animate ContainerLayer");
@ -344,15 +344,17 @@ AddAnimationForProperty(nsIFrame* aFrame, nsCSSProperty aProperty,
aLayer->AddAnimationForNextTransaction() :
aLayer->AddAnimation();
animation->startTime() = ea->mStartTime + ea->mTiming.mDelay;
animation->duration() = ea->mTiming.mIterationDuration;
animation->iterationCount() = ea->mTiming.mIterationCount;
animation->direction() = ea->mTiming.mDirection;
animation->startTime() = aPlayer->mStartTime + aPlayer->mTiming.mDelay;
animation->duration() = aPlayer->mTiming.mIterationDuration;
animation->iterationCount() = aPlayer->mTiming.mIterationCount;
animation->direction() = aPlayer->mTiming.mDirection;
animation->property() = aProperty;
animation->data() = aData;
for (uint32_t propIdx = 0; propIdx < ea->mProperties.Length(); propIdx++) {
AnimationProperty* property = &ea->mProperties[propIdx];
for (size_t propIdx = 0;
propIdx < aPlayer->mProperties.Length();
propIdx++) {
AnimationProperty* property = &aPlayer->mProperties[propIdx];
if (aProperty != property->mProperty) {
continue;
@ -387,16 +389,16 @@ AddAnimationForProperty(nsIFrame* aFrame, nsCSSProperty aProperty,
static void
AddAnimationsForProperty(nsIFrame* aFrame, nsCSSProperty aProperty,
AnimationPlayerPtrArray& aAnimations,
AnimationPlayerPtrArray& aPlayers,
Layer* aLayer, AnimationData& aData,
bool aPending) {
for (uint32_t animIdx = 0; animIdx < aAnimations.Length(); animIdx++) {
AnimationPlayer* anim = aAnimations[animIdx];
if (!(anim->HasAnimationOfProperty(aProperty) && anim->IsRunning())) {
for (size_t playerIdx = 0; playerIdx < aPlayers.Length(); playerIdx++) {
AnimationPlayer* player = aPlayers[playerIdx];
if (!(player->HasAnimationOfProperty(aProperty) && player->IsRunning())) {
continue;
}
AddAnimationForProperty(aFrame, aProperty, anim, aLayer, aData, aPending);
anim->mIsRunningOnCompositor = true;
AddAnimationForProperty(aFrame, aProperty, player, aLayer, aData, aPending);
player->mIsRunningOnCompositor = true;
}
}
@ -489,13 +491,13 @@ nsDisplayListBuilder::AddAnimationsAndTransitionsToLayer(Layer* aLayer,
}
if (transitions) {
AddAnimationsForProperty(aFrame, aProperty, transitions->mAnimations,
AddAnimationsForProperty(aFrame, aProperty, transitions->mPlayers,
aLayer, data, pending);
aLayer->SetAnimationGeneration(transitions->mAnimationGeneration);
}
if (animations) {
AddAnimationsForProperty(aFrame, aProperty, animations->mAnimations,
AddAnimationsForProperty(aFrame, aProperty, animations->mPlayers,
aLayer, data, pending);
aLayer->SetAnimationGeneration(animations->mAnimationGeneration);
}

View File

@ -470,13 +470,13 @@ GetMinAndMaxScaleForAnimationProperty(nsIContent* aContent,
if (!collection)
return;
for (uint32_t animIdx = collection->mAnimations.Length(); animIdx-- != 0; ) {
AnimationPlayer* anim = collection->mAnimations[animIdx];
if (anim->IsFinishedTransition()) {
for (size_t playerIdx = collection->mPlayers.Length(); playerIdx-- != 0; ) {
AnimationPlayer* player = collection->mPlayers[playerIdx];
if (player->IsFinishedTransition()) {
continue;
}
for (uint32_t propIdx = anim->mProperties.Length(); propIdx-- != 0; ) {
AnimationProperty& prop = anim->mProperties[propIdx];
for (size_t propIdx = player->mProperties.Length(); propIdx-- != 0; ) {
AnimationProperty& prop = player->mProperties[propIdx];
if (prop.mProperty == eCSSProperty_transform) {
for (uint32_t segIdx = prop.mSegments.Length(); segIdx-- != 0; ) {
AnimationPropertySegment& segment = prop.mSegments[segIdx];

View File

@ -353,12 +353,12 @@ AnimationPlayerCollection::CanPerformOnCompositorThread(
return false;
}
for (uint32_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
const AnimationPlayer* anim = mAnimations[animIdx];
bool isRunning = anim->IsRunning();
for (uint32_t propIdx = 0, propEnd = anim->mProperties.Length();
for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
const AnimationPlayer* player = mPlayers[playerIdx];
bool isRunning = player->IsRunning();
for (size_t propIdx = 0, propEnd = player->mProperties.Length();
propIdx != propEnd; ++propIdx) {
if (IsGeometricProperty(anim->mProperties[propIdx].mProperty) &&
if (IsGeometricProperty(player->mProperties[propIdx].mProperty) &&
isRunning) {
aFlags = CanAnimateFlags(aFlags | CanAnimate_HasGeometricProperty);
break;
@ -367,17 +367,17 @@ AnimationPlayerCollection::CanPerformOnCompositorThread(
}
bool existsProperty = false;
for (uint32_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
const AnimationPlayer* anim = mAnimations[animIdx];
if (!anim->IsRunning()) {
for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
const AnimationPlayer* player = mPlayers[playerIdx];
if (!player->IsRunning()) {
continue;
}
existsProperty = true;
for (uint32_t propIdx = 0, propEnd = anim->mProperties.Length();
for (size_t propIdx = 0, propEnd = player->mProperties.Length();
propIdx != propEnd; ++propIdx) {
const AnimationProperty& prop = anim->mProperties[propIdx];
const AnimationProperty& prop = player->mProperties[propIdx];
if (!CanAnimatePropertyOnCompositor(mElement,
prop.mProperty,
aFlags) ||
@ -399,10 +399,10 @@ bool
AnimationPlayerCollection::HasAnimationOfProperty(
nsCSSProperty aProperty) const
{
for (uint32_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
const AnimationPlayer* anim = mAnimations[animIdx];
if (anim->HasAnimationOfProperty(aProperty) &&
!anim->IsFinishedTransition()) {
for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
const AnimationPlayer* player = mPlayers[playerIdx];
if (player->HasAnimationOfProperty(aProperty) &&
!player->IsFinishedTransition()) {
return true;
}
}
@ -445,9 +445,9 @@ AnimationPlayerCollection::PropertyDtor(void *aObject, nsIAtom *aPropertyName,
void
AnimationPlayerCollection::Tick()
{
for (size_t animIdx = 0, animEnd = mAnimations.Length();
animIdx != animEnd; animIdx++) {
mAnimations[animIdx]->Tick();
for (size_t playerIdx = 0, playerEnd = mPlayers.Length();
playerIdx != playerEnd; playerIdx++) {
mPlayers[playerIdx]->Tick();
}
}
@ -467,26 +467,27 @@ AnimationPlayerCollection::EnsureStyleRuleFor(TimeStamp aRefreshTime,
// mode behaviour). This loop checks for any finishing animations and forces
// the style recalculation if we find any.
if (aFlags == EnsureStyleRule_IsThrottled) {
for (uint32_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
AnimationPlayer* anim = mAnimations[animIdx];
for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
AnimationPlayer* player = mPlayers[playerIdx];
// Skip finished transitions or animations whose @keyframes rule
// is empty.
if (anim->IsFinishedTransition() || anim->mProperties.IsEmpty()) {
if (player->IsFinishedTransition() || player->mProperties.IsEmpty()) {
continue;
}
// The GetLocalTime() call here handles pausing. But:
// The GetComputedTiming() call here handles pausing. But:
// FIXME: avoid recalculating every time when paused.
ComputedTiming computedTiming = anim->GetComputedTiming(anim->mTiming);
ComputedTiming computedTiming =
player->GetComputedTiming(player->mTiming);
// XXX We shouldn't really be using mLastNotification as a general
// indicator that the animation has finished, it should be reserved for
// events. If we use it differently in the future this use might need
// changing.
if (!anim->mIsRunningOnCompositor ||
if (!player->mIsRunningOnCompositor ||
(computedTiming.mPhase == ComputedTiming::AnimationPhase_After &&
anim->mLastNotification != AnimationPlayer::LAST_NOTIFICATION_END))
player->mLastNotification != AnimationPlayer::LAST_NOTIFICATION_END))
{
aFlags = EnsureStyleRule_IsNotThrottled;
break;
@ -511,20 +512,21 @@ AnimationPlayerCollection::EnsureStyleRuleFor(TimeStamp aRefreshTime,
// Therefore, we iterate from last animation to first.
nsCSSPropertySet properties;
for (uint32_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
AnimationPlayer* anim = mAnimations[animIdx];
for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
AnimationPlayer* player = mPlayers[playerIdx];
if (anim->IsFinishedTransition()) {
if (player->IsFinishedTransition()) {
continue;
}
// The GetLocalTime() call here handles pausing. But:
// The GetComputedTiming() call here handles pausing. But:
// FIXME: avoid recalculating every time when paused.
ComputedTiming computedTiming = anim->GetComputedTiming(anim->mTiming);
ComputedTiming computedTiming =
player->GetComputedTiming(player->mTiming);
if ((computedTiming.mPhase == ComputedTiming::AnimationPhase_Before ||
computedTiming.mPhase == ComputedTiming::AnimationPhase_Active) &&
!anim->IsPaused()) {
!player->IsPaused()) {
mNeedsRefreshes = true;
}
@ -538,10 +540,10 @@ AnimationPlayerCollection::EnsureStyleRuleFor(TimeStamp aRefreshTime,
computedTiming.mTimeFraction <= 1.0,
"timing fraction should be in [0-1]");
for (uint32_t propIdx = 0, propEnd = anim->mProperties.Length();
for (size_t propIdx = 0, propEnd = player->mProperties.Length();
propIdx != propEnd; ++propIdx)
{
const AnimationProperty &prop = anim->mProperties[propIdx];
const AnimationProperty& prop = player->mProperties[propIdx];
NS_ABORT_IF_FALSE(prop.mSegments[0].mFromKey == 0.0,
"incorrect first from key");
@ -691,8 +693,8 @@ AnimationPlayerCollection::UpdateAnimationGeneration(
bool
AnimationPlayerCollection::HasCurrentAnimations()
{
for (uint32_t animIdx = mAnimations.Length(); animIdx-- != 0; ) {
if (mAnimations[animIdx]->IsCurrent()) {
for (size_t playerIdx = mPlayers.Length(); playerIdx-- != 0; ) {
if (mPlayers[playerIdx]->IsCurrent()) {
return true;
}
}

View File

@ -270,7 +270,7 @@ struct AnimationPlayerCollection : public PRCList
mozilla::css::CommonAnimationManager *mManager;
mozilla::AnimationPlayerPtrArray mAnimations;
mozilla::AnimationPlayerPtrArray mPlayers;
// This style rule contains the style data for currently animating
// values. It only matches when styling with animation. When we

View File

@ -43,10 +43,10 @@ nsAnimationManager::GetEventsForCurrentTime(AnimationPlayerCollection*
aCollection,
EventArray& aEventsToDispatch)
{
for (uint32_t animIdx = aCollection->mAnimations.Length(); animIdx-- != 0; ) {
AnimationPlayer* anim = aCollection->mAnimations[animIdx];
for (size_t playerIdx = aCollection->mPlayers.Length(); playerIdx-- != 0; ) {
AnimationPlayer* player = aCollection->mPlayers[playerIdx];
ComputedTiming computedTiming = anim->GetComputedTiming(anim->mTiming);
ComputedTiming computedTiming = player->GetComputedTiming(player->mTiming);
switch (computedTiming.mPhase) {
case ComputedTiming::AnimationPhase_Null:
@ -56,7 +56,7 @@ nsAnimationManager::GetEventsForCurrentTime(AnimationPlayerCollection*
case ComputedTiming::AnimationPhase_Active:
// Dispatch 'animationstart' or 'animationiteration' when needed.
if (computedTiming.mCurrentIteration != anim->mLastNotification) {
if (computedTiming.mCurrentIteration != player->mLastNotification) {
// Notify 'animationstart' even if a negative delay puts us
// past the first iteration.
// Note that when somebody changes the animation-duration
@ -64,16 +64,18 @@ nsAnimationManager::GetEventsForCurrentTime(AnimationPlayerCollection*
// immediately in many cases. It's not clear to me if that's the
// right thing to do.
uint32_t message =
anim->mLastNotification == AnimationPlayer::LAST_NOTIFICATION_NONE
? NS_ANIMATION_START : NS_ANIMATION_ITERATION;
player->mLastNotification ==
AnimationPlayer::LAST_NOTIFICATION_NONE
? NS_ANIMATION_START
: NS_ANIMATION_ITERATION;
anim->mLastNotification = computedTiming.mCurrentIteration;
player->mLastNotification = computedTiming.mCurrentIteration;
TimeDuration iterationStart =
anim->mTiming.mIterationDuration *
player->mTiming.mIterationDuration *
computedTiming.mCurrentIteration;
TimeDuration elapsedTime =
std::max(iterationStart, anim->InitialAdvance());
AnimationEventInfo ei(aCollection->mElement, anim->mName, message,
std::max(iterationStart, player->InitialAdvance());
AnimationEventInfo ei(aCollection->mElement, player->mName, message,
elapsedTime, aCollection->PseudoElement());
aEventsToDispatch.AppendElement(ei);
}
@ -82,25 +84,25 @@ nsAnimationManager::GetEventsForCurrentTime(AnimationPlayerCollection*
case ComputedTiming::AnimationPhase_After:
// If we skipped the animation interval entirely, dispatch
// 'animationstart' first
if (anim->mLastNotification ==
if (player->mLastNotification ==
AnimationPlayer::LAST_NOTIFICATION_NONE) {
// Notifying for start of 0th iteration.
// (This is overwritten below but we set it here to maintain
// internal consistency.)
anim->mLastNotification = 0;
player->mLastNotification = 0;
TimeDuration elapsedTime =
std::min(anim->InitialAdvance(), computedTiming.mActiveDuration);
std::min(player->InitialAdvance(), computedTiming.mActiveDuration);
AnimationEventInfo ei(aCollection->mElement,
anim->mName, NS_ANIMATION_START,
player->mName, NS_ANIMATION_START,
elapsedTime, aCollection->PseudoElement());
aEventsToDispatch.AppendElement(ei);
}
// Dispatch 'animationend' when needed.
if (anim->mLastNotification !=
if (player->mLastNotification !=
AnimationPlayer::LAST_NOTIFICATION_END) {
anim->mLastNotification = AnimationPlayer::LAST_NOTIFICATION_END;
player->mLastNotification = AnimationPlayer::LAST_NOTIFICATION_END;
AnimationEventInfo ei(aCollection->mElement,
anim->mName, NS_ANIMATION_END,
player->mName, NS_ANIMATION_END,
computedTiming.mActiveDuration,
aCollection->PseudoElement());
aEventsToDispatch.AppendElement(ei);
@ -244,10 +246,10 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
// build the animations list
dom::AnimationTimeline* timeline = aElement->OwnerDoc()->Timeline();
AnimationPlayerPtrArray newAnimations;
BuildAnimations(aStyleContext, timeline, newAnimations);
AnimationPlayerPtrArray newPlayers;
BuildAnimations(aStyleContext, timeline, newPlayers);
if (newAnimations.IsEmpty()) {
if (newPlayers.IsEmpty()) {
if (collection) {
collection->Destroy();
}
@ -269,9 +271,9 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
// In order to honor what the spec said, we'd copy more data over
// (or potentially optimize BuildAnimations to avoid rebuilding it
// in the first place).
if (!collection->mAnimations.IsEmpty()) {
for (size_t newIdx = newAnimations.Length(); newIdx-- != 0;) {
AnimationPlayer* newAnim = newAnimations[newIdx];
if (!collection->mPlayers.IsEmpty()) {
for (size_t newIdx = newPlayers.Length(); newIdx-- != 0;) {
AnimationPlayer* newPlayer = newPlayers[newIdx];
// Find the matching animation with this name in the old list
// of animations. We iterate through both lists in a backwards
@ -279,32 +281,32 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
// the new list of animations with a given name than in the old
// list, it will be the animations towards the of the beginning of
// the list that do not match and are treated as new animations.
nsRefPtr<AnimationPlayer> oldAnim;
size_t oldIdx = collection->mAnimations.Length();
nsRefPtr<AnimationPlayer> oldPlayer;
size_t oldIdx = collection->mPlayers.Length();
while (oldIdx-- != 0) {
AnimationPlayer* a = collection->mAnimations[oldIdx];
if (a->mName == newAnim->mName) {
oldAnim = a;
AnimationPlayer* a = collection->mPlayers[oldIdx];
if (a->mName == newPlayer->mName) {
oldPlayer = a;
break;
}
}
if (!oldAnim) {
if (!oldPlayer) {
continue;
}
// Update the old from the new so we can keep the original object
// identity (and any expando properties attached to it).
oldAnim->mTiming = newAnim->mTiming;
oldAnim->mProperties = newAnim->mProperties;
oldPlayer->mTiming = newPlayer->mTiming;
oldPlayer->mProperties = newPlayer->mProperties;
// Reset compositor state so animation will be re-synchronized.
oldAnim->mIsRunningOnCompositor = false;
oldPlayer->mIsRunningOnCompositor = false;
// Handle changes in play state.
if (!oldAnim->IsPaused() && newAnim->IsPaused()) {
if (!oldPlayer->IsPaused() && newPlayer->IsPaused()) {
// Start pause at current time.
oldAnim->mPauseStart = timeline->GetCurrentTimeStamp();
} else if (oldAnim->IsPaused() && !newAnim->IsPaused()) {
oldPlayer->mPauseStart = timeline->GetCurrentTimeStamp();
} else if (oldPlayer->IsPaused() && !newPlayer->IsPaused()) {
const TimeStamp& now = timeline->GetCurrentTimeStamp();
if (!now.IsNull()) {
// FIXME: Once we store the start time and pause start as
@ -312,28 +314,28 @@ nsAnimationManager::CheckAnimationRule(nsStyleContext* aStyleContext,
// start time to something more appropriate when now IsNull.
// Handle change in pause state by adjusting start time to
// unpause.
oldAnim->mStartTime += now - oldAnim->mPauseStart;
oldPlayer->mStartTime += now - oldPlayer->mPauseStart;
}
oldAnim->mPauseStart = TimeStamp();
oldPlayer->mPauseStart = TimeStamp();
}
oldAnim->mPlayState = newAnim->mPlayState;
oldPlayer->mPlayState = newPlayer->mPlayState;
// Replace new animation with the (updated) old one and remove the
// old one from the array so we don't try to match it any more.
//
// Although we're doing this while iterating this is safe because
// we're not changing the length of newAnimations and we've finished
// we're not changing the length of newPlayers and we've finished
// iterating over the list of old iterations.
newAnim = nullptr;
newAnimations.ReplaceElementAt(newIdx, oldAnim);
collection->mAnimations.RemoveElementAt(oldIdx);
newPlayer = nullptr;
newPlayers.ReplaceElementAt(newIdx, oldPlayer);
collection->mPlayers.RemoveElementAt(oldIdx);
}
}
} else {
collection =
GetAnimationPlayers(aElement, aStyleContext->GetPseudoType(), true);
}
collection->mAnimations.SwapElements(newAnimations);
collection->mPlayers.SwapElements(newPlayers);
collection->mNeedsRefreshes = true;
collection->Tick();
@ -406,16 +408,16 @@ ResolvedStyleCache::Get(nsPresContext *aPresContext,
void
nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
dom::AnimationTimeline* aTimeline,
AnimationPlayerPtrArray& aAnimations)
AnimationPlayerPtrArray& aPlayers)
{
NS_ABORT_IF_FALSE(aAnimations.IsEmpty(), "expect empty array");
NS_ABORT_IF_FALSE(aPlayers.IsEmpty(), "expect empty array");
ResolvedStyleCache resolvedStyles;
const nsStyleDisplay *disp = aStyleContext->StyleDisplay();
TimeStamp now = aTimeline->GetCurrentTimeStamp();
for (uint32_t animIdx = 0, animEnd = disp->mAnimationNameCount;
for (size_t animIdx = 0, animEnd = disp->mAnimationNameCount;
animIdx != animEnd; ++animIdx) {
const StyleAnimation& src = disp->mAnimations[animIdx];
@ -434,7 +436,7 @@ nsAnimationManager::BuildAnimations(nsStyleContext* aStyleContext,
}
nsRefPtr<AnimationPlayer> dest =
*aAnimations.AppendElement(new AnimationPlayer(aTimeline));
*aPlayers.AppendElement(new AnimationPlayer(aTimeline));
dest->mName = src.GetName();

View File

@ -254,18 +254,18 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
}
}
AnimationPlayerPtrArray& animations = collection->mAnimations;
uint32_t i = animations.Length();
AnimationPlayerPtrArray& players = collection->mPlayers;
size_t i = players.Length();
NS_ABORT_IF_FALSE(i != 0, "empty transitions list?");
StyleAnimationValue currentValue;
do {
--i;
AnimationPlayer* animation = animations[i];
MOZ_ASSERT(animation->mProperties.Length() == 1,
AnimationPlayer* player = players[i];
MOZ_ASSERT(player->mProperties.Length() == 1,
"Should have one animation property for a transition");
MOZ_ASSERT(animation->mProperties[0].mSegments.Length() == 1,
MOZ_ASSERT(player->mProperties[0].mSegments.Length() == 1,
"Animation property should have one segment for a transition");
const AnimationProperty& prop = animation->mProperties[0];
const AnimationProperty& prop = player->mProperties[0];
const AnimationPropertySegment& segment = prop.mSegments[0];
// properties no longer in 'transition-property'
if ((checkProperties &&
@ -276,12 +276,12 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
currentValue) ||
currentValue != segment.mToValue) {
// stop the transition
animations.RemoveElementAt(i);
players.RemoveElementAt(i);
collection->UpdateAnimationGeneration(mPresContext);
}
} while (i != 0);
if (animations.IsEmpty()) {
if (players.IsEmpty()) {
collection->Destroy();
collection = nullptr;
}
@ -311,14 +311,14 @@ nsTransitionManager::StyleContextChanged(dom::Element *aElement,
nsRefPtr<css::AnimValuesStyleRule> coverRule = new css::AnimValuesStyleRule;
AnimationPlayerPtrArray& animations = collection->mAnimations;
for (uint32_t i = 0, i_end = animations.Length(); i < i_end; ++i) {
AnimationPlayer* animation = animations[i];
MOZ_ASSERT(animation->mProperties.Length() == 1,
AnimationPlayerPtrArray& players = collection->mPlayers;
for (size_t i = 0, i_end = players.Length(); i < i_end; ++i) {
AnimationPlayer* player = players[i];
MOZ_ASSERT(player->mProperties.Length() == 1,
"Should have one animation property for a transition");
MOZ_ASSERT(animation->mProperties[0].mSegments.Length() == 1,
MOZ_ASSERT(player->mProperties[0].mSegments.Length() == 1,
"Animation property should have one segment for a transition");
AnimationProperty& prop = animation->mProperties[0];
AnimationProperty& prop = player->mProperties[0];
AnimationPropertySegment& segment = prop.mSegments[0];
if (whichStarted.HasProperty(prop.mProperty)) {
coverRule->AddValue(prop.mProperty, segment.mFromValue);
@ -385,15 +385,15 @@ nsTransitionManager::ConsiderStartingTransition(
size_t currentIndex = nsTArray<ElementPropertyTransition>::NoIndex;
const ElementPropertyTransition *oldPT = nullptr;
if (aElementTransitions) {
AnimationPlayerPtrArray& animations = aElementTransitions->mAnimations;
for (size_t i = 0, i_end = animations.Length(); i < i_end; ++i) {
MOZ_ASSERT(animations[i]->mProperties.Length() == 1,
AnimationPlayerPtrArray& players = aElementTransitions->mPlayers;
for (size_t i = 0, i_end = players.Length(); i < i_end; ++i) {
MOZ_ASSERT(players[i]->mProperties.Length() == 1,
"Should have one animation property for a transition");
if (animations[i]->mProperties[0].mProperty == aProperty) {
if (players[i]->mProperties[0].mProperty == aProperty) {
haveCurrentTransition = true;
currentIndex = i;
oldPT =
aElementTransitions->mAnimations[currentIndex]->AsTransition();
aElementTransitions->mPlayers[currentIndex]->AsTransition();
break;
}
}
@ -426,11 +426,11 @@ nsTransitionManager::ConsiderStartingTransition(
// in-progress value (which is particularly easy to cause when we're
// currently in the 'transition-delay'). It also might happen because we
// just got a style change to a value that can't be interpolated.
AnimationPlayerPtrArray& animations = aElementTransitions->mAnimations;
animations.RemoveElementAt(currentIndex);
AnimationPlayerPtrArray& players = aElementTransitions->mPlayers;
players.RemoveElementAt(currentIndex);
aElementTransitions->UpdateAnimationGeneration(mPresContext);
if (animations.IsEmpty()) {
if (players.IsEmpty()) {
aElementTransitions->Destroy();
// |aElementTransitions| is now a dangling pointer!
aElementTransitions = nullptr;
@ -521,20 +521,20 @@ nsTransitionManager::ConsiderStartingTransition(
}
}
AnimationPlayerPtrArray &animations = aElementTransitions->mAnimations;
AnimationPlayerPtrArray& players = aElementTransitions->mPlayers;
#ifdef DEBUG
for (uint32_t i = 0, i_end = animations.Length(); i < i_end; ++i) {
NS_ABORT_IF_FALSE(animations[i]->mProperties.Length() == 1,
for (size_t i = 0, i_end = players.Length(); i < i_end; ++i) {
NS_ABORT_IF_FALSE(players[i]->mProperties.Length() == 1,
"Should have one animation property for a transition");
NS_ABORT_IF_FALSE(i == currentIndex ||
animations[i]->mProperties[0].mProperty != aProperty,
players[i]->mProperties[0].mProperty != aProperty,
"duplicate transitions for property");
}
#endif
if (haveCurrentTransition) {
animations[currentIndex] = pt;
players[currentIndex] = pt;
} else {
if (!animations.AppendElement(pt)) {
if (!players.AppendElement(pt)) {
NS_WARNING("out of memory");
return;
}
@ -757,35 +757,35 @@ nsTransitionManager::FlushTransitions(FlushFlags aFlags)
"Element::UnbindFromTree should have "
"destroyed the element transitions object");
uint32_t i = collection->mAnimations.Length();
size_t i = collection->mPlayers.Length();
NS_ABORT_IF_FALSE(i != 0, "empty transitions list?");
bool transitionStartedOrEnded = false;
do {
--i;
AnimationPlayer* anim = collection->mAnimations[i];
if (anim->IsFinishedTransition()) {
AnimationPlayer* player = collection->mPlayers[i];
if (player->IsFinishedTransition()) {
// Actually remove transitions one throttle-able cycle after their
// completion. We only clear on a throttle-able cycle because that
// means it is a regular restyle tick and thus it is safe to discard
// the transition. If the flush is not throttle-able, we might still
// have new transitions left to process. See comment below.
if (aFlags == Can_Throttle) {
collection->mAnimations.RemoveElementAt(i);
collection->mPlayers.RemoveElementAt(i);
}
} else {
ComputedTiming computedTiming =
anim->GetComputedTiming(anim->mTiming);
player->GetComputedTiming(player->mTiming);
if (computedTiming.mPhase == ComputedTiming::AnimationPhase_After) {
MOZ_ASSERT(anim->mProperties.Length() == 1,
MOZ_ASSERT(player->mProperties.Length() == 1,
"Should have one animation property for a transition");
nsCSSProperty prop = anim->mProperties[0].mProperty;
nsCSSProperty prop = player->mProperties[0].mProperty;
if (nsCSSProps::PropHasFlags(prop, CSS_PROPERTY_REPORT_OTHER_NAME))
{
prop = nsCSSProps::OtherNameFor(prop);
}
events.AppendElement(
TransitionEventInfo(collection->mElement, prop,
anim->mTiming.mIterationDuration,
player->mTiming.mIterationDuration,
collection->PseudoElement()));
// Leave this transition in the list for one more refresh
@ -795,13 +795,13 @@ nsTransitionManager::FlushTransitions(FlushFlags aFlags)
// a non-animation style change that would affect it, we need
// to know not to start a new transition for the transition
// from the almost-completed value to the final value.
anim->SetFinishedTransition();
player->SetFinishedTransition();
collection->UpdateAnimationGeneration(mPresContext);
transitionStartedOrEnded = true;
} else if ((computedTiming.mPhase ==
ComputedTiming::AnimationPhase_Active) &&
canThrottleTick &&
!anim->mIsRunningOnCompositor) {
!player->mIsRunningOnCompositor) {
// Start a transition with a delay where we should start the
// transition proper.
collection->UpdateAnimationGeneration(mPresContext);
@ -825,7 +825,7 @@ nsTransitionManager::FlushTransitions(FlushFlags aFlags)
didThrottle = true;
}
if (collection->mAnimations.IsEmpty()) {
if (collection->mPlayers.IsEmpty()) {
collection->Destroy();
// |collection| is now a dangling pointer!
collection = nullptr;