| Index: Source/core/animation/css/CSSAnimations.cpp
|
| diff --git a/Source/core/animation/css/CSSAnimations.cpp b/Source/core/animation/css/CSSAnimations.cpp
|
| index b3358ea2f2663d0ff71422e4fbc9c34b39e94fe6..5bbde26e9122da361a3ba401c5e5ec07bceb94a1 100644
|
| --- a/Source/core/animation/css/CSSAnimations.cpp
|
| +++ b/Source/core/animation/css/CSSAnimations.cpp
|
| @@ -191,8 +191,11 @@ void CSSAnimations::update(Element* element, const RenderStyle* style)
|
| OwnPtr<CSSAnimations::EventDelegate> eventDelegate = adoptPtr(new EventDelegate(element, animationName));
|
| ASSERT(!isNull(element->document()->timeline()->currentTime()));
|
| // FIXME: crbug.com/268791 - Keyframes are already normalized, perhaps there should be a flag on KeyframeAnimationEffect to skip normalization.
|
| - m_animations.set(animationName.impl(), element->document()->timeline()->play(
|
| - Animation::create(element, KeyframeAnimationEffect::create(keyframes), timing, eventDelegate.release()).get()).get());
|
| + RefPtr<Animation> animation = Animation::create(element, KeyframeAnimationEffect::create(keyframes), timing, eventDelegate.release());
|
| + // If the start delay is zero, force a sample to make sure events fire.
|
| + if (!timing.startDelay)
|
| + animation->forceSampleBeforeStartTime();
|
| + m_animations.set(animationName.impl(), element->document()->timeline()->play(animation.get()).get());
|
| }
|
| }
|
| }
|
| @@ -215,7 +218,7 @@ void CSSAnimations::EventDelegate::maybeDispatch(Document::ListenerType listener
|
| m_target->document()->timeline()->addEventToDispatch(m_target, AnimationEvent::create(eventName, m_name, elapsedTime));
|
| }
|
|
|
| -void CSSAnimations::EventDelegate::onEventCondition(bool wasInPlay, bool isInPlay, double previousIteration, double currentIteration)
|
| +void CSSAnimations::EventDelegate::onEventCondition(bool wasInPlay, bool isInPlay, bool wasCurrent, bool isCurrent, double previousIteration, double currentIteration)
|
| {
|
| // Events for a single document are queued and dispatched as a group at
|
| // the end of DocumentTimeline::serviceAnimations.
|
| @@ -223,18 +226,18 @@ void CSSAnimations::EventDelegate::onEventCondition(bool wasInPlay, bool isInPla
|
| // trigger a timer to dispatch when control is released.
|
| // FIXME: Receive TimedItem as param in order to produce correct elapsed time value.
|
| double elapsedTime = 0;
|
| - if (!wasInPlay && isInPlay) {
|
| - maybeDispatch(Document::ANIMATIONSTART_LISTENER, eventNames().webkitAnimationStartEvent, elapsedTime);
|
| - return;
|
| - }
|
| if (wasInPlay && isInPlay && currentIteration != previousIteration) {
|
| maybeDispatch(Document::ANIMATIONITERATION_LISTENER, eventNames().webkitAnimationIterationEvent, elapsedTime);
|
| return;
|
| }
|
| - if (wasInPlay && !isInPlay) {
|
| + bool wasBefore = !wasInPlay && wasCurrent;
|
| + bool isBefore = !isInPlay && isCurrent;
|
| + if (wasBefore && !isBefore)
|
| + maybeDispatch(Document::ANIMATIONSTART_LISTENER, eventNames().webkitAnimationStartEvent, elapsedTime);
|
| + bool wasAfter = !wasInPlay && !wasCurrent;
|
| + bool isAfter = !isInPlay && !isCurrent;
|
| + if (!wasAfter && isAfter)
|
| maybeDispatch(Document::ANIMATIONEND_LISTENER, eventNames().webkitAnimationEndEvent, elapsedTime);
|
| - return;
|
| - }
|
| }
|
|
|
| } // namespace WebCore
|
|
|