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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 phase, double previousIteration, double currentIteration)
dstockwell 2013/08/21 06:21:53 phase -> currentPhase or currentIteration -> itera
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 (previousPhase == TimedItem::PhaseActive && phase == TimedItem::PhaseActi ve && previousIteration != currentIteration) {
227 maybeDispatch(Document::ANIMATIONSTART_LISTENER, eventNames().webkitAnim ationStartEvent, elapsedTime);
228 return;
229 }
230 if (wasInPlay && isInPlay && currentIteration != previousIteration) {
231 maybeDispatch(Document::ANIMATIONITERATION_LISTENER, eventNames().webkit AnimationIterationEvent, elapsedTime); 247 maybeDispatch(Document::ANIMATIONITERATION_LISTENER, eventNames().webkit AnimationIterationEvent, elapsedTime);
232 return; 248 return;
233 } 249 }
234 if (wasInPlay && !isInPlay) { 250 if ((isFirstSample || previousPhase == TimedItem::PhaseBefore) && isLaterPha se(phase, TimedItem::PhaseBefore))
251 maybeDispatch(Document::ANIMATIONSTART_LISTENER, eventNames().webkitAnim ationStartEvent, elapsedTime);
252 if ((isFirstSample || isEarlierPhase(previousPhase, TimedItem::PhaseAfter)) && phase == TimedItem::PhaseAfter)
235 maybeDispatch(Document::ANIMATIONEND_LISTENER, eventNames().webkitAnimat ionEndEvent, elapsedTime); 253 maybeDispatch(Document::ANIMATIONEND_LISTENER, eventNames().webkitAnimat ionEndEvent, elapsedTime);
236 return;
237 }
238 } 254 }
239 255
240 } // namespace WebCore 256 } // namespace WebCore
OLDNEW
« Source/core/animation/TimedItemTest.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