| OLD | NEW |
| 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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 } | 184 } |
| 185 | 185 |
| 186 KeyframeAnimationEffect::KeyframeVector keyframes; | 186 KeyframeAnimationEffect::KeyframeVector keyframes; |
| 187 element->document()->styleResolver()->resolveKeyframes(element, styl
e, animationName.impl(), keyframes); | 187 element->document()->styleResolver()->resolveKeyframes(element, styl
e, animationName.impl(), keyframes); |
| 188 if (!keyframes.isEmpty()) { | 188 if (!keyframes.isEmpty()) { |
| 189 Timing timing; | 189 Timing timing; |
| 190 timingFromAnimationData(animationData, timing); | 190 timingFromAnimationData(animationData, timing); |
| 191 OwnPtr<CSSAnimations::EventDelegate> eventDelegate = adoptPtr(ne
w EventDelegate(element, animationName)); | 191 OwnPtr<CSSAnimations::EventDelegate> eventDelegate = adoptPtr(ne
w EventDelegate(element, animationName)); |
| 192 ASSERT(!isNull(element->document()->timeline()->currentTime())); | 192 ASSERT(!isNull(element->document()->timeline()->currentTime())); |
| 193 // FIXME: crbug.com/268791 - Keyframes are already normalized, p
erhaps there should be a flag on KeyframeAnimationEffect to skip normalization. | 193 // FIXME: crbug.com/268791 - Keyframes are already normalized, p
erhaps there should be a flag on KeyframeAnimationEffect to skip normalization. |
| 194 m_animations.set(animationName.impl(), element->document()->time
line()->play( | 194 RefPtr<Animation> animation = Animation::create(element, Keyfram
eAnimationEffect::create(keyframes), timing, eventDelegate.release()); |
| 195 Animation::create(element, KeyframeAnimationEffect::create(k
eyframes), timing, eventDelegate.release()).get()).get()); | 195 // If the start delay is zero, force a sample to make sure event
s fire. |
| 196 if (!timing.startDelay) |
| 197 animation->forceSampleBeforeStartTime(); |
| 198 m_animations.set(animationName.impl(), element->document()->time
line()->play(animation.get()).get()); |
| 196 } | 199 } |
| 197 } | 200 } |
| 198 } | 201 } |
| 199 | 202 |
| 200 for (HashSet<StringImpl*>::const_iterator iter = inactive.begin(); iter != i
nactive.end(); ++iter) | 203 for (HashSet<StringImpl*>::const_iterator iter = inactive.begin(); iter != i
nactive.end(); ++iter) |
| 201 m_animations.take(*iter)->cancel(); | 204 m_animations.take(*iter)->cancel(); |
| 202 } | 205 } |
| 203 | 206 |
| 204 void CSSAnimations::cancel() | 207 void CSSAnimations::cancel() |
| 205 { | 208 { |
| 206 for (AnimationMap::iterator iter = m_animations.begin(); iter != m_animation
s.end(); ++iter) | 209 for (AnimationMap::iterator iter = m_animations.begin(); iter != m_animation
s.end(); ++iter) |
| 207 iter->value->cancel(); | 210 iter->value->cancel(); |
| 208 | 211 |
| 209 m_animations.clear(); | 212 m_animations.clear(); |
| 210 } | 213 } |
| 211 | 214 |
| 212 void CSSAnimations::EventDelegate::maybeDispatch(Document::ListenerType listener
Type, AtomicString& eventName, double elapsedTime) | 215 void CSSAnimations::EventDelegate::maybeDispatch(Document::ListenerType listener
Type, AtomicString& eventName, double elapsedTime) |
| 213 { | 216 { |
| 214 if (m_target->document()->hasListenerType(listenerType)) | 217 if (m_target->document()->hasListenerType(listenerType)) |
| 215 m_target->document()->timeline()->addEventToDispatch(m_target, Animation
Event::create(eventName, m_name, elapsedTime)); | 218 m_target->document()->timeline()->addEventToDispatch(m_target, Animation
Event::create(eventName, m_name, elapsedTime)); |
| 216 } | 219 } |
| 217 | 220 |
| 218 void CSSAnimations::EventDelegate::onEventCondition(bool wasInPlay, bool isInPla
y, double previousIteration, double currentIteration) | 221 void CSSAnimations::EventDelegate::onEventCondition(bool wasInPlay, bool isInPla
y, bool wasCurrent, bool isCurrent, double previousIteration, double currentIter
ation) |
| 219 { | 222 { |
| 220 // Events for a single document are queued and dispatched as a group at | 223 // Events for a single document are queued and dispatched as a group at |
| 221 // the end of DocumentTimeline::serviceAnimations. | 224 // the end of DocumentTimeline::serviceAnimations. |
| 222 // FIXME: Events which are queued outside of serviceAnimations should | 225 // FIXME: Events which are queued outside of serviceAnimations should |
| 223 // trigger a timer to dispatch when control is released. | 226 // trigger a timer to dispatch when control is released. |
| 224 // FIXME: Receive TimedItem as param in order to produce correct elapsed tim
e value. | 227 // FIXME: Receive TimedItem as param in order to produce correct elapsed tim
e value. |
| 225 double elapsedTime = 0; | 228 double elapsedTime = 0; |
| 226 if (!wasInPlay && isInPlay) { | |
| 227 maybeDispatch(Document::ANIMATIONSTART_LISTENER, eventNames().webkitAnim
ationStartEvent, elapsedTime); | |
| 228 return; | |
| 229 } | |
| 230 if (wasInPlay && isInPlay && currentIteration != previousIteration) { | 229 if (wasInPlay && isInPlay && currentIteration != previousIteration) { |
| 231 maybeDispatch(Document::ANIMATIONITERATION_LISTENER, eventNames().webkit
AnimationIterationEvent, elapsedTime); | 230 maybeDispatch(Document::ANIMATIONITERATION_LISTENER, eventNames().webkit
AnimationIterationEvent, elapsedTime); |
| 232 return; | 231 return; |
| 233 } | 232 } |
| 234 if (wasInPlay && !isInPlay) { | 233 bool wasBefore = !wasInPlay && wasCurrent; |
| 234 bool isBefore = !isInPlay && isCurrent; |
| 235 if (wasBefore && !isBefore) |
| 236 maybeDispatch(Document::ANIMATIONSTART_LISTENER, eventNames().webkitAnim
ationStartEvent, elapsedTime); |
| 237 bool wasAfter = !wasInPlay && !wasCurrent; |
| 238 bool isAfter = !isInPlay && !isCurrent; |
| 239 if (!wasAfter && isAfter) |
| 235 maybeDispatch(Document::ANIMATIONEND_LISTENER, eventNames().webkitAnimat
ionEndEvent, elapsedTime); | 240 maybeDispatch(Document::ANIMATIONEND_LISTENER, eventNames().webkitAnimat
ionEndEvent, elapsedTime); |
| 236 return; | |
| 237 } | |
| 238 } | 241 } |
| 239 | 242 |
| 240 } // namespace WebCore | 243 } // namespace WebCore |
| OLD | NEW |