Chromium Code Reviews| 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 // compatitbility with the existing implementation, this event uses | |
|
dstockwell
2013/08/22 07:32:58
compatibility
Steve Block
2013/08/27 05:04:00
Done.
| |
| 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)) { |
| 261 ASSERT(timedItem->specified().startDelay > 0 || isFirstSample); | |
| 262 const double elapsedTime = timedItem->specified().startDelay < 0 ? -time dItem->specified().startDelay : 0; | |
|
dstockwell
2013/08/22 07:32:58
Should we clamp this to activeDuration?
Steve Block
2013/08/27 05:04:00
Hmmm, the spec doesn't make this clear. In any cas
| |
| 253 maybeDispatch(Document::ANIMATIONSTART_LISTENER, eventNames().webkitAnim ationStartEvent, elapsedTime); | 263 maybeDispatch(Document::ANIMATIONSTART_LISTENER, eventNames().webkitAnim ationStartEvent, elapsedTime); |
| 264 } | |
| 254 if ((isFirstSample || isEarlierPhase(previousPhase, TimedItem::PhaseAfter)) && currentPhase == TimedItem::PhaseAfter) | 265 if ((isFirstSample || isEarlierPhase(previousPhase, TimedItem::PhaseAfter)) && currentPhase == TimedItem::PhaseAfter) |
| 255 maybeDispatch(Document::ANIMATIONEND_LISTENER, eventNames().webkitAnimat ionEndEvent, elapsedTime); | 266 maybeDispatch(Document::ANIMATIONEND_LISTENER, eventNames().webkitAnimat ionEndEvent, timedItem->activeDuration()); |
| 256 } | 267 } |
| 257 | 268 |
| 258 } // namespace WebCore | 269 } // namespace WebCore |
| OLD | NEW |