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/KeyframeEffectOptions.h" | 42 #include "core/animation/KeyframeEffectOptions.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<KeyframeEffect> KeyframeEffect::create(Element* target, P
assRefPtrWillBeRawPtr<EffectModel> model, const Timing& timing, Priority priorit
y, PassOwnPtrWillBeRawPtr<EventDelegate> eventDelegate) | 52 KeyframeEffect* KeyframeEffect::create(Element* target, EffectModel* model, cons
t Timing& timing, Priority priority, EventDelegate* eventDelegate) |
53 { | 53 { |
54 return adoptRefWillBeNoop(new KeyframeEffect(target, model, timing, priority
, eventDelegate)); | 54 return new KeyframeEffect(target, model, timing, priority, eventDelegate); |
55 } | 55 } |
56 | 56 |
57 PassRefPtrWillBeRawPtr<KeyframeEffect> KeyframeEffect::create(Element* element,
const Vector<Dictionary>& keyframeDictionaryVector, double duration, ExceptionSt
ate& exceptionState) | 57 KeyframeEffect* KeyframeEffect::create(Element* element, const Vector<Dictionary
>& keyframeDictionaryVector, 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<KeyframeEffect> KeyframeEffect::create(Element* element,
const Vector<Dictionary>& keyframeDictionaryVector, const KeyframeEffectOptions&
timingInput, ExceptionState& exceptionState) | 64 KeyframeEffect* KeyframeEffect::create(Element* element, const Vector<Dictionary
>& keyframeDictionaryVector, const KeyframeEffectOptions& timingInput, Exception
State& 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<KeyframeEffect> KeyframeEffect::create(Element* element,
const Vector<Dictionary>& keyframeDictionaryVector, ExceptionState& exceptionSta
te) | 71 KeyframeEffect* KeyframeEffect::create(Element* element, const Vector<Dictionary
>& keyframeDictionaryVector, 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 KeyframeEffect::KeyframeEffect(Element* target, PassRefPtrWillBeRawPtr<EffectMod
el> model, const Timing& timing, Priority priority, PassOwnPtrWillBeRawPtr<Event
Delegate> eventDelegate) | 79 KeyframeEffect::KeyframeEffect(Element* target, EffectModel* model, const Timing
& timing, Priority priority, EventDelegate* eventDelegate) |
80 : AnimationEffect(timing, eventDelegate) | 80 : AnimationEffect(timing, eventDelegate) |
81 , m_target(target) | 81 , m_target(target) |
82 , m_model(model) | 82 , m_model(model) |
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().addEffect(this); | |
89 #endif | |
90 } | 86 } |
91 | 87 |
92 KeyframeEffect::~KeyframeEffect() | 88 KeyframeEffect::~KeyframeEffect() |
93 { | 89 { |
94 #if !ENABLE(OILPAN) | |
95 if (m_target) | |
96 m_target->elementAnimations()->notifyEffectDestroyed(this); | |
97 #endif | |
98 } | 90 } |
99 | 91 |
100 void KeyframeEffect::attach(Animation* animation) | 92 void KeyframeEffect::attach(Animation* animation) |
101 { | 93 { |
102 if (m_target) { | 94 if (m_target) { |
103 m_target->ensureElementAnimations().animations().add(animation); | 95 m_target->ensureElementAnimations().animations().add(animation); |
104 m_target->setNeedsAnimationStyleRecalc(); | 96 m_target->setNeedsAnimationStyleRecalc(); |
105 } | 97 } |
106 AnimationEffect::attach(animation); | 98 AnimationEffect::attach(animation); |
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 && animation()->hasActiveAnimationsOnCompositor() | 134 && animation()->hasActiveAnimationsOnCompositor() |
143 && animation()->affects(*m_target, CSSPropertyTransform)) { | 135 && animation()->affects(*m_target, CSSPropertyTransform)) { |
144 animation()->cancelAnimationOnCompositor(); | 136 animation()->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_model->sample(static_cast<int>(iteration), timeFraction(), iterationDurati
on(), interpolations); | 143 m_model->sample(static_cast<int>(iteration), timeFraction(), iterationDurati
on(), 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 KeyframeEffect::clearEffects() | 159 void KeyframeEffect::clearEffects() |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 | 324 |
333 DEFINE_TRACE(KeyframeEffect) | 325 DEFINE_TRACE(KeyframeEffect) |
334 { | 326 { |
335 visitor->trace(m_target); | 327 visitor->trace(m_target); |
336 visitor->trace(m_model); | 328 visitor->trace(m_model); |
337 visitor->trace(m_sampledEffect); | 329 visitor->trace(m_sampledEffect); |
338 AnimationEffect::trace(visitor); | 330 AnimationEffect::trace(visitor); |
339 } | 331 } |
340 | 332 |
341 } // namespace blink | 333 } // namespace blink |
OLD | NEW |