Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Unified Diff: Source/core/animation/css/CSSAnimations.cpp

Issue 23173007: Web Animations: Fix CSS events to handle animations with very short durations (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« Source/core/animation/TimedItem.cpp ('K') | « Source/core/animation/css/CSSAnimations.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698