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 baaeda5bee
commit adf45cac79

View File

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