Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 ASSERT(player()); |
| 54 m_target->removeActiveAnimation(this); | 56 if (m_activeInAnimationStack) |
| 57 player()->timeline()->animationStack().remove(m_target.get(), this); | |
| 55 } | 58 } |
| 56 | 59 |
| 57 void Animation::applyEffects(bool previouslyActiveOrInEffect) | 60 void Animation::applyEffects(bool previouslyActiveOrInEffect) |
| 58 { | 61 { |
| 62 ASSERT(player()); | |
| 59 if (!previouslyActiveOrInEffect) { | 63 if (!previouslyActiveOrInEffect) { |
| 60 m_target->addActiveAnimation(this); | 64 player()->timeline()->animationStack().add(m_target.get(), this); |
| 61 m_isInTargetActiveAnimationsList = true; | 65 m_activeInAnimationStack = true; |
| 62 } | 66 } |
| 63 m_compositableValues = m_effect->sample(currentIteration(), timeFraction()); | 67 m_compositableValues = m_effect->sample(currentIteration(), timeFraction()); |
| 64 m_target->setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRenderer); | 68 m_target->setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRenderer); |
| 65 } | 69 } |
| 66 | 70 |
| 67 void Animation::clearEffects() | 71 void Animation::clearEffects() |
| 68 { | 72 { |
| 69 m_target->removeActiveAnimation(this); | 73 ASSERT(player()); |
| 70 m_isInTargetActiveAnimationsList = false; | 74 player()->timeline()->animationStack().remove(m_target.get(), this); |
| 75 m_activeInAnimationStack = false; | |
|
shans
2013/07/17 06:25:28
reuse willDetach() here? Or add a detach() functio
dstockwell
2013/07/17 13:10:19
Done.
| |
| 71 m_compositableValues.clear(); | 76 m_compositableValues.clear(); |
| 72 } | 77 } |
| 73 | 78 |
| 74 void Animation::updateChildrenAndEffects(bool wasActiveOrInEffect) const | 79 void Animation::updateChildrenAndEffects(bool wasActiveOrInEffect) const |
| 75 { | 80 { |
| 76 const bool isActiveOrInEffect = isActive() || isInEffect(); | 81 const bool isActiveOrInEffect = isActive() || isInEffect(); |
| 77 ASSERT(m_isInTargetActiveAnimationsList == wasActiveOrInEffect); | 82 ASSERT(m_activeInAnimationStack == wasActiveOrInEffect); |
| 78 if (wasActiveOrInEffect && !isActiveOrInEffect) | 83 if (wasActiveOrInEffect && !isActiveOrInEffect) |
| 79 const_cast<Animation*>(this)->clearEffects(); | 84 const_cast<Animation*>(this)->clearEffects(); |
| 80 else if (isActiveOrInEffect) | 85 else if (isActiveOrInEffect) |
| 81 const_cast<Animation*>(this)->applyEffects(wasActiveOrInEffect); | 86 const_cast<Animation*>(this)->applyEffects(wasActiveOrInEffect); |
| 82 } | 87 } |
| 83 | 88 |
| 84 } // namespace WebCore | 89 } // namespace WebCore |
| OLD | NEW |