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

Side by Side 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: Address feedback. 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/animation/css/CSSAnimations.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 existing->value->setPaused(paused); 175 existing->value->setPaused(paused);
176 inactive.remove(animationName.impl()); 176 inactive.remove(animationName.impl());
177 continue; 177 continue;
178 } 178 }
179 179
180 KeyframeAnimationEffect::KeyframeVector keyframes; 180 KeyframeAnimationEffect::KeyframeVector keyframes;
181 element->document()->styleResolver()->resolveKeyframes(element, styl e, animationName.impl(), keyframes); 181 element->document()->styleResolver()->resolveKeyframes(element, styl e, animationName.impl(), keyframes);
182 if (!keyframes.isEmpty()) { 182 if (!keyframes.isEmpty()) {
183 Timing timing; 183 Timing timing;
184 timingFromAnimationData(animationData, timing); 184 timingFromAnimationData(animationData, timing);
185 OwnPtr<CSSAnimations::EventDelegate> eventDelegate = adoptPtr(ne w EventDelegate(element, animationName));
185 m_animations.set(animationName.impl(), element->document()->time line()->play( 186 m_animations.set(animationName.impl(), element->document()->time line()->play(
186 Animation::create(element, KeyframeAnimationEffect::create(k eyframes), timing).get()).get()); 187 Animation::create(element, KeyframeAnimationEffect::create(k eyframes), timing, eventDelegate.release()).get()).get());
187 } 188 }
188 } 189 }
189 } 190 }
190 191
191 for (HashSet<StringImpl*>::const_iterator iter = inactive.begin(); iter != i nactive.end(); ++iter) 192 for (HashSet<StringImpl*>::const_iterator iter = inactive.begin(); iter != i nactive.end(); ++iter)
192 m_animations.take(*iter)->cancel(); 193 m_animations.take(*iter)->cancel();
193 } 194 }
194 195
195 void CSSAnimations::cancel() 196 void CSSAnimations::cancel()
196 { 197 {
197 for (AnimationMap::iterator iter = m_animations.begin(); iter != m_animation s.end(); ++iter) 198 for (AnimationMap::iterator iter = m_animations.begin(); iter != m_animation s.end(); ++iter)
198 iter->value->cancel(); 199 iter->value->cancel();
199 200
200 m_animations.clear(); 201 m_animations.clear();
201 } 202 }
202 203
204 void CSSAnimations::EventDelegate::maybeDispatch(Document::ListenerType listener Type, AtomicString& eventName, double elapsedTime)
205 {
206 if (m_target->document()->hasListenerType(listenerType))
207 m_target->document()->timeline()->addEventToDispatch(m_target, Animation Event::create(eventName, m_name, elapsedTime));
208 }
209
210 void CSSAnimations::EventDelegate::onEventCondition(bool wasInPlay, bool isInPla y, double previousIteration, double currentIteration)
211 {
212 // Events for a single document are queued and dispatched as a group at
213 // the end of DocumentTimeline::serviceAnimations.
214 // FIXME: Events which are queued outside of serviceAnimations should
215 // trigger a timer to dispatch when control is released.
216 // FIXME: Receive TimedItem as param in order to produce correct elapsed tim e value.
217 double elapsedTime = 0;
218 if (!wasInPlay && isInPlay) {
219 maybeDispatch(Document::ANIMATIONSTART_LISTENER, eventNames().webkitAnim ationStartEvent, elapsedTime);
220 return;
221 }
222 if (wasInPlay && isInPlay && currentIteration != previousIteration) {
223 maybeDispatch(Document::ANIMATIONITERATION_LISTENER, eventNames().webkit AnimationIterationEvent, elapsedTime);
224 return;
225 }
226 if (wasInPlay && !isInPlay) {
227 maybeDispatch(Document::ANIMATIONEND_LISTENER, eventNames().webkitAnimat ionEndEvent, elapsedTime);
228 return;
229 }
230 }
231
203 } // namespace WebCore 232 } // namespace WebCore
OLDNEW
« 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