Bug 1004871 part 8 - Simplify ElementAnimations::GetEventsAt; r=dholbert

This patch shuffles the code in ElementAnimations::GetEventsAt to make it easier
to follow.

It also removes a check for whether or not the animation is paused.
Previously we would not dispatch events if the animation was paused and in its
active phase (but we would if the animation had finished). There doesn't seem to
be any reason for this. If the animation was paused between the last sample and
the current sample and the boundary of an iteration also occurred in that time
then I expect we should dispatch that event. Removing this check for the pause
state does not cause any tests fail.

Separating out the event logic here makes it clear that we do not dispatch start
events in the situation where one sample falls before the active interval and
one sample falls after it (filed as bug 1004361). This patch adds a comment to
this effect.
This commit is contained in:
Brian Birtles
2014-05-28 16:51:49 +09:00
parent bbb6e17384
commit ca93c49f2a

View File

@@ -315,16 +315,15 @@ ElementAnimations::GetEventsAt(TimeStamp aRefreshTime,
ComputedTiming computedTiming = ComputedTiming computedTiming =
GetPositionInIteration(elapsedDuration, anim->mTiming); GetPositionInIteration(elapsedDuration, anim->mTiming);
if (computedTiming.mPhase == ComputedTiming::AnimationPhase_After) { // FIXME: Bug 1004361: If our active duration is sufficiently short and our
// Dispatch 'animationend' when needed. // samples are sufficiently infrequent we will end up skipping the start
if (anim->mLastNotification != ElementAnimation::LAST_NOTIFICATION_END) { // event and jumping straight to the end event.
anim->mLastNotification = ElementAnimation::LAST_NOTIFICATION_END; switch (computedTiming.mPhase) {
AnimationEventInfo ei(mElement, anim->mName, NS_ANIMATION_END, case ComputedTiming::AnimationPhase_Before:
elapsedDuration, PseudoElement()); // Do nothing
aEventsToDispatch.AppendElement(ei); break;
}
} else if (computedTiming.mPhase == ComputedTiming::AnimationPhase_Active) { case ComputedTiming::AnimationPhase_Active:
if (!anim->IsPaused()) {
// Dispatch 'animationstart' or 'animationiteration' when needed. // Dispatch 'animationstart' or 'animationiteration' when needed.
if (computedTiming.mCurrentIteration != anim->mLastNotification) { if (computedTiming.mCurrentIteration != anim->mLastNotification) {
// Notify 'animationstart' even if a negative delay puts us // Notify 'animationstart' even if a negative delay puts us
@@ -342,7 +341,18 @@ ElementAnimations::GetEventsAt(TimeStamp aRefreshTime,
elapsedDuration, PseudoElement()); elapsedDuration, PseudoElement());
aEventsToDispatch.AppendElement(ei); aEventsToDispatch.AppendElement(ei);
} }
break;
case ComputedTiming::AnimationPhase_After:
// Dispatch 'animationend' when needed.
if (anim->mLastNotification !=
ElementAnimation::LAST_NOTIFICATION_END) {
anim->mLastNotification = ElementAnimation::LAST_NOTIFICATION_END;
AnimationEventInfo ei(mElement, anim->mName, NS_ANIMATION_END,
elapsedDuration, PseudoElement());
aEventsToDispatch.AppendElement(ei);
} }
break;
} }
} }
} }