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 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
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 "core/animation/ActiveAnimations.h" | 35 #include "core/animation/ActiveAnimations.h" |
35 #include "core/animation/Animation.h" | 36 #include "core/animation/Animation.h" |
36 #include "core/animation/AnimationTimeline.h" | 37 #include "core/animation/AnimationTimeline.h" |
37 #include "core/animation/EffectInput.h" | 38 #include "core/animation/EffectInput.h" |
38 #include "core/animation/TimingInput.h" | 39 #include "core/animation/TimingInput.h" |
39 #include "core/dom/Document.h" | 40 #include "core/dom/Document.h" |
40 #include "core/dom/Element.h" | 41 #include "core/dom/Element.h" |
41 #include "platform/RuntimeEnabledFeatures.h" | 42 #include "platform/RuntimeEnabledFeatures.h" |
42 | 43 |
43 | 44 |
44 namespace blink { | 45 namespace blink { |
45 | 46 |
46 class Dictionary; | 47 class Dictionary; |
47 | 48 |
48 class ElementAnimation { | 49 class ElementAnimation { |
49 public: | 50 public: |
50 static AnimationPlayer* animate(Element& element, PassRefPtrWillBeRawPtr<Ani
mationEffect> effect, const Dictionary& timingInputDictionary) | 51 static AnimationPlayer* animate(Element& element, const AnimationEffectOrDic
tionarySequence& effectInput, double duration, ExceptionState& exceptionState) |
51 { | 52 { |
52 return animateInternal(element, effect, TimingInput::convert(timingInput
Dictionary)); | 53 RefPtrWillBeRawPtr<AnimationEffect> effect = EffectInput::convert(&eleme
nt, effectInput, exceptionState); |
53 } | 54 if (exceptionState.hadException()) |
54 | 55 return 0; |
55 static AnimationPlayer* animate(Element& element, PassRefPtrWillBeRawPtr<Ani
mationEffect> effect, double duration) | |
56 { | |
57 return animateInternal(element, effect, TimingInput::convert(duration)); | 56 return animateInternal(element, effect, TimingInput::convert(duration)); |
58 } | 57 } |
59 | 58 |
60 static AnimationPlayer* animate(Element& element, PassRefPtrWillBeRawPtr<Ani
mationEffect> effect) | 59 static AnimationPlayer* animate(Element& element, const AnimationEffectOrDic
tionarySequence& effectInput, const AnimationTimingProperties& timingInput, Exce
ptionState& exceptionState) |
61 { | 60 { |
| 61 RefPtrWillBeRawPtr<AnimationEffect> effect = EffectInput::convert(&eleme
nt, effectInput, exceptionState); |
| 62 if (exceptionState.hadException()) |
| 63 return 0; |
| 64 return animateInternal(element, effect, TimingInput::convert(timingInput
)); |
| 65 } |
| 66 |
| 67 static AnimationPlayer* animate(Element& element, const AnimationEffectOrDic
tionarySequence& effectInput, ExceptionState& exceptionState) |
| 68 { |
| 69 RefPtrWillBeRawPtr<AnimationEffect> effect = EffectInput::convert(&eleme
nt, effectInput, exceptionState); |
| 70 if (exceptionState.hadException()) |
| 71 return 0; |
62 return animateInternal(element, effect, Timing()); | 72 return animateInternal(element, effect, Timing()); |
63 } | 73 } |
64 | 74 |
65 static AnimationPlayer* animate(Element& element, const Vector<Dictionary>&
keyframeDictionaryVector, const Dictionary& timingInputDictionary, ExceptionStat
e& exceptionState) | |
66 { | |
67 RefPtrWillBeRawPtr<AnimationEffect> effect = EffectInput::convert(&eleme
nt, keyframeDictionaryVector, exceptionState); | |
68 if (exceptionState.hadException()) | |
69 return 0; | |
70 ASSERT(effect); | |
71 return animateInternal(element, effect.release(), TimingInput::convert(t
imingInputDictionary)); | |
72 } | |
73 | |
74 static AnimationPlayer* animate(Element& element, const Vector<Dictionary>&
keyframeDictionaryVector, double duration, ExceptionState& exceptionState) | |
75 { | |
76 RefPtrWillBeRawPtr<AnimationEffect> effect = EffectInput::convert(&eleme
nt, keyframeDictionaryVector, exceptionState); | |
77 if (exceptionState.hadException()) | |
78 return 0; | |
79 ASSERT(effect); | |
80 return animateInternal(element, effect.release(), TimingInput::convert(d
uration)); | |
81 } | |
82 | |
83 static AnimationPlayer* animate(Element& element, const Vector<Dictionary>&
keyframeDictionaryVector, ExceptionState& exceptionState) | |
84 { | |
85 RefPtrWillBeRawPtr<AnimationEffect> effect = EffectInput::convert(&eleme
nt, keyframeDictionaryVector, exceptionState); | |
86 if (exceptionState.hadException()) | |
87 return 0; | |
88 ASSERT(effect); | |
89 return animateInternal(element, effect.release(), Timing()); | |
90 } | |
91 | |
92 static WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer> > getAnimationPl
ayers(Element& element) | 75 static WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer> > getAnimationPl
ayers(Element& element) |
93 { | 76 { |
94 WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer> > animationPlayers; | 77 WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer> > animationPlayers; |
95 | 78 |
96 if (!element.hasActiveAnimations()) | 79 if (!element.hasActiveAnimations()) |
97 return animationPlayers; | 80 return animationPlayers; |
98 | 81 |
99 for (const auto& player : element.document().timeline().getAnimationPlay
ers()) { | 82 for (const auto& player : element.document().timeline().getAnimationPlay
ers()) { |
100 ASSERT(player->source()); | 83 ASSERT(player->source()); |
101 if (toAnimation(player->source())->target() == element && (player->s
ource()->isCurrent() || player->source()->isInEffect())) | 84 if (toAnimation(player->source())->target() == element && (player->s
ource()->isCurrent() || player->source()->isInEffect())) |
102 animationPlayers.append(player); | 85 animationPlayers.append(player); |
103 } | 86 } |
104 return animationPlayers; | 87 return animationPlayers; |
105 } | 88 } |
106 | 89 |
107 private: | 90 private: |
108 static AnimationPlayer* animateInternal(Element& element, PassRefPtrWillBeRa
wPtr<AnimationEffect> effect, const Timing& timing) | 91 static AnimationPlayer* animateInternal(Element& element, PassRefPtrWillBeRa
wPtr<AnimationEffect> effect, const Timing& timing) |
109 { | 92 { |
110 RefPtrWillBeRawPtr<Animation> animation = Animation::create(&element, ef
fect, timing); | 93 RefPtrWillBeRawPtr<Animation> animation = Animation::create(&element, ef
fect, timing); |
111 return element.document().timeline().play(animation.get()); | 94 return element.document().timeline().play(animation.get()); |
112 } | 95 } |
113 }; | 96 }; |
114 | 97 |
115 } // namespace blink | 98 } // namespace blink |
116 | 99 |
117 #endif // ElementAnimation_h | 100 #endif // ElementAnimation_h |
OLD | NEW |