Chromium Code Reviews| Index: Source/core/animation/css/CSSAnimations.cpp |
| diff --git a/Source/core/animation/css/CSSAnimations.cpp b/Source/core/animation/css/CSSAnimations.cpp |
| index 444d015839363043270db20e492a1cb4440a78e0..04fa077ceb8c374ecf6c4dd11c2385ac868ea107 100644 |
| --- a/Source/core/animation/css/CSSAnimations.cpp |
| +++ b/Source/core/animation/css/CSSAnimations.cpp |
| @@ -235,24 +235,35 @@ void CSSAnimations::EventDelegate::maybeDispatch(Document::ListenerType listener |
| m_target->document()->timeline()->addEventToDispatch(m_target, AnimationEvent::create(eventName, m_name, elapsedTime)); |
| } |
| -void CSSAnimations::EventDelegate::onEventCondition(bool isFirstSample, TimedItem::Phase previousPhase, TimedItem::Phase currentPhase, double previousIteration, double currentIteration) |
| +void CSSAnimations::EventDelegate::onEventCondition(const TimedItem* timedItem, bool isFirstSample, TimedItem::Phase previousPhase, double previousIteration) |
| { |
| // Events for a single document are queued and dispatched as a group at |
| // the end of DocumentTimeline::serviceAnimations. |
| // FIXME: Events which are queued outside of serviceAnimations should |
| // trigger a timer to dispatch when control is released. |
| - // FIXME: Receive TimedItem as param in order to produce correct elapsed time value. |
| - double elapsedTime = 0; |
| + const TimedItem::Phase currentPhase = timedItem->phase(); |
| + const double currentIteration = timedItem->currentIteration(); |
| + |
| + // Note that the elapsedTime is measured from when the animation starts playing. |
| if (!isFirstSample && previousPhase == TimedItem::PhaseActive && currentPhase == TimedItem::PhaseActive && previousIteration != currentIteration) { |
| ASSERT(!isNull(previousIteration)); |
| ASSERT(!isNull(currentIteration)); |
| + // We fire only a single event for all iterations thast terminate |
| + // between a single pair of samples. See http://crbug.com/275263. For |
| + // compatitbility with the existing implementation, this event uses |
|
dstockwell
2013/08/22 07:32:58
compatibility
Steve Block
2013/08/27 05:04:00
Done.
|
| + // the elapsedTime for the first iteration in question. |
| + ASSERT(timedItem->specified().hasIterationDuration); |
| + const double elapsedTime = timedItem->specified().iterationDuration * (previousIteration + 1); |
| maybeDispatch(Document::ANIMATIONITERATION_LISTENER, eventNames().webkitAnimationIterationEvent, elapsedTime); |
| return; |
| } |
| - if ((isFirstSample || previousPhase == TimedItem::PhaseBefore) && isLaterPhase(currentPhase, TimedItem::PhaseBefore)) |
| + if ((isFirstSample || previousPhase == TimedItem::PhaseBefore) && isLaterPhase(currentPhase, TimedItem::PhaseBefore)) { |
| + ASSERT(timedItem->specified().startDelay > 0 || isFirstSample); |
| + const double elapsedTime = timedItem->specified().startDelay < 0 ? -timedItem->specified().startDelay : 0; |
|
dstockwell
2013/08/22 07:32:58
Should we clamp this to activeDuration?
Steve Block
2013/08/27 05:04:00
Hmmm, the spec doesn't make this clear. In any cas
|
| maybeDispatch(Document::ANIMATIONSTART_LISTENER, eventNames().webkitAnimationStartEvent, elapsedTime); |
| + } |
| if ((isFirstSample || isEarlierPhase(previousPhase, TimedItem::PhaseAfter)) && currentPhase == TimedItem::PhaseAfter) |
| - maybeDispatch(Document::ANIMATIONEND_LISTENER, eventNames().webkitAnimationEndEvent, elapsedTime); |
| + maybeDispatch(Document::ANIMATIONEND_LISTENER, eventNames().webkitAnimationEndEvent, timedItem->activeDuration()); |
| } |
| } // namespace WebCore |