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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 #include "core/animation/KeyframeEffectModel.h" | 42 #include "core/animation/KeyframeEffectModel.h" |
| 43 #include "core/animation/PropertyHandle.h" | 43 #include "core/animation/PropertyHandle.h" |
| 44 #include "core/dom/Element.h" | 44 #include "core/dom/Element.h" |
| 45 #include "core/dom/NodeComputedStyle.h" | 45 #include "core/dom/NodeComputedStyle.h" |
| 46 #include "core/frame/UseCounter.h" | 46 #include "core/frame/UseCounter.h" |
| 47 #include "core/paint/DeprecatedPaintLayer.h" | 47 #include "core/paint/DeprecatedPaintLayer.h" |
| 48 #include "core/svg/SVGElement.h" | 48 #include "core/svg/SVGElement.h" |
| 49 | 49 |
| 50 namespace blink { | 50 namespace blink { |
| 51 | 51 |
| 52 PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* target, PassRefPtrW illBeRawPtr<AnimationEffect> effect, const Timing& timing, Priority priority, Pa ssOwnPtrWillBeRawPtr<EventDelegate> eventDelegate) | 52 Animation* Animation::create(Element* target, AnimationEffect* effect, const Tim ing& timing, Priority priority, EventDelegate* eventDelegate) |
| 53 { | 53 { |
| 54 return adoptRefWillBeNoop(new Animation(target, effect, timing, priority, ev entDelegate)); | 54 return new Animation(target, effect, timing, priority, eventDelegate); |
| 55 } | 55 } |
| 56 | 56 |
| 57 PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* element, const Vect or<Dictionary>& keyframeDictionaryVector, double duration, ExceptionState& excep tionState) | 57 Animation* Animation::create(Element* element, const Vector<Dictionary>& keyfram eDictionaryVector, double duration, ExceptionState& exceptionState) |
| 58 { | 58 { |
| 59 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); | 59 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); |
| 60 if (element) | 60 if (element) |
| 61 UseCounter::count(element->document(), UseCounter::AnimationConstructorK eyframeListEffectObjectTiming); | 61 UseCounter::count(element->document(), UseCounter::AnimationConstructorK eyframeListEffectObjectTiming); |
| 62 return create(element, EffectInput::convert(element, keyframeDictionaryVecto r, exceptionState), TimingInput::convert(duration)); | 62 return create(element, EffectInput::convert(element, keyframeDictionaryVecto r, exceptionState), TimingInput::convert(duration)); |
| 63 } | 63 } |
| 64 PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* element, const Vect or<Dictionary>& keyframeDictionaryVector, const AnimationTimingProperties& timin gInput, ExceptionState& exceptionState) | 64 Animation* Animation::create(Element* element, const Vector<Dictionary>& keyfram eDictionaryVector, const AnimationTimingProperties& timingInput, ExceptionState& exceptionState) |
| 65 { | 65 { |
| 66 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); | 66 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); |
| 67 if (element) | 67 if (element) |
| 68 UseCounter::count(element->document(), UseCounter::AnimationConstructorK eyframeListEffectObjectTiming); | 68 UseCounter::count(element->document(), UseCounter::AnimationConstructorK eyframeListEffectObjectTiming); |
| 69 return create(element, EffectInput::convert(element, keyframeDictionaryVecto r, exceptionState), TimingInput::convert(timingInput)); | 69 return create(element, EffectInput::convert(element, keyframeDictionaryVecto r, exceptionState), TimingInput::convert(timingInput)); |
| 70 } | 70 } |
| 71 PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* element, const Vect or<Dictionary>& keyframeDictionaryVector, ExceptionState& exceptionState) | 71 Animation* Animation::create(Element* element, const Vector<Dictionary>& keyfram eDictionaryVector, ExceptionState& exceptionState) |
| 72 { | 72 { |
| 73 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); | 73 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); |
| 74 if (element) | 74 if (element) |
| 75 UseCounter::count(element->document(), UseCounter::AnimationConstructorK eyframeListEffectNoTiming); | 75 UseCounter::count(element->document(), UseCounter::AnimationConstructorK eyframeListEffectNoTiming); |
| 76 return create(element, EffectInput::convert(element, keyframeDictionaryVecto r, exceptionState), Timing()); | 76 return create(element, EffectInput::convert(element, keyframeDictionaryVecto r, exceptionState), Timing()); |
| 77 } | 77 } |
| 78 | 78 |
| 79 Animation::Animation(Element* target, PassRefPtrWillBeRawPtr<AnimationEffect> ef fect, const Timing& timing, Priority priority, PassOwnPtrWillBeRawPtr<EventDeleg ate> eventDelegate) | 79 Animation::Animation(Element* target, AnimationEffect* effect, const Timing& tim ing, Priority priority, EventDelegate* eventDelegate) |
| 80 : AnimationNode(timing, eventDelegate) | 80 : AnimationNode(timing, eventDelegate) |
| 81 , m_target(target) | 81 , m_target(target) |
| 82 , m_effect(effect) | 82 , m_effect(effect) |
| 83 , m_sampledEffect(nullptr) | 83 , m_sampledEffect(nullptr) |
| 84 , m_priority(priority) | 84 , m_priority(priority) |
| 85 { | 85 { |
| 86 #if !ENABLE(OILPAN) | |
| 87 if (m_target) | |
| 88 m_target->ensureElementAnimations().addAnimation(this); | |
|
haraken
2015/05/08 00:13:06
You cannot remove this.
peria
2015/05/08 02:21:20
Acknowledged.
| |
| 89 #endif | |
| 90 } | 86 } |
| 91 | 87 |
| 92 Animation::~Animation() | 88 Animation::~Animation() |
| 93 { | 89 { |
| 94 #if !ENABLE(OILPAN) | |
| 95 if (m_target) | |
| 96 m_target->elementAnimations()->notifyAnimationDestroyed(this); | |
|
haraken
2015/05/08 00:13:06
Ditto.
peria
2015/05/08 02:21:20
Acknowledged.
| |
| 97 #endif | |
| 98 } | 90 } |
| 99 | 91 |
| 100 void Animation::attach(AnimationPlayer* player) | 92 void Animation::attach(AnimationPlayer* player) |
| 101 { | 93 { |
| 102 if (m_target) { | 94 if (m_target) { |
| 103 m_target->ensureElementAnimations().players().add(player); | 95 m_target->ensureElementAnimations().players().add(player); |
| 104 m_target->setNeedsAnimationStyleRecalc(); | 96 m_target->setNeedsAnimationStyleRecalc(); |
| 105 } | 97 } |
| 106 AnimationNode::attach(player); | 98 AnimationNode::attach(player); |
| 107 } | 99 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 // Cancel composited animation of transform if a motion path has been introd uced on the element. | 131 // Cancel composited animation of transform if a motion path has been introd uced on the element. |
| 140 if (m_target->computedStyle() | 132 if (m_target->computedStyle() |
| 141 && m_target->computedStyle()->hasMotionPath() | 133 && m_target->computedStyle()->hasMotionPath() |
| 142 && player()->hasActiveAnimationsOnCompositor() | 134 && player()->hasActiveAnimationsOnCompositor() |
| 143 && player()->affects(*m_target, CSSPropertyTransform)) { | 135 && player()->affects(*m_target, CSSPropertyTransform)) { |
| 144 player()->cancelAnimationOnCompositor(); | 136 player()->cancelAnimationOnCompositor(); |
| 145 } | 137 } |
| 146 | 138 |
| 147 double iteration = currentIteration(); | 139 double iteration = currentIteration(); |
| 148 ASSERT(iteration >= 0); | 140 ASSERT(iteration >= 0); |
| 149 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> inte rpolations = m_sampledEffect ? m_sampledEffect->mutableInterpolations() : nullpt r; | 141 HeapVector<Member<Interpolation>>* interpolations = m_sampledEffect ? m_samp ledEffect->mutableInterpolations() : nullptr; |
| 150 // FIXME: Handle iteration values which overflow int. | 142 // FIXME: Handle iteration values which overflow int. |
| 151 m_effect->sample(static_cast<int>(iteration), timeFraction(), iterationDurat ion(), interpolations); | 143 m_effect->sample(static_cast<int>(iteration), timeFraction(), iterationDurat ion(), interpolations); |
| 152 if (m_sampledEffect) { | 144 if (m_sampledEffect) { |
| 153 m_sampledEffect->setInterpolations(interpolations.release()); | 145 m_sampledEffect->setInterpolations(interpolations); |
| 154 } else if (interpolations && !interpolations->isEmpty()) { | 146 } else if (interpolations && !interpolations->isEmpty()) { |
| 155 OwnPtrWillBeRawPtr<SampledEffect> sampledEffect = SampledEffect::create( this, interpolations.release()); | 147 SampledEffect* sampledEffect = SampledEffect::create(this, interpolation s); |
| 156 m_sampledEffect = sampledEffect.get(); | 148 m_sampledEffect = sampledEffect; |
| 157 ensureAnimationStack(m_target).add(sampledEffect.release()); | 149 ensureAnimationStack(m_target).add(sampledEffect); |
| 158 } else { | 150 } else { |
| 159 return; | 151 return; |
| 160 } | 152 } |
| 161 | 153 |
| 162 m_target->setNeedsAnimationStyleRecalc(); | 154 m_target->setNeedsAnimationStyleRecalc(); |
| 163 if (m_target->isSVGElement()) | 155 if (m_target->isSVGElement()) |
| 164 m_sampledEffect->applySVGUpdate(toSVGElement(*m_target)); | 156 m_sampledEffect->applySVGUpdate(toSVGElement(*m_target)); |
| 165 } | 157 } |
| 166 | 158 |
| 167 void Animation::clearEffects() | 159 void Animation::clearEffects() |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 216 // that will be, however, so the parent will need to supply it. | 208 // that will be, however, so the parent will need to supply it. |
| 217 return forwards | 209 return forwards |
| 218 ? std::numeric_limits<double>::infinity() | 210 ? std::numeric_limits<double>::infinity() |
| 219 : localTime - end; | 211 : localTime - end; |
| 220 default: | 212 default: |
| 221 ASSERT_NOT_REACHED(); | 213 ASSERT_NOT_REACHED(); |
| 222 return std::numeric_limits<double>::infinity(); | 214 return std::numeric_limits<double>::infinity(); |
| 223 } | 215 } |
| 224 } | 216 } |
| 225 | 217 |
| 226 #if !ENABLE(OILPAN) | |
| 227 void Animation::notifyElementDestroyed() | |
|
haraken
2015/05/08 00:13:06
Ditto.
peria
2015/05/08 02:21:20
Acknowledged.
| |
| 228 { | |
| 229 // If our player is kept alive just by the sampledEffect, we might get our | |
| 230 // destructor called when we call SampledEffect::clear(), so we need to | |
| 231 // clear m_sampledEffect first. | |
| 232 m_target = nullptr; | |
| 233 clearEventDelegate(); | |
| 234 SampledEffect* sampledEffect = m_sampledEffect; | |
| 235 m_sampledEffect = nullptr; | |
| 236 if (sampledEffect) | |
| 237 sampledEffect->clear(); | |
| 238 } | |
| 239 #endif | |
| 240 | |
| 241 bool Animation::isCandidateForAnimationOnCompositor(double playerPlaybackRate) c onst | 218 bool Animation::isCandidateForAnimationOnCompositor(double playerPlaybackRate) c onst |
| 242 { | 219 { |
| 243 if (!effect() | 220 if (!effect() |
| 244 || !m_target | 221 || !m_target |
| 245 || (m_target->computedStyle() && m_target->computedStyle()->hasMotionPat h())) | 222 || (m_target->computedStyle() && m_target->computedStyle()->hasMotionPat h())) |
| 246 return false; | 223 return false; |
| 247 | 224 |
| 248 return CompositorAnimations::instance()->isCandidateForAnimationOnCompositor (specifiedTiming(), *m_target, player(), *effect(), playerPlaybackRate); | 225 return CompositorAnimations::instance()->isCandidateForAnimationOnCompositor (specifiedTiming(), *m_target, player(), *effect(), playerPlaybackRate); |
| 249 } | 226 } |
| 250 | 227 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 | 309 |
| 333 DEFINE_TRACE(Animation) | 310 DEFINE_TRACE(Animation) |
| 334 { | 311 { |
| 335 visitor->trace(m_target); | 312 visitor->trace(m_target); |
| 336 visitor->trace(m_effect); | 313 visitor->trace(m_effect); |
| 337 visitor->trace(m_sampledEffect); | 314 visitor->trace(m_sampledEffect); |
| 338 AnimationNode::trace(visitor); | 315 AnimationNode::trace(visitor); |
| 339 } | 316 } |
| 340 | 317 |
| 341 } // namespace blink | 318 } // namespace blink |
| OLD | NEW |