| 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 28 matching lines...) Expand all Loading... |
| 39 #include "core/animation/CompositorAnimations.h" | 39 #include "core/animation/CompositorAnimations.h" |
| 40 #include "core/animation/DocumentTimeline.h" | 40 #include "core/animation/DocumentTimeline.h" |
| 41 #include "core/animation/Interpolation.h" | 41 #include "core/animation/Interpolation.h" |
| 42 #include "core/animation/KeyframeEffectModel.h" | 42 #include "core/animation/KeyframeEffectModel.h" |
| 43 #include "core/dom/Element.h" | 43 #include "core/dom/Element.h" |
| 44 #include "core/frame/UseCounter.h" | 44 #include "core/frame/UseCounter.h" |
| 45 #include "core/rendering/RenderLayer.h" | 45 #include "core/rendering/RenderLayer.h" |
| 46 | 46 |
| 47 namespace WebCore { | 47 namespace WebCore { |
| 48 | 48 |
| 49 PassRefPtr<Animation> Animation::create(Element* target, PassRefPtrWillBeRawPtr<
AnimationEffect> effect, const Timing& timing, Priority priority, PassOwnPtr<Eve
ntDelegate> eventDelegate) | 49 PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* target, PassRefPtrW
illBeRawPtr<AnimationEffect> effect, const Timing& timing, Priority priority, Pa
ssOwnPtr<EventDelegate> eventDelegate) |
| 50 { | 50 { |
| 51 return adoptRef(new Animation(target, effect, timing, priority, eventDelegat
e)); | 51 return adoptRefWillBeNoop(new Animation(target, effect, timing, priority, ev
entDelegate)); |
| 52 } | 52 } |
| 53 | 53 |
| 54 PassRefPtr<Animation> Animation::create(Element* element, PassRefPtrWillBeRawPtr
<AnimationEffect> effect, const Dictionary& timingInputDictionary) | 54 PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* element, PassRefPtr
WillBeRawPtr<AnimationEffect> effect, const Dictionary& timingInputDictionary) |
| 55 { | 55 { |
| 56 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); | 56 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); |
| 57 return create(element, effect, TimingInput::convert(timingInputDictionary)); | 57 return create(element, effect, TimingInput::convert(timingInputDictionary)); |
| 58 } | 58 } |
| 59 PassRefPtr<Animation> Animation::create(Element* element, PassRefPtrWillBeRawPtr
<AnimationEffect> effect, double duration) | 59 PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* element, PassRefPtr
WillBeRawPtr<AnimationEffect> effect, double duration) |
| 60 { | 60 { |
| 61 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); | 61 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); |
| 62 return create(element, effect, TimingInput::convert(duration)); | 62 return create(element, effect, TimingInput::convert(duration)); |
| 63 } | 63 } |
| 64 PassRefPtr<Animation> Animation::create(Element* element, PassRefPtrWillBeRawPtr
<AnimationEffect> effect) | 64 PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* element, PassRefPtr
WillBeRawPtr<AnimationEffect> effect) |
| 65 { | 65 { |
| 66 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); | 66 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); |
| 67 return create(element, effect, Timing()); | 67 return create(element, effect, Timing()); |
| 68 } | 68 } |
| 69 PassRefPtr<Animation> Animation::create(Element* element, const Vector<Dictionar
y>& keyframeDictionaryVector, const Dictionary& timingInputDictionary, Exception
State& exceptionState) | 69 PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* element, const Vect
or<Dictionary>& keyframeDictionaryVector, const Dictionary& timingInputDictionar
y, ExceptionState& exceptionState) |
| 70 { | 70 { |
| 71 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); | 71 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); |
| 72 if (element) | 72 if (element) |
| 73 UseCounter::count(element->document(), UseCounter::AnimationConstructorK
eyframeListEffectObjectTiming); | 73 UseCounter::count(element->document(), UseCounter::AnimationConstructorK
eyframeListEffectObjectTiming); |
| 74 return create(element, EffectInput::convert(element, keyframeDictionaryVecto
r, exceptionState), TimingInput::convert(timingInputDictionary)); | 74 return create(element, EffectInput::convert(element, keyframeDictionaryVecto
r, exceptionState), TimingInput::convert(timingInputDictionary)); |
| 75 } | 75 } |
| 76 PassRefPtr<Animation> Animation::create(Element* element, const Vector<Dictionar
y>& keyframeDictionaryVector, double duration, ExceptionState& exceptionState) | 76 PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* element, const Vect
or<Dictionary>& keyframeDictionaryVector, double duration, ExceptionState& excep
tionState) |
| 77 { | 77 { |
| 78 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); | 78 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); |
| 79 if (element) | 79 if (element) |
| 80 UseCounter::count(element->document(), UseCounter::AnimationConstructorK
eyframeListEffectDoubleTiming); | 80 UseCounter::count(element->document(), UseCounter::AnimationConstructorK
eyframeListEffectDoubleTiming); |
| 81 return create(element, EffectInput::convert(element, keyframeDictionaryVecto
r, exceptionState), TimingInput::convert(duration)); | 81 return create(element, EffectInput::convert(element, keyframeDictionaryVecto
r, exceptionState), TimingInput::convert(duration)); |
| 82 } | 82 } |
| 83 PassRefPtr<Animation> Animation::create(Element* element, const Vector<Dictionar
y>& keyframeDictionaryVector, ExceptionState& exceptionState) | 83 PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* element, const Vect
or<Dictionary>& keyframeDictionaryVector, ExceptionState& exceptionState) |
| 84 { | 84 { |
| 85 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); | 85 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); |
| 86 if (element) | 86 if (element) |
| 87 UseCounter::count(element->document(), UseCounter::AnimationConstructorK
eyframeListEffectNoTiming); | 87 UseCounter::count(element->document(), UseCounter::AnimationConstructorK
eyframeListEffectNoTiming); |
| 88 return create(element, EffectInput::convert(element, keyframeDictionaryVecto
r, exceptionState), Timing()); | 88 return create(element, EffectInput::convert(element, keyframeDictionaryVecto
r, exceptionState), Timing()); |
| 89 } | 89 } |
| 90 | 90 |
| 91 Animation::Animation(Element* target, PassRefPtrWillBeRawPtr<AnimationEffect> ef
fect, const Timing& timing, Priority priority, PassOwnPtr<EventDelegate> eventDe
legate) | 91 Animation::Animation(Element* target, PassRefPtrWillBeRawPtr<AnimationEffect> ef
fect, const Timing& timing, Priority priority, PassOwnPtr<EventDelegate> eventDe
legate) |
| 92 : TimedItem(timing, eventDelegate) | 92 : TimedItem(timing, eventDelegate) |
| 93 , m_target(target) | 93 , m_target(target) |
| 94 , m_effect(effect) | 94 , m_effect(effect) |
| 95 , m_sampledEffect(0) | 95 , m_sampledEffect(nullptr) |
| 96 , m_priority(priority) | 96 , m_priority(priority) |
| 97 { | 97 { |
| 98 #if !ENABLE(OILPAN) |
| 98 if (m_target) | 99 if (m_target) |
| 99 m_target->ensureActiveAnimations().addAnimation(this); | 100 m_target->ensureActiveAnimations().addAnimation(this); |
| 101 #endif |
| 100 } | 102 } |
| 101 | 103 |
| 102 Animation::~Animation() | 104 Animation::~Animation() |
| 103 { | 105 { |
| 106 #if !ENABLE(OILPAN) |
| 104 if (m_target) | 107 if (m_target) |
| 105 m_target->activeAnimations()->notifyAnimationDestroyed(this); | 108 m_target->activeAnimations()->notifyAnimationDestroyed(this); |
| 109 #endif |
| 106 } | 110 } |
| 107 | 111 |
| 108 void Animation::didAttach() | 112 void Animation::attach(AnimationPlayer* player) |
| 109 { | 113 { |
| 110 if (m_target) { | 114 if (m_target) { |
| 111 m_target->ensureActiveAnimations().addPlayer(player()); | 115 m_target->ensureActiveAnimations().addPlayer(player); |
| 112 m_target->setNeedsAnimationStyleRecalc(); | 116 m_target->setNeedsAnimationStyleRecalc(); |
| 113 } | 117 } |
| 118 TimedItem::attach(player); |
| 114 } | 119 } |
| 115 | 120 |
| 116 void Animation::willDetach() | 121 void Animation::detach() |
| 117 { | 122 { |
| 118 if (m_target) | 123 if (m_target) |
| 119 m_target->activeAnimations()->removePlayer(player()); | 124 m_target->activeAnimations()->removePlayer(player()); |
| 120 if (m_sampledEffect) | 125 if (m_sampledEffect) |
| 121 clearEffects(); | 126 clearEffects(); |
| 127 TimedItem::detach(); |
| 122 } | 128 } |
| 123 | 129 |
| 124 void Animation::specifiedTimingChanged() | 130 void Animation::specifiedTimingChanged() |
| 125 { | 131 { |
| 126 cancelAnimationOnCompositor(); | 132 cancelAnimationOnCompositor(); |
| 127 if (player()) { | 133 if (player()) { |
| 128 // FIXME: Needs to consider groups when added. | 134 // FIXME: Needs to consider groups when added. |
| 129 ASSERT(player()->source() == this); | 135 ASSERT(player()->source() == this); |
| 130 player()->schedulePendingAnimationOnCompositor(); | 136 player()->schedulePendingAnimationOnCompositor(); |
| 131 } | 137 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 143 if (!m_target || !m_effect) | 149 if (!m_target || !m_effect) |
| 144 return; | 150 return; |
| 145 | 151 |
| 146 double iteration = currentIteration(); | 152 double iteration = currentIteration(); |
| 147 ASSERT(iteration >= 0); | 153 ASSERT(iteration >= 0); |
| 148 // FIXME: Handle iteration values which overflow int. | 154 // FIXME: Handle iteration values which overflow int. |
| 149 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > in
terpolations = m_effect->sample(static_cast<int>(iteration), timeFraction(), ite
rationDuration()); | 155 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > in
terpolations = m_effect->sample(static_cast<int>(iteration), timeFraction(), ite
rationDuration()); |
| 150 if (m_sampledEffect) { | 156 if (m_sampledEffect) { |
| 151 m_sampledEffect->setInterpolations(interpolations.release()); | 157 m_sampledEffect->setInterpolations(interpolations.release()); |
| 152 } else if (!interpolations->isEmpty()) { | 158 } else if (!interpolations->isEmpty()) { |
| 153 OwnPtr<SampledEffect> sampledEffect = SampledEffect::create(this, interp
olations.release()); | 159 OwnPtrWillBeRawPtr<SampledEffect> sampledEffect = SampledEffect::create(
this, interpolations.release()); |
| 154 m_sampledEffect = sampledEffect.get(); | 160 m_sampledEffect = sampledEffect.get(); |
| 155 ensureAnimationStack(m_target).add(sampledEffect.release()); | 161 ensureAnimationStack(m_target).add(sampledEffect.release()); |
| 156 } else { | 162 } else { |
| 157 return; | 163 return; |
| 158 } | 164 } |
| 159 | 165 |
| 160 m_target->setNeedsAnimationStyleRecalc(); | 166 m_target->setNeedsAnimationStyleRecalc(); |
| 161 } | 167 } |
| 162 | 168 |
| 163 void Animation::clearEffects() | 169 void Animation::clearEffects() |
| 164 { | 170 { |
| 165 ASSERT(player()); | 171 ASSERT(player()); |
| 166 ASSERT(m_sampledEffect); | 172 ASSERT(m_sampledEffect); |
| 167 | 173 |
| 168 m_sampledEffect->clear(); | 174 m_sampledEffect->clear(); |
| 169 m_sampledEffect = 0; | 175 m_sampledEffect = nullptr; |
| 170 cancelAnimationOnCompositor(); | 176 cancelAnimationOnCompositor(); |
| 171 m_target->setNeedsAnimationStyleRecalc(); | 177 m_target->setNeedsAnimationStyleRecalc(); |
| 172 invalidate(); | 178 invalidate(); |
| 173 } | 179 } |
| 174 | 180 |
| 175 void Animation::updateChildrenAndEffects() const | 181 void Animation::updateChildrenAndEffects() const |
| 176 { | 182 { |
| 177 if (!m_effect) | 183 if (!m_effect) |
| 178 return; | 184 return; |
| 179 if (isInEffect()) | 185 if (isInEffect()) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 return std::numeric_limits<double>::infinity(); | 224 return std::numeric_limits<double>::infinity(); |
| 219 default: | 225 default: |
| 220 ASSERT_NOT_REACHED(); | 226 ASSERT_NOT_REACHED(); |
| 221 return std::numeric_limits<double>::infinity(); | 227 return std::numeric_limits<double>::infinity(); |
| 222 } | 228 } |
| 223 } | 229 } |
| 224 | 230 |
| 225 void Animation::notifySampledEffectRemovedFromAnimationStack() | 231 void Animation::notifySampledEffectRemovedFromAnimationStack() |
| 226 { | 232 { |
| 227 ASSERT(m_sampledEffect); | 233 ASSERT(m_sampledEffect); |
| 228 m_sampledEffect = 0; | 234 m_sampledEffect = nullptr; |
| 229 } | 235 } |
| 230 | 236 |
| 237 #if !ENABLE(OILPAN) |
| 231 void Animation::notifyElementDestroyed() | 238 void Animation::notifyElementDestroyed() |
| 232 { | 239 { |
| 233 // If our player is kept alive just by the sampledEffect, we might get our | 240 // If our player is kept alive just by the sampledEffect, we might get our |
| 234 // destructor called when we call SampledEffect::clear(), so we need to | 241 // destructor called when we call SampledEffect::clear(), so we need to |
| 235 // clear m_sampledEffect first. | 242 // clear m_sampledEffect first. |
| 236 m_target = 0; | 243 m_target = 0; |
| 237 clearEventDelegate(); | 244 clearEventDelegate(); |
| 238 SampledEffect* sampledEffect = m_sampledEffect; | 245 SampledEffect* sampledEffect = m_sampledEffect; |
| 239 m_sampledEffect = 0; | 246 m_sampledEffect = nullptr; |
| 240 if (sampledEffect) | 247 if (sampledEffect) |
| 241 sampledEffect->clear(); | 248 sampledEffect->clear(); |
| 242 } | 249 } |
| 250 #endif |
| 243 | 251 |
| 244 bool Animation::isCandidateForAnimationOnCompositor() const | 252 bool Animation::isCandidateForAnimationOnCompositor() const |
| 245 { | 253 { |
| 246 if (!effect() || !m_target) | 254 if (!effect() || !m_target) |
| 247 return false; | 255 return false; |
| 248 return CompositorAnimations::instance()->isCandidateForAnimationOnCompositor
(specifiedTiming(), *effect()); | 256 return CompositorAnimations::instance()->isCandidateForAnimationOnCompositor
(specifiedTiming(), *effect()); |
| 249 } | 257 } |
| 250 | 258 |
| 251 bool Animation::maybeStartAnimationOnCompositor(double startTime) | 259 bool Animation::maybeStartAnimationOnCompositor(double startTime) |
| 252 { | 260 { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 | 301 |
| 294 void Animation::pauseAnimationForTestingOnCompositor(double pauseTime) | 302 void Animation::pauseAnimationForTestingOnCompositor(double pauseTime) |
| 295 { | 303 { |
| 296 ASSERT(hasActiveAnimationsOnCompositor()); | 304 ASSERT(hasActiveAnimationsOnCompositor()); |
| 297 if (!m_target || !m_target->renderer()) | 305 if (!m_target || !m_target->renderer()) |
| 298 return; | 306 return; |
| 299 for (size_t i = 0; i < m_compositorAnimationIds.size(); ++i) | 307 for (size_t i = 0; i < m_compositorAnimationIds.size(); ++i) |
| 300 CompositorAnimations::instance()->pauseAnimationForTestingOnCompositor(*
m_target, m_compositorAnimationIds[i], pauseTime); | 308 CompositorAnimations::instance()->pauseAnimationForTestingOnCompositor(*
m_target, m_compositorAnimationIds[i], pauseTime); |
| 301 } | 309 } |
| 302 | 310 |
| 311 void Animation::trace(Visitor* visitor) |
| 312 { |
| 313 visitor->trace(m_target); |
| 314 visitor->trace(m_effect); |
| 315 visitor->trace(m_sampledEffect); |
| 316 TimedItem::trace(visitor); |
| 317 } |
| 318 |
| 303 } // namespace WebCore | 319 } // namespace WebCore |
| OLD | NEW |