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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 class Element; | 48 class Element; |
49 class StylePropertyShorthand; | 49 class StylePropertyShorthand; |
50 class StyleResolver; | 50 class StyleResolver; |
51 | 51 |
52 class CSSAnimations final { | 52 class CSSAnimations final { |
53 WTF_MAKE_NONCOPYABLE(CSSAnimations); | 53 WTF_MAKE_NONCOPYABLE(CSSAnimations); |
54 DISALLOW_ALLOCATION(); | 54 DISALLOW_ALLOCATION(); |
55 public: | 55 public: |
56 CSSAnimations(); | 56 CSSAnimations(); |
57 | 57 |
58 const AtomicString getAnimationNameForInspector(const AnimationPlayer&); | 58 const AtomicString getAnimationNameForInspector(const Animation&); |
59 bool isTransitionAnimationForInspector(const AnimationPlayer&) const; | 59 bool isTransitionAnimationForInspector(const Animation&) const; |
60 | 60 |
61 static const StylePropertyShorthand& propertiesForTransitionAll(); | 61 static const StylePropertyShorthand& propertiesForTransitionAll(); |
62 static bool isAllowedAnimation(CSSPropertyID); | 62 static bool isAllowedAnimation(CSSPropertyID); |
63 static PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> calculateUpdate(const Elem
ent* animatingElement, Element&, const ComputedStyle&, ComputedStyle* parentStyl
e, StyleResolver*); | 63 static PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> calculateUpdate(const Elem
ent* animatingElement, Element&, const ComputedStyle&, ComputedStyle* parentStyl
e, StyleResolver*); |
64 | 64 |
65 void setPendingUpdate(PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> update) { m
_pendingUpdate = update; } | 65 void setPendingUpdate(PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> update) { m
_pendingUpdate = update; } |
66 void maybeApplyPendingUpdate(Element*); | 66 void maybeApplyPendingUpdate(Element*); |
67 bool isEmpty() const { return m_animations.isEmpty() && m_transitions.isEmpt
y() && !m_pendingUpdate; } | 67 bool isEmpty() const { return m_animations.isEmpty() && m_transitions.isEmpt
y() && !m_pendingUpdate; } |
68 void cancel(); | 68 void cancel(); |
69 | 69 |
70 DECLARE_TRACE(); | 70 DECLARE_TRACE(); |
71 | 71 |
72 private: | 72 private: |
73 class RunningAnimation final : public RefCountedWillBeGarbageCollectedFinali
zed<RunningAnimation> { | 73 class RunningAnimation final : public RefCountedWillBeGarbageCollectedFinali
zed<RunningAnimation> { |
74 public: | 74 public: |
75 RunningAnimation(PassRefPtrWillBeRawPtr<AnimationPlayer> player, CSSAnim
ationUpdate::NewAnimation animation) | 75 RunningAnimation(PassRefPtrWillBeRawPtr<Animation> animation, CSSAnimati
onUpdate::NewAnimation newAnimation) |
76 : player(player) | 76 : animation(animation) |
77 , specifiedTiming(animation.timing) | 77 , specifiedTiming(newAnimation.timing) |
78 , styleRule(animation.styleRule) | 78 , styleRule(newAnimation.styleRule) |
79 , styleRuleVersion(animation.styleRuleVersion) | 79 , styleRuleVersion(newAnimation.styleRuleVersion) |
80 { | 80 { |
81 } | 81 } |
82 | 82 |
83 void update(CSSAnimationUpdate::UpdatedAnimation update) | 83 void update(CSSAnimationUpdate::UpdatedAnimation update) |
84 { | 84 { |
85 styleRule = update.styleRule; | 85 styleRule = update.styleRule; |
86 styleRuleVersion = update.styleRuleVersion; | 86 styleRuleVersion = update.styleRuleVersion; |
87 specifiedTiming = update.specifiedTiming; | 87 specifiedTiming = update.specifiedTiming; |
88 } | 88 } |
89 | 89 |
90 DEFINE_INLINE_TRACE() | 90 DEFINE_INLINE_TRACE() |
91 { | 91 { |
92 visitor->trace(player); | 92 visitor->trace(animation); |
93 visitor->trace(styleRule); | 93 visitor->trace(styleRule); |
94 } | 94 } |
95 | 95 |
96 RefPtrWillBeMember<AnimationPlayer> player; | 96 RefPtrWillBeMember<Animation> animation; |
97 Timing specifiedTiming; | 97 Timing specifiedTiming; |
98 RefPtrWillBeMember<StyleRuleKeyframes> styleRule; | 98 RefPtrWillBeMember<StyleRuleKeyframes> styleRule; |
99 unsigned styleRuleVersion; | 99 unsigned styleRuleVersion; |
100 }; | 100 }; |
101 | 101 |
102 struct RunningTransition { | 102 struct RunningTransition { |
103 ALLOW_ONLY_INLINE_ALLOCATION(); | 103 ALLOW_ONLY_INLINE_ALLOCATION(); |
104 public: | 104 public: |
105 DEFINE_INLINE_TRACE() | 105 DEFINE_INLINE_TRACE() |
106 { | 106 { |
107 visitor->trace(player); | 107 visitor->trace(animation); |
108 visitor->trace(from); | 108 visitor->trace(from); |
109 visitor->trace(to); | 109 visitor->trace(to); |
110 } | 110 } |
111 | 111 |
112 RefPtrWillBeMember<AnimationPlayer> player; | 112 RefPtrWillBeMember<Animation> animation; |
113 RawPtrWillBeMember<const AnimatableValue> from; | 113 RawPtrWillBeMember<const AnimatableValue> from; |
114 RawPtrWillBeMember<const AnimatableValue> to; | 114 RawPtrWillBeMember<const AnimatableValue> to; |
115 }; | 115 }; |
116 | 116 |
117 using AnimationMap = WillBeHeapHashMap<AtomicString, RefPtrWillBeMember<Runn
ingAnimation>>; | 117 using AnimationMap = WillBeHeapHashMap<AtomicString, RefPtrWillBeMember<Runn
ingAnimation>>; |
118 AnimationMap m_animations; | 118 AnimationMap m_animations; |
119 | 119 |
120 using TransitionMap = WillBeHeapHashMap<CSSPropertyID, RunningTransition>; | 120 using TransitionMap = WillBeHeapHashMap<CSSPropertyID, RunningTransition>; |
121 TransitionMap m_transitions; | 121 TransitionMap m_transitions; |
122 | 122 |
123 OwnPtrWillBeMember<CSSAnimationUpdate> m_pendingUpdate; | 123 OwnPtrWillBeMember<CSSAnimationUpdate> m_pendingUpdate; |
124 | 124 |
125 ActiveInterpolationMap m_previousActiveInterpolationsForAnimations; | 125 ActiveInterpolationMap m_previousActiveInterpolationsForAnimations; |
126 | 126 |
127 static void calculateAnimationUpdate(CSSAnimationUpdate*, const Element* ani
matingElement, Element&, const ComputedStyle&, ComputedStyle* parentStyle, Style
Resolver*); | 127 static void calculateAnimationUpdate(CSSAnimationUpdate*, const Element* ani
matingElement, Element&, const ComputedStyle&, ComputedStyle* parentStyle, Style
Resolver*); |
128 static void calculateTransitionUpdate(CSSAnimationUpdate*, const Element* an
imatingElement, const ComputedStyle&); | 128 static void calculateTransitionUpdate(CSSAnimationUpdate*, const Element* an
imatingElement, const ComputedStyle&); |
129 static void calculateTransitionUpdateForProperty(CSSPropertyID, CSSPropertyI
D eventId, const CSSTransitionData&, size_t transitionIndex, const ComputedStyle
& oldStyle, const ComputedStyle&, const TransitionMap* activeTransitions, CSSAni
mationUpdate*, const Element*); | 129 static void calculateTransitionUpdateForProperty(CSSPropertyID, CSSPropertyI
D eventId, const CSSTransitionData&, size_t transitionIndex, const ComputedStyle
& oldStyle, const ComputedStyle&, const TransitionMap* activeTransitions, CSSAni
mationUpdate*, const Element*); |
130 | 130 |
131 static void calculateAnimationActiveInterpolations(CSSAnimationUpdate*, cons
t Element* animatingElement, double timelineCurrentTime); | 131 static void calculateAnimationActiveInterpolations(CSSAnimationUpdate*, cons
t Element* animatingElement, double timelineCurrentTime); |
132 static void calculateTransitionActiveInterpolations(CSSAnimationUpdate*, con
st Element* animatingElement, double timelineCurrentTime); | 132 static void calculateTransitionActiveInterpolations(CSSAnimationUpdate*, con
st Element* animatingElement, double timelineCurrentTime); |
133 | 133 |
134 class AnimationEventDelegate final : public AnimationNode::EventDelegate { | 134 class AnimationEventDelegate final : public AnimationEffect::EventDelegate { |
135 public: | 135 public: |
136 AnimationEventDelegate(Element* animationTarget, const AtomicString& nam
e) | 136 AnimationEventDelegate(Element* animationTarget, const AtomicString& nam
e) |
137 : m_animationTarget(animationTarget) | 137 : m_animationTarget(animationTarget) |
138 , m_name(name) | 138 , m_name(name) |
139 , m_previousPhase(AnimationNode::PhaseNone) | 139 , m_previousPhase(AnimationEffect::PhaseNone) |
140 , m_previousIteration(nullValue()) | 140 , m_previousIteration(nullValue()) |
141 { | 141 { |
142 } | 142 } |
143 virtual bool requiresIterationEvents(const AnimationNode&) override; | 143 virtual bool requiresIterationEvents(const AnimationEffect&) override; |
144 virtual void onEventCondition(const AnimationNode&) override; | 144 virtual void onEventCondition(const AnimationEffect&) override; |
145 DECLARE_VIRTUAL_TRACE(); | 145 DECLARE_VIRTUAL_TRACE(); |
146 | 146 |
147 private: | 147 private: |
148 const Element& animationTarget() const { return *m_animationTarget; } | 148 const Element& animationTarget() const { return *m_animationTarget; } |
149 EventTarget* eventTarget() const; | 149 EventTarget* eventTarget() const; |
150 Document& document() const { return m_animationTarget->document(); } | 150 Document& document() const { return m_animationTarget->document(); } |
151 | 151 |
152 void maybeDispatch(Document::ListenerType, const AtomicString& eventName
, double elapsedTime); | 152 void maybeDispatch(Document::ListenerType, const AtomicString& eventName
, double elapsedTime); |
153 RawPtrWillBeMember<Element> m_animationTarget; | 153 RawPtrWillBeMember<Element> m_animationTarget; |
154 const AtomicString m_name; | 154 const AtomicString m_name; |
155 AnimationNode::Phase m_previousPhase; | 155 AnimationEffect::Phase m_previousPhase; |
156 double m_previousIteration; | 156 double m_previousIteration; |
157 }; | 157 }; |
158 | 158 |
159 class TransitionEventDelegate final : public AnimationNode::EventDelegate { | 159 class TransitionEventDelegate final : public AnimationEffect::EventDelegate
{ |
160 public: | 160 public: |
161 TransitionEventDelegate(Element* transitionTarget, CSSPropertyID propert
y) | 161 TransitionEventDelegate(Element* transitionTarget, CSSPropertyID propert
y) |
162 : m_transitionTarget(transitionTarget) | 162 : m_transitionTarget(transitionTarget) |
163 , m_property(property) | 163 , m_property(property) |
164 , m_previousPhase(AnimationNode::PhaseNone) | 164 , m_previousPhase(AnimationEffect::PhaseNone) |
165 { | 165 { |
166 } | 166 } |
167 virtual bool requiresIterationEvents(const AnimationNode&) override { re
turn false; } | 167 virtual bool requiresIterationEvents(const AnimationEffect&) override {
return false; } |
168 virtual void onEventCondition(const AnimationNode&) override; | 168 virtual void onEventCondition(const AnimationEffect&) override; |
169 DECLARE_VIRTUAL_TRACE(); | 169 DECLARE_VIRTUAL_TRACE(); |
170 | 170 |
171 private: | 171 private: |
172 const Element& transitionTarget() const { return *m_transitionTarget; } | 172 const Element& transitionTarget() const { return *m_transitionTarget; } |
173 EventTarget* eventTarget() const; | 173 EventTarget* eventTarget() const; |
174 PseudoId pseudoId() const { return m_transitionTarget->pseudoId(); } | 174 PseudoId pseudoId() const { return m_transitionTarget->pseudoId(); } |
175 Document& document() const { return m_transitionTarget->document(); } | 175 Document& document() const { return m_transitionTarget->document(); } |
176 | 176 |
177 RawPtrWillBeMember<Element> m_transitionTarget; | 177 RawPtrWillBeMember<Element> m_transitionTarget; |
178 const CSSPropertyID m_property; | 178 const CSSPropertyID m_property; |
179 AnimationNode::Phase m_previousPhase; | 179 AnimationEffect::Phase m_previousPhase; |
180 }; | 180 }; |
181 }; | 181 }; |
182 | 182 |
183 } // namespace blink | 183 } // namespace blink |
184 | 184 |
185 #endif | 185 #endif |
OLD | NEW |