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

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

Issue 23039013: Web Animations: Fix elpasedTime in animation events (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed elapsedTime for negative delay and added a test 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
« no previous file with comments | « Source/core/animation/css/CSSAnimations.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/animation/css/CSSAnimations.cpp
diff --git a/Source/core/animation/css/CSSAnimations.cpp b/Source/core/animation/css/CSSAnimations.cpp
index 444d015839363043270db20e492a1cb4440a78e0..c8eb78a5977032c4dde8fc332b1fcb1701bf6336 100644
--- a/Source/core/animation/css/CSSAnimations.cpp
+++ b/Source/core/animation/css/CSSAnimations.cpp
@@ -235,24 +235,37 @@ 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 isFirstSample, TimedItem::Phase previousPhase, TimedItem::Phase currentPhase, double previousIteration, double currentIteration)
+void CSSAnimations::EventDelegate::onEventCondition(const TimedItem* timedItem, bool isFirstSample, TimedItem::Phase previousPhase, double previousIteration)
{
// Events for a single document are queued and dispatched as a group at
// the end of DocumentTimeline::serviceAnimations.
// FIXME: Events which are queued outside of serviceAnimations should
// 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;
+ const TimedItem::Phase currentPhase = timedItem->phase();
+ const double currentIteration = timedItem->currentIteration();
+
+ // Note that the elapsedTime is measured from when the animation starts playing.
if (!isFirstSample && previousPhase == TimedItem::PhaseActive && currentPhase == TimedItem::PhaseActive && previousIteration != currentIteration) {
ASSERT(!isNull(previousIteration));
ASSERT(!isNull(currentIteration));
+ // We fire only a single event for all iterations thast terminate
+ // between a single pair of samples. See http://crbug.com/275263. For
+ // compatibility with the existing implementation, this event uses
+ // the elapsedTime for the first iteration in question.
+ ASSERT(timedItem->specified().hasIterationDuration);
+ const double elapsedTime = timedItem->specified().iterationDuration * (previousIteration + 1);
maybeDispatch(Document::ANIMATIONITERATION_LISTENER, eventNames().webkitAnimationIterationEvent, elapsedTime);
return;
}
- if ((isFirstSample || previousPhase == TimedItem::PhaseBefore) && isLaterPhase(currentPhase, TimedItem::PhaseBefore))
- maybeDispatch(Document::ANIMATIONSTART_LISTENER, eventNames().webkitAnimationStartEvent, elapsedTime);
+ if ((isFirstSample || previousPhase == TimedItem::PhaseBefore) && isLaterPhase(currentPhase, TimedItem::PhaseBefore)) {
+ ASSERT(timedItem->specified().startDelay > 0 || isFirstSample);
+ // The spec states that the elapsed time should be
+ // 'delay < 0 ? -delay : 0', but we always use 0 to match the existing
+ // implementation. See crbug.com/279611
+ maybeDispatch(Document::ANIMATIONSTART_LISTENER, eventNames().webkitAnimationStartEvent, 0);
+ }
if ((isFirstSample || isEarlierPhase(previousPhase, TimedItem::PhaseAfter)) && currentPhase == TimedItem::PhaseAfter)
- maybeDispatch(Document::ANIMATIONEND_LISTENER, eventNames().webkitAnimationEndEvent, elapsedTime);
+ maybeDispatch(Document::ANIMATIONEND_LISTENER, eventNames().webkitAnimationEndEvent, timedItem->activeDuration());
}
} // namespace WebCore
« no previous file with comments | « Source/core/animation/css/CSSAnimations.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698