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 281fea9593df8aa436fe62b624b4f0408382af41..16a150f6242e8ea6a21276f7c98ef92e45ad6256 100644 |
| --- a/Source/core/animation/css/CSSAnimations.cpp |
| +++ b/Source/core/animation/css/CSSAnimations.cpp |
| @@ -182,8 +182,9 @@ void CSSAnimations::update(Element* element, const RenderStyle* style) |
| if (!keyframes.isEmpty()) { |
| Timing timing; |
| timingFromAnimationData(animationData, timing); |
| + OwnPtr<CSSAnimations::EventDelegate> eventDelegate = adoptPtr(new EventDelegate(element, animationName)); |
| m_animations.set(animationName.impl(), element->document()->timeline()->play( |
| - Animation::create(element, KeyframeAnimationEffect::create(keyframes), timing).get()).get()); |
| + Animation::create(element, KeyframeAnimationEffect::create(keyframes), timing, eventDelegate.release()).get()).get()); |
| } |
| } |
| } |
| @@ -200,4 +201,28 @@ void CSSAnimations::cancel() |
| m_animations.clear(); |
| } |
| +void CSSAnimations::EventDelegate::dispatch(Document::ListenerType listenerType, AtomicString& eventName, double elapsedTime) |
|
Steve Block
2013/08/06 05:29:12
Should this be called maybeDispatch(), as we only
dstockwell
2013/08/06 06:10:02
Done.
|
| +{ |
| + if (m_target->document()->hasListenerType(listenerType)) |
| + m_target->document()->timeline()->addEventToDispatch(m_target, AnimationEvent::create(eventName, m_name, elapsedTime)); |
|
Steve Block
2013/08/06 05:29:12
We receive the calls to EventDelegate::onEventCond
dstockwell
2013/08/06 06:10:02
Almost. Start events for new animations can be tri
|
| +} |
| + |
| +void CSSAnimations::EventDelegate::onEventCondition(bool wasInPlay, bool isInPlay, double previousIteration, double currentIteration) |
| +{ |
| + // FIXME: Receive TimedItem as param in order to produce correct elapsed time value. |
| + double elapsedTime = 0; |
| + if (!wasInPlay && isInPlay) { |
| + dispatch(Document::ANIMATIONSTART_LISTENER, eventNames().webkitAnimationStartEvent, elapsedTime); |
| + return; |
| + } |
| + if (wasInPlay && isInPlay && currentIteration != previousIteration) { |
| + dispatch(Document::ANIMATIONITERATION_LISTENER, eventNames().webkitAnimationIterationEvent, elapsedTime); |
| + return; |
| + } |
| + if (wasInPlay && !isInPlay) { |
| + dispatch(Document::ANIMATIONEND_LISTENER, eventNames().webkitAnimationEndEvent, elapsedTime); |
| + return; |
| + } |
| +} |
| + |
| } // namespace WebCore |