| 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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 228 |
| 229 m_animations.clear(); | 229 m_animations.clear(); |
| 230 } | 230 } |
| 231 | 231 |
| 232 void CSSAnimations::EventDelegate::maybeDispatch(Document::ListenerType listener
Type, AtomicString& eventName, double elapsedTime) | 232 void CSSAnimations::EventDelegate::maybeDispatch(Document::ListenerType listener
Type, AtomicString& eventName, double elapsedTime) |
| 233 { | 233 { |
| 234 if (m_target->document()->hasListenerType(listenerType)) | 234 if (m_target->document()->hasListenerType(listenerType)) |
| 235 m_target->document()->timeline()->addEventToDispatch(m_target, Animation
Event::create(eventName, m_name, elapsedTime)); | 235 m_target->document()->timeline()->addEventToDispatch(m_target, Animation
Event::create(eventName, m_name, elapsedTime)); |
| 236 } | 236 } |
| 237 | 237 |
| 238 void CSSAnimations::EventDelegate::onEventCondition(bool isFirstSample, TimedIte
m::Phase previousPhase, TimedItem::Phase currentPhase, double previousIteration,
double currentIteration) | 238 void CSSAnimations::EventDelegate::onEventCondition(const TimedItem* timedItem,
bool isFirstSample, TimedItem::Phase previousPhase, double previousIteration) |
| 239 { | 239 { |
| 240 // Events for a single document are queued and dispatched as a group at | 240 // Events for a single document are queued and dispatched as a group at |
| 241 // the end of DocumentTimeline::serviceAnimations. | 241 // the end of DocumentTimeline::serviceAnimations. |
| 242 // FIXME: Events which are queued outside of serviceAnimations should | 242 // FIXME: Events which are queued outside of serviceAnimations should |
| 243 // trigger a timer to dispatch when control is released. | 243 // trigger a timer to dispatch when control is released. |
| 244 // FIXME: Receive TimedItem as param in order to produce correct elapsed tim
e value. | 244 const TimedItem::Phase currentPhase = timedItem->phase(); |
| 245 double elapsedTime = 0; | 245 const double currentIteration = timedItem->currentIteration(); |
| 246 |
| 247 // Note that the elapsedTime is measured from when the animation starts play
ing. |
| 246 if (!isFirstSample && previousPhase == TimedItem::PhaseActive && currentPhas
e == TimedItem::PhaseActive && previousIteration != currentIteration) { | 248 if (!isFirstSample && previousPhase == TimedItem::PhaseActive && currentPhas
e == TimedItem::PhaseActive && previousIteration != currentIteration) { |
| 247 ASSERT(!isNull(previousIteration)); | 249 ASSERT(!isNull(previousIteration)); |
| 248 ASSERT(!isNull(currentIteration)); | 250 ASSERT(!isNull(currentIteration)); |
| 251 // We fire only a single event for all iterations thast terminate |
| 252 // between a single pair of samples. See http://crbug.com/275263. For |
| 253 // compatibility with the existing implementation, this event uses |
| 254 // the elapsedTime for the first iteration in question. |
| 255 ASSERT(timedItem->specified().hasIterationDuration); |
| 256 const double elapsedTime = timedItem->specified().iterationDuration * (p
reviousIteration + 1); |
| 249 maybeDispatch(Document::ANIMATIONITERATION_LISTENER, eventNames().webkit
AnimationIterationEvent, elapsedTime); | 257 maybeDispatch(Document::ANIMATIONITERATION_LISTENER, eventNames().webkit
AnimationIterationEvent, elapsedTime); |
| 250 return; | 258 return; |
| 251 } | 259 } |
| 252 if ((isFirstSample || previousPhase == TimedItem::PhaseBefore) && isLaterPha
se(currentPhase, TimedItem::PhaseBefore)) | 260 if ((isFirstSample || previousPhase == TimedItem::PhaseBefore) && isLaterPha
se(currentPhase, TimedItem::PhaseBefore)) { |
| 253 maybeDispatch(Document::ANIMATIONSTART_LISTENER, eventNames().webkitAnim
ationStartEvent, elapsedTime); | 261 ASSERT(timedItem->specified().startDelay > 0 || isFirstSample); |
| 262 // The spec states that the elapsed time should be |
| 263 // 'delay < 0 ? -delay : 0', but we always use 0 to match the existing |
| 264 // implementation. See crbug.com/279611 |
| 265 maybeDispatch(Document::ANIMATIONSTART_LISTENER, eventNames().webkitAnim
ationStartEvent, 0); |
| 266 } |
| 254 if ((isFirstSample || isEarlierPhase(previousPhase, TimedItem::PhaseAfter))
&& currentPhase == TimedItem::PhaseAfter) | 267 if ((isFirstSample || isEarlierPhase(previousPhase, TimedItem::PhaseAfter))
&& currentPhase == TimedItem::PhaseAfter) |
| 255 maybeDispatch(Document::ANIMATIONEND_LISTENER, eventNames().webkitAnimat
ionEndEvent, elapsedTime); | 268 maybeDispatch(Document::ANIMATIONEND_LISTENER, eventNames().webkitAnimat
ionEndEvent, timedItem->activeDuration()); |
| 256 } | 269 } |
| 257 | 270 |
| 258 } // namespace WebCore | 271 } // namespace WebCore |
| OLD | NEW |