Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Unified Diff: Source/core/animation/css/CSSAnimations.cpp

Issue 22123002: Web Animations: Implement CSS Animation events (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/animation/css/CSSAnimations.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « Source/core/animation/css/CSSAnimations.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698