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 14 matching lines...) Expand all Loading... |
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 #ifndef ElementAnimation_h | 31 #ifndef ElementAnimation_h |
32 #define ElementAnimation_h | 32 #define ElementAnimation_h |
33 | 33 |
34 #include "bindings/core/v8/UnionTypesCore.h" | 34 #include "bindings/core/v8/UnionTypesCore.h" |
35 #include "core/animation/Animation.h" | |
36 #include "core/animation/AnimationTimeline.h" | 35 #include "core/animation/AnimationTimeline.h" |
37 #include "core/animation/EffectInput.h" | 36 #include "core/animation/EffectInput.h" |
38 #include "core/animation/ElementAnimations.h" | 37 #include "core/animation/ElementAnimations.h" |
| 38 #include "core/animation/KeyframeEffect.h" |
39 #include "core/animation/TimingInput.h" | 39 #include "core/animation/TimingInput.h" |
40 #include "core/dom/Document.h" | 40 #include "core/dom/Document.h" |
41 #include "core/dom/Element.h" | 41 #include "core/dom/Element.h" |
42 #include "platform/RuntimeEnabledFeatures.h" | 42 #include "platform/RuntimeEnabledFeatures.h" |
43 | 43 |
44 | 44 |
45 namespace blink { | 45 namespace blink { |
46 | 46 |
47 class Dictionary; | 47 class Dictionary; |
48 | 48 |
49 class ElementAnimation { | 49 class ElementAnimation { |
50 public: | 50 public: |
51 static AnimationPlayer* animate(Element& element, const AnimationEffectOrDic
tionarySequence& effectInput, double duration, ExceptionState& exceptionState) | 51 static Animation* animate(Element& element, const EffectModelOrDictionarySeq
uence& effectInput, double duration, ExceptionState& exceptionState) |
52 { | 52 { |
53 RefPtrWillBeRawPtr<AnimationEffect> effect = EffectInput::convert(&eleme
nt, effectInput, exceptionState); | 53 RefPtrWillBeRawPtr<EffectModel> effect = EffectInput::convert(&element,
effectInput, exceptionState); |
54 if (exceptionState.hadException()) | 54 if (exceptionState.hadException()) |
55 return 0; | 55 return 0; |
56 return animateInternal(element, effect, TimingInput::convert(duration)); | 56 return animateInternal(element, effect, TimingInput::convert(duration)); |
57 } | 57 } |
58 | 58 |
59 static AnimationPlayer* animate(Element& element, const AnimationEffectOrDic
tionarySequence& effectInput, const AnimationTimingProperties& timingInput, Exce
ptionState& exceptionState) | 59 static Animation* animate(Element& element, const EffectModelOrDictionarySeq
uence& effectInput, const KeyframeEffectOptions& timingInput, ExceptionState& ex
ceptionState) |
60 { | 60 { |
61 RefPtrWillBeRawPtr<AnimationEffect> effect = EffectInput::convert(&eleme
nt, effectInput, exceptionState); | 61 RefPtrWillBeRawPtr<EffectModel> effect = EffectInput::convert(&element,
effectInput, exceptionState); |
62 if (exceptionState.hadException()) | 62 if (exceptionState.hadException()) |
63 return 0; | 63 return 0; |
64 return animateInternal(element, effect, TimingInput::convert(timingInput
)); | 64 return animateInternal(element, effect, TimingInput::convert(timingInput
)); |
65 } | 65 } |
66 | 66 |
67 static AnimationPlayer* animate(Element& element, const AnimationEffectOrDic
tionarySequence& effectInput, ExceptionState& exceptionState) | 67 static Animation* animate(Element& element, const EffectModelOrDictionarySeq
uence& effectInput, ExceptionState& exceptionState) |
68 { | 68 { |
69 RefPtrWillBeRawPtr<AnimationEffect> effect = EffectInput::convert(&eleme
nt, effectInput, exceptionState); | 69 RefPtrWillBeRawPtr<EffectModel> effect = EffectInput::convert(&element,
effectInput, exceptionState); |
70 if (exceptionState.hadException()) | 70 if (exceptionState.hadException()) |
71 return 0; | 71 return 0; |
72 return animateInternal(element, effect, Timing()); | 72 return animateInternal(element, effect, Timing()); |
73 } | 73 } |
74 | 74 |
75 static WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer>> getAnimationPla
yers(Element& element) | 75 static WillBeHeapVector<RefPtrWillBeMember<Animation>> getAnimations(Element
& element) |
76 { | 76 { |
77 WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer>> animationPlayers; | 77 WillBeHeapVector<RefPtrWillBeMember<Animation>> animationss; |
78 | 78 |
79 if (!element.hasAnimations()) | 79 if (!element.hasAnimations()) |
80 return animationPlayers; | 80 return animationss; |
81 | 81 |
82 for (const auto& player : element.document().timeline().getAnimationPlay
ers()) { | 82 for (const auto& animation : element.document().timeline().getAnimations
()) { |
83 ASSERT(player->source()); | 83 ASSERT(animation->source()); |
84 if (toAnimation(player->source())->target() == element && (player->s
ource()->isCurrent() || player->source()->isInEffect())) | 84 if (toKeyframeEffect(animation->source())->target() == element && (a
nimation->source()->isCurrent() || animation->source()->isInEffect())) |
85 animationPlayers.append(player); | 85 animationss.append(animation); |
86 } | 86 } |
87 return animationPlayers; | 87 return animationss; |
88 } | 88 } |
89 | 89 |
90 private: | 90 private: |
91 static AnimationPlayer* animateInternal(Element& element, PassRefPtrWillBeRa
wPtr<AnimationEffect> effect, const Timing& timing) | 91 static Animation* animateInternal(Element& element, PassRefPtrWillBeRawPtr<E
ffectModel> effect, const Timing& timing) |
92 { | 92 { |
93 RefPtrWillBeRawPtr<Animation> animation = Animation::create(&element, ef
fect, timing); | 93 RefPtrWillBeRawPtr<KeyframeEffect> keyframeEffect = KeyframeEffect::crea
te(&element, effect, timing); |
94 return element.document().timeline().play(animation.get()); | 94 return element.document().timeline().play(keyframeEffect.get()); |
95 } | 95 } |
96 }; | 96 }; |
97 | 97 |
98 } // namespace blink | 98 } // namespace blink |
99 | 99 |
100 #endif // ElementAnimation_h | 100 #endif // ElementAnimation_h |
OLD | NEW |