| 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 24 matching lines...) Expand all Loading... |
| 35 #include "core/animation/KeyframeAnimationEffect.h" | 35 #include "core/animation/KeyframeAnimationEffect.h" |
| 36 #include "core/css/CSSKeyframeRule.h" | 36 #include "core/css/CSSKeyframeRule.h" |
| 37 #include "core/css/resolver/StyleResolver.h" | 37 #include "core/css/resolver/StyleResolver.h" |
| 38 #include "core/dom/AnimationEvent.h" | 38 #include "core/dom/AnimationEvent.h" |
| 39 #include "core/dom/Element.h" | 39 #include "core/dom/Element.h" |
| 40 #include "core/dom/EventNames.h" | 40 #include "core/dom/EventNames.h" |
| 41 #include "core/platform/animation/CSSAnimationDataList.h" | 41 #include "core/platform/animation/CSSAnimationDataList.h" |
| 42 #include "core/platform/animation/TimingFunction.h" | 42 #include "core/platform/animation/TimingFunction.h" |
| 43 #include "wtf/HashSet.h" | 43 #include "wtf/HashSet.h" |
| 44 | 44 |
| 45 namespace { |
| 46 |
| 47 using namespace WebCore; |
| 48 |
| 49 bool isEarlierPhase(TimedItem::Phase target, TimedItem::Phase reference) |
| 50 { |
| 51 ASSERT(target != TimedItem::PhaseNone); |
| 52 ASSERT(reference != TimedItem::PhaseNone); |
| 53 return target < reference; |
| 54 } |
| 55 |
| 56 bool isLaterPhase(TimedItem::Phase target, TimedItem::Phase reference) |
| 57 { |
| 58 ASSERT(target != TimedItem::PhaseNone); |
| 59 ASSERT(reference != TimedItem::PhaseNone); |
| 60 return target > reference; |
| 61 } |
| 62 |
| 63 } // namespace |
| 64 |
| 45 namespace WebCore { | 65 namespace WebCore { |
| 46 | 66 |
| 47 void timingFromAnimationData(const CSSAnimationData* animationData, Timing& timi
ng) | 67 void timingFromAnimationData(const CSSAnimationData* animationData, Timing& timi
ng) |
| 48 { | 68 { |
| 49 if (animationData->isDelaySet()) | 69 if (animationData->isDelaySet()) |
| 50 timing.startDelay = animationData->delay(); | 70 timing.startDelay = animationData->delay(); |
| 51 if (animationData->isDurationSet()) { | 71 if (animationData->isDurationSet()) { |
| 52 timing.iterationDuration = animationData->duration(); | 72 timing.iterationDuration = animationData->duration(); |
| 53 timing.hasIterationDuration = true; | 73 timing.hasIterationDuration = true; |
| 54 } | 74 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 | 228 |
| 209 m_animations.clear(); | 229 m_animations.clear(); |
| 210 } | 230 } |
| 211 | 231 |
| 212 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) |
| 213 { | 233 { |
| 214 if (m_target->document()->hasListenerType(listenerType)) | 234 if (m_target->document()->hasListenerType(listenerType)) |
| 215 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)); |
| 216 } | 236 } |
| 217 | 237 |
| 218 void CSSAnimations::EventDelegate::onEventCondition(bool wasInPlay, bool isInPla
y, double previousIteration, double currentIteration) | 238 void CSSAnimations::EventDelegate::onEventCondition(bool isFirstSample, TimedIte
m::Phase previousPhase, TimedItem::Phase currentPhase, double previousIteration,
double currentIteration) |
| 219 { | 239 { |
| 220 // 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 |
| 221 // the end of DocumentTimeline::serviceAnimations. | 241 // the end of DocumentTimeline::serviceAnimations. |
| 222 // FIXME: Events which are queued outside of serviceAnimations should | 242 // FIXME: Events which are queued outside of serviceAnimations should |
| 223 // trigger a timer to dispatch when control is released. | 243 // trigger a timer to dispatch when control is released. |
| 224 // FIXME: Receive TimedItem as param in order to produce correct elapsed tim
e value. | 244 // FIXME: Receive TimedItem as param in order to produce correct elapsed tim
e value. |
| 225 double elapsedTime = 0; | 245 double elapsedTime = 0; |
| 226 if (!wasInPlay && isInPlay) { | 246 if (!isFirstSample && previousPhase == TimedItem::PhaseActive && currentPhas
e == TimedItem::PhaseActive && previousIteration != currentIteration) { |
| 227 maybeDispatch(Document::ANIMATIONSTART_LISTENER, eventNames().webkitAnim
ationStartEvent, elapsedTime); | 247 ASSERT(!isNull(previousIteration)); |
| 228 return; | 248 ASSERT(!isNull(currentIteration)); |
| 229 } | |
| 230 if (wasInPlay && isInPlay && currentIteration != previousIteration) { | |
| 231 maybeDispatch(Document::ANIMATIONITERATION_LISTENER, eventNames().webkit
AnimationIterationEvent, elapsedTime); | 249 maybeDispatch(Document::ANIMATIONITERATION_LISTENER, eventNames().webkit
AnimationIterationEvent, elapsedTime); |
| 232 return; | 250 return; |
| 233 } | 251 } |
| 234 if (wasInPlay && !isInPlay) { | 252 if ((isFirstSample || previousPhase == TimedItem::PhaseBefore) && isLaterPha
se(currentPhase, TimedItem::PhaseBefore)) |
| 253 maybeDispatch(Document::ANIMATIONSTART_LISTENER, eventNames().webkitAnim
ationStartEvent, elapsedTime); |
| 254 if ((isFirstSample || isEarlierPhase(previousPhase, TimedItem::PhaseAfter))
&& currentPhase == TimedItem::PhaseAfter) |
| 235 maybeDispatch(Document::ANIMATIONEND_LISTENER, eventNames().webkitAnimat
ionEndEvent, elapsedTime); | 255 maybeDispatch(Document::ANIMATIONEND_LISTENER, eventNames().webkitAnimat
ionEndEvent, elapsedTime); |
| 236 return; | |
| 237 } | |
| 238 } | 256 } |
| 239 | 257 |
| 240 } // namespace WebCore | 258 } // namespace WebCore |
| OLD | NEW |