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

Side by Side Diff: Source/core/animation/Animation.cpp

Issue 19266007: Web Animations: Introduce ActiveAnimations and AnimationStack (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased. Created 7 years, 5 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
« no previous file with comments | « Source/core/animation/Animation.h ('k') | Source/core/animation/AnimationStack.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/animation/Animation.h" 32 #include "core/animation/Animation.h"
33 33
34 #include "core/animation/DocumentTimeline.h"
35 #include "core/animation/Player.h"
34 #include "core/dom/Element.h" 36 #include "core/dom/Element.h"
35 37
36 namespace WebCore { 38 namespace WebCore {
37 39
38 PassRefPtr<Animation> Animation::create(PassRefPtr<Element> target, PassRefPtr<A nimationEffect> effect, const Timing& timing) 40 PassRefPtr<Animation> Animation::create(PassRefPtr<Element> target, PassRefPtr<A nimationEffect> effect, const Timing& timing)
39 { 41 {
40 return adoptRef(new Animation(target, effect, timing)); 42 return adoptRef(new Animation(target, effect, timing));
41 } 43 }
42 44
43 Animation::Animation(PassRefPtr<Element> target, PassRefPtr<AnimationEffect> eff ect, const Timing& timing) 45 Animation::Animation(PassRefPtr<Element> target, PassRefPtr<AnimationEffect> eff ect, const Timing& timing)
44 : TimedItem(timing) 46 : TimedItem(timing)
45 , m_target(target) 47 , m_target(target)
46 , m_effect(effect) 48 , m_effect(effect)
47 , m_isInTargetActiveAnimationsList(false) 49 , m_activeInAnimationStack(false)
48 { 50 {
49 } 51 }
50 52
51 Animation::~Animation() 53 void Animation::willDetach()
52 { 54 {
53 if (m_isInTargetActiveAnimationsList) 55 if (m_activeInAnimationStack)
54 m_target->removeActiveAnimation(this); 56 clearEffects();
57 }
58
59 static AnimationStack* ensureAnimationStack(Element* element)
60 {
61 return element->ensureActiveAnimations()->defaultStack();
55 } 62 }
56 63
57 void Animation::applyEffects(bool previouslyActiveOrInEffect) 64 void Animation::applyEffects(bool previouslyActiveOrInEffect)
58 { 65 {
66 ASSERT(player());
59 if (!previouslyActiveOrInEffect) { 67 if (!previouslyActiveOrInEffect) {
60 m_target->addActiveAnimation(this); 68 ensureAnimationStack(m_target.get())->add(this);
61 m_isInTargetActiveAnimationsList = true; 69 m_activeInAnimationStack = true;
62 } 70 }
63 m_compositableValues = m_effect->sample(currentIteration(), timeFraction()); 71 m_compositableValues = m_effect->sample(currentIteration(), timeFraction());
64 m_target->setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRenderer); 72 m_target->setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRenderer);
65 } 73 }
66 74
67 void Animation::clearEffects() 75 void Animation::clearEffects()
68 { 76 {
69 m_target->removeActiveAnimation(this); 77 ASSERT(player());
70 m_isInTargetActiveAnimationsList = false; 78 ASSERT(m_activeInAnimationStack);
79 ensureAnimationStack(m_target.get())->remove(this);
80 m_activeInAnimationStack = false;
71 m_compositableValues.clear(); 81 m_compositableValues.clear();
72 } 82 }
73 83
74 void Animation::updateChildrenAndEffects(bool wasActiveOrInEffect) const 84 void Animation::updateChildrenAndEffects(bool wasActiveOrInEffect) const
75 { 85 {
76 const bool isActiveOrInEffect = isActive() || isInEffect(); 86 const bool isActiveOrInEffect = isActive() || isInEffect();
77 ASSERT(m_isInTargetActiveAnimationsList == wasActiveOrInEffect); 87 ASSERT(m_activeInAnimationStack == wasActiveOrInEffect);
78 if (wasActiveOrInEffect && !isActiveOrInEffect) 88 if (wasActiveOrInEffect && !isActiveOrInEffect)
79 const_cast<Animation*>(this)->clearEffects(); 89 const_cast<Animation*>(this)->clearEffects();
80 else if (isActiveOrInEffect) 90 else if (isActiveOrInEffect)
81 const_cast<Animation*>(this)->applyEffects(wasActiveOrInEffect); 91 const_cast<Animation*>(this)->applyEffects(wasActiveOrInEffect);
82 } 92 }
83 93
84 } // namespace WebCore 94 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/animation/Animation.h ('k') | Source/core/animation/AnimationStack.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698