| 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(PassRefPtr<Element> target, PassRefPtrWi
llBeRawPtr<AnimationEffect> effect, const Timing& timing, Priority priority, Pas
sOwnPtr<EventDelegate> eventDelegate) | 49 PassRefPtrWillBeRawPtr<Animation> Animation::create(PassRefPtr<Element> target,
PassRefPtrWillBeRawPtr<AnimationEffect> effect, const Timing& timing, Priority p
riority, PassOwnPtr<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 UseCounter::count(element->document(), UseCounter::AnimationConstructorKeyfr
ameListEffectObjectTiming); | 72 UseCounter::count(element->document(), UseCounter::AnimationConstructorKeyfr
ameListEffectObjectTiming); |
| 73 return create(element, EffectInput::convert(element, keyframeDictionaryVecto
r, exceptionState), TimingInput::convert(timingInputDictionary)); | 73 return create(element, EffectInput::convert(element, keyframeDictionaryVecto
r, exceptionState), TimingInput::convert(timingInputDictionary)); |
| 74 } | 74 } |
| 75 PassRefPtr<Animation> Animation::create(Element* element, const Vector<Dictionar
y>& keyframeDictionaryVector, double duration, ExceptionState& exceptionState) | 75 PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* element, const Vect
or<Dictionary>& keyframeDictionaryVector, double duration, ExceptionState& excep
tionState) |
| 76 { | 76 { |
| 77 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); | 77 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); |
| 78 UseCounter::count(element->document(), UseCounter::AnimationConstructorKeyfr
ameListEffectDoubleTiming); | 78 UseCounter::count(element->document(), UseCounter::AnimationConstructorKeyfr
ameListEffectDoubleTiming); |
| 79 return create(element, EffectInput::convert(element, keyframeDictionaryVecto
r, exceptionState), TimingInput::convert(duration)); | 79 return create(element, EffectInput::convert(element, keyframeDictionaryVecto
r, exceptionState), TimingInput::convert(duration)); |
| 80 } | 80 } |
| 81 PassRefPtr<Animation> Animation::create(Element* element, const Vector<Dictionar
y>& keyframeDictionaryVector, ExceptionState& exceptionState) | 81 PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* element, const Vect
or<Dictionary>& keyframeDictionaryVector, ExceptionState& exceptionState) |
| 82 { | 82 { |
| 83 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); | 83 ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); |
| 84 UseCounter::count(element->document(), UseCounter::AnimationConstructorKeyfr
ameListEffectNoTiming); | 84 UseCounter::count(element->document(), UseCounter::AnimationConstructorKeyfr
ameListEffectNoTiming); |
| 85 return create(element, EffectInput::convert(element, keyframeDictionaryVecto
r, exceptionState), Timing()); | 85 return create(element, EffectInput::convert(element, keyframeDictionaryVecto
r, exceptionState), Timing()); |
| 86 } | 86 } |
| 87 | 87 |
| 88 Animation::Animation(PassRefPtr<Element> target, PassRefPtrWillBeRawPtr<Animatio
nEffect> effect, const Timing& timing, Priority priority, PassOwnPtr<EventDelega
te> eventDelegate) | 88 Animation::Animation(PassRefPtr<Element> target, PassRefPtrWillBeRawPtr<Animatio
nEffect> effect, const Timing& timing, Priority priority, PassOwnPtr<EventDelega
te> eventDelegate) |
| 89 : TimedItem(timing, eventDelegate) | 89 : TimedItem(timing, eventDelegate) |
| 90 , m_target(target) | 90 , m_target(target) |
| 91 , m_effect(effect) | 91 , m_effect(effect) |
| 92 , m_sampledEffect(0) | 92 , m_sampledEffect(nullptr) |
| 93 , m_priority(priority) | 93 , m_priority(priority) |
| 94 { | 94 { |
| 95 } | 95 } |
| 96 | 96 |
| 97 void Animation::didAttach() | 97 void Animation::attach(AnimationPlayer* player) |
| 98 { | 98 { |
| 99 if (m_target) { | 99 if (m_target) { |
| 100 m_target->ensureActiveAnimations().players().add(player()); | 100 m_target->ensureActiveAnimations().players().add(player); |
| 101 m_target->setNeedsAnimationStyleRecalc(); | 101 m_target->setNeedsAnimationStyleRecalc(); |
| 102 } | 102 } |
| 103 TimedItem::attach(player); |
| 103 } | 104 } |
| 104 | 105 |
| 105 void Animation::willDetach() | 106 void Animation::detach() |
| 106 { | 107 { |
| 107 if (m_target) { | 108 if (m_target) { |
| 109 #if !ENABLE(OILPAN) |
| 108 m_target->activeAnimations()->players().remove(player()); | 110 m_target->activeAnimations()->players().remove(player()); |
| 111 #endif |
| 109 m_target->setNeedsAnimationStyleRecalc(); | 112 m_target->setNeedsAnimationStyleRecalc(); |
| 110 } | 113 } |
| 111 if (m_sampledEffect) | 114 if (m_sampledEffect) |
| 112 clearEffects(); | 115 clearEffects(); |
| 116 TimedItem::detach(); |
| 113 } | 117 } |
| 114 | 118 |
| 115 void Animation::specifiedTimingChanged() | 119 void Animation::specifiedTimingChanged() |
| 116 { | 120 { |
| 117 // FIXME: Restart on compositor. | 121 // FIXME: Restart on compositor. |
| 118 cancelAnimationOnCompositor(); | 122 cancelAnimationOnCompositor(); |
| 119 } | 123 } |
| 120 | 124 |
| 121 static AnimationStack& ensureAnimationStack(Element* element) | 125 static AnimationStack& ensureAnimationStack(Element* element) |
| 122 { | 126 { |
| 123 return element->ensureActiveAnimations().defaultStack(); | 127 return element->ensureActiveAnimations().defaultStack(); |
| 124 } | 128 } |
| 125 | 129 |
| 126 void Animation::applyEffects() | 130 void Animation::applyEffects() |
| 127 { | 131 { |
| 128 ASSERT(isInEffect()); | 132 ASSERT(isInEffect()); |
| 129 ASSERT(player()); | 133 ASSERT(player()); |
| 130 if (!m_target || !m_effect) | 134 if (!m_target || !m_effect) |
| 131 return; | 135 return; |
| 132 | 136 |
| 133 double iteration = currentIteration(); | 137 double iteration = currentIteration(); |
| 134 ASSERT(iteration >= 0); | 138 ASSERT(iteration >= 0); |
| 135 // FIXME: Handle iteration values which overflow int. | 139 // FIXME: Handle iteration values which overflow int. |
| 136 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > in
terpolations = m_effect->sample(static_cast<int>(iteration), timeFraction(), dur
ation()); | 140 OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation> > > in
terpolations = m_effect->sample(static_cast<int>(iteration), timeFraction(), dur
ation()); |
| 137 if (m_sampledEffect) { | 141 if (m_sampledEffect) { |
| 138 m_sampledEffect->setInterpolations(interpolations.release()); | 142 m_sampledEffect->setInterpolations(interpolations.release()); |
| 139 } else if (!interpolations->isEmpty()) { | 143 } else if (!interpolations->isEmpty()) { |
| 140 OwnPtr<SampledEffect> sampledEffect = SampledEffect::create(this, interp
olations.release()); | 144 OwnPtrWillBeRawPtr<SampledEffect> sampledEffect = SampledEffect::create(
this, interpolations.release()); |
| 141 m_sampledEffect = sampledEffect.get(); | 145 m_sampledEffect = sampledEffect.get(); |
| 142 ensureAnimationStack(m_target.get()).add(sampledEffect.release()); | 146 ensureAnimationStack(m_target.get()).add(sampledEffect.release()); |
| 143 } else { | 147 } else { |
| 144 return; | 148 return; |
| 145 } | 149 } |
| 146 | 150 |
| 147 m_target->setNeedsAnimationStyleRecalc(); | 151 m_target->setNeedsAnimationStyleRecalc(); |
| 148 } | 152 } |
| 149 | 153 |
| 150 void Animation::clearEffects() | 154 void Animation::clearEffects() |
| 151 { | 155 { |
| 152 ASSERT(player()); | 156 ASSERT(player()); |
| 153 ASSERT(m_sampledEffect); | 157 ASSERT(m_sampledEffect); |
| 154 | 158 |
| 155 m_sampledEffect->clear(); | 159 m_sampledEffect->detach(); |
| 156 m_sampledEffect = 0; | 160 m_sampledEffect = nullptr; |
| 157 cancelAnimationOnCompositor(); | 161 cancelAnimationOnCompositor(); |
| 158 m_target->setNeedsAnimationStyleRecalc(); | 162 m_target->setNeedsAnimationStyleRecalc(); |
| 159 invalidate(); | 163 invalidate(); |
| 160 } | 164 } |
| 161 | 165 |
| 162 void Animation::updateChildrenAndEffects() const | 166 void Animation::updateChildrenAndEffects() const |
| 163 { | 167 { |
| 164 if (!m_effect) | 168 if (!m_effect) |
| 165 return; | 169 return; |
| 166 if (isInEffect()) | 170 if (isInEffect()) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 return std::numeric_limits<double>::infinity(); | 209 return std::numeric_limits<double>::infinity(); |
| 206 default: | 210 default: |
| 207 ASSERT_NOT_REACHED(); | 211 ASSERT_NOT_REACHED(); |
| 208 return std::numeric_limits<double>::infinity(); | 212 return std::numeric_limits<double>::infinity(); |
| 209 } | 213 } |
| 210 } | 214 } |
| 211 | 215 |
| 212 void Animation::notifySampledEffectRemovedFromAnimationStack() | 216 void Animation::notifySampledEffectRemovedFromAnimationStack() |
| 213 { | 217 { |
| 214 ASSERT(m_sampledEffect); | 218 ASSERT(m_sampledEffect); |
| 215 m_sampledEffect = 0; | 219 m_sampledEffect = nullptr; |
| 216 } | 220 } |
| 217 | 221 |
| 218 bool Animation::isCandidateForAnimationOnCompositor() const | 222 bool Animation::isCandidateForAnimationOnCompositor() const |
| 219 { | 223 { |
| 220 if (!effect() || !m_target) | 224 if (!effect() || !m_target) |
| 221 return false; | 225 return false; |
| 222 return CompositorAnimations::instance()->isCandidateForAnimationOnCompositor
(specifiedTiming(), *effect()); | 226 return CompositorAnimations::instance()->isCandidateForAnimationOnCompositor
(specifiedTiming(), *effect()); |
| 223 } | 227 } |
| 224 | 228 |
| 225 bool Animation::maybeStartAnimationOnCompositor(double startTime) | 229 bool Animation::maybeStartAnimationOnCompositor(double startTime) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 271 |
| 268 void Animation::pauseAnimationForTestingOnCompositor(double pauseTime) | 272 void Animation::pauseAnimationForTestingOnCompositor(double pauseTime) |
| 269 { | 273 { |
| 270 ASSERT(hasActiveAnimationsOnCompositor()); | 274 ASSERT(hasActiveAnimationsOnCompositor()); |
| 271 if (!m_target || !m_target->renderer()) | 275 if (!m_target || !m_target->renderer()) |
| 272 return; | 276 return; |
| 273 for (size_t i = 0; i < m_compositorAnimationIds.size(); ++i) | 277 for (size_t i = 0; i < m_compositorAnimationIds.size(); ++i) |
| 274 CompositorAnimations::instance()->pauseAnimationForTestingOnCompositor(*
m_target.get(), m_compositorAnimationIds[i], pauseTime); | 278 CompositorAnimations::instance()->pauseAnimationForTestingOnCompositor(*
m_target.get(), m_compositorAnimationIds[i], pauseTime); |
| 275 } | 279 } |
| 276 | 280 |
| 281 void Animation::trace(Visitor* visitor) |
| 282 { |
| 283 visitor->trace(m_effect); |
| 284 visitor->trace(m_sampledEffect); |
| 285 TimedItem::trace(visitor); |
| 286 } |
| 287 |
| 277 } // namespace WebCore | 288 } // namespace WebCore |
| OLD | NEW |