Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: Source/core/animation/css/CSSAnimations.h

Issue 212143002: Oilpan: Move CSSAnimations, CSSAnimationUpdate and ActiveAnimations to oilpan's heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 namespace WebCore { 46 namespace WebCore {
47 47
48 class Element; 48 class Element;
49 class StylePropertyShorthand; 49 class StylePropertyShorthand;
50 class StyleResolver; 50 class StyleResolver;
51 class StyleRuleKeyframes; 51 class StyleRuleKeyframes;
52 52
53 // This class stores the CSS Animations/Transitions information we use during a style recalc. 53 // This class stores the CSS Animations/Transitions information we use during a style recalc.
54 // This includes updates to animations/transitions as well as the Interpolations to be applied. 54 // This includes updates to animations/transitions as well as the Interpolations to be applied.
55 class CSSAnimationUpdate FINAL { 55 class CSSAnimationUpdate FINAL : public NoBaseWillBeGarbageCollectedFinalized<CS SAnimationUpdate> {
56 public: 56 public:
57 void startAnimation(AtomicString& animationName, const HashSet<RefPtr<InertA nimation> >& animations) 57 void startAnimation(AtomicString& animationName, const HashSet<RefPtr<InertA nimation> >& animations)
58 { 58 {
59 NewAnimation newAnimation; 59 NewAnimation newAnimation;
60 newAnimation.name = animationName; 60 newAnimation.name = animationName;
61 newAnimation.animations = animations; 61 newAnimation.animations = animations;
62 m_newAnimations.append(newAnimation); 62 m_newAnimations.append(newAnimation);
63 } 63 }
64 // Returns whether player has been cancelled and should be filtered during s tyle application. 64 // Returns whether player has been cancelled and should be filtered during s tyle application.
65 bool isCancelledAnimation(const AnimationPlayer* player) const { return m_ca ncelledAnimationAnimationPlayers.contains(player); } 65 bool isCancelledAnimation(const AnimationPlayer* player) const { return m_ca ncelledAnimationAnimationPlayers.contains(player); }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 { 102 {
103 visitor->trace(from); 103 visitor->trace(from);
104 visitor->trace(to); 104 visitor->trace(to);
105 } 105 }
106 106
107 CSSPropertyID id; 107 CSSPropertyID id;
108 RawPtrWillBeMember<const AnimatableValue> from; 108 RawPtrWillBeMember<const AnimatableValue> from;
109 RawPtrWillBeMember<const AnimatableValue> to; 109 RawPtrWillBeMember<const AnimatableValue> to;
110 RefPtr<InertAnimation> animation; 110 RefPtr<InertAnimation> animation;
111 }; 111 };
112 typedef WillBePersistentHeapHashMap<CSSPropertyID, NewTransition> NewTransit ionMap; 112 typedef WillBeHeapHashMap<CSSPropertyID, NewTransition> NewTransitionMap;
113 const NewTransitionMap& newTransitions() const { return m_newTransitions; } 113 const NewTransitionMap& newTransitions() const { return m_newTransitions; }
114 const HashSet<CSSPropertyID>& cancelledTransitions() const { return m_cancel ledTransitions; } 114 const HashSet<CSSPropertyID>& cancelledTransitions() const { return m_cancel ledTransitions; }
115 115
116 void adoptActiveInterpolationsForAnimations(WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& newMap) { newMap.swap(m_activeInterpolatio nsForAnimations); } 116 void adoptActiveInterpolationsForAnimations(WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& newMap) { newMap.swap(m_activeInterpolatio nsForAnimations); }
117 void adoptActiveInterpolationsForTransitions(WillBeHeapHashMap<CSSPropertyID , RefPtrWillBeMember<Interpolation> >& newMap) { newMap.swap(m_activeInterpolati onsForTransitions); } 117 void adoptActiveInterpolationsForTransitions(WillBeHeapHashMap<CSSPropertyID , RefPtrWillBeMember<Interpolation> >& newMap) { newMap.swap(m_activeInterpolati onsForTransitions); }
118 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpolationsForAnimations() const { return m_activeInterpolationsForAnim ations; } 118 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpolationsForAnimations() const { return m_activeInterpolationsForAnim ations; }
119 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpolationsForTransitions() const { return m_activeInterpolationsForTra nsitions; } 119 const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpolationsForTransitions() const { return m_activeInterpolationsForTra nsitions; }
120 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& active InterpolationsForAnimations() { return m_activeInterpolationsForAnimations; } 120 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& active InterpolationsForAnimations() { return m_activeInterpolationsForAnimations; }
121 121
122 bool isEmpty() const 122 bool isEmpty() const
123 { 123 {
124 return m_newAnimations.isEmpty() 124 return m_newAnimations.isEmpty()
125 && m_cancelledAnimationNames.isEmpty() 125 && m_cancelledAnimationNames.isEmpty()
126 && m_cancelledAnimationAnimationPlayers.isEmpty() 126 && m_cancelledAnimationAnimationPlayers.isEmpty()
127 && m_animationsWithPauseToggled.isEmpty() 127 && m_animationsWithPauseToggled.isEmpty()
128 && m_newTransitions.isEmpty() 128 && m_newTransitions.isEmpty()
129 && m_cancelledTransitions.isEmpty() 129 && m_cancelledTransitions.isEmpty()
130 && m_activeInterpolationsForAnimations.isEmpty() 130 && m_activeInterpolationsForAnimations.isEmpty()
131 && m_activeInterpolationsForTransitions.isEmpty(); 131 && m_activeInterpolationsForTransitions.isEmpty();
132 } 132 }
133
134 void trace(Visitor*);
135
133 private: 136 private:
134 // Order is significant since it defines the order in which new animations 137 // Order is significant since it defines the order in which new animations
135 // will be started. Note that there may be multiple animations present 138 // will be started. Note that there may be multiple animations present
136 // with the same name, due to the way in which we split up animations with 139 // with the same name, due to the way in which we split up animations with
137 // incomplete keyframes. 140 // incomplete keyframes.
138 Vector<NewAnimation> m_newAnimations; 141 Vector<NewAnimation> m_newAnimations;
139 Vector<AtomicString> m_cancelledAnimationNames; 142 Vector<AtomicString> m_cancelledAnimationNames;
140 HashSet<const AnimationPlayer*> m_cancelledAnimationAnimationPlayers; 143 HashSet<const AnimationPlayer*> m_cancelledAnimationAnimationPlayers;
haraken 2014/03/26 06:20:52 This raw pointer is safe, because this set just wa
141 Vector<AtomicString> m_animationsWithPauseToggled; 144 Vector<AtomicString> m_animationsWithPauseToggled;
142 145
143 NewTransitionMap m_newTransitions; 146 NewTransitionMap m_newTransitions;
144 HashSet<CSSPropertyID> m_cancelledTransitions; 147 HashSet<CSSPropertyID> m_cancelledTransitions;
145 148
146 WillBePersistentHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > m_activeInterpolationsForAnimations; 149 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > m_activ eInterpolationsForAnimations;
147 WillBePersistentHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > m_activeInterpolationsForTransitions; 150 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > m_activ eInterpolationsForTransitions;
148 }; 151 };
149 152
150 class CSSAnimations FINAL { 153 class CSSAnimations FINAL : public NoBaseWillBeGarbageCollectedFinalized<CSSAnim ations> {
151 public: 154 public:
152 // FIXME: This method is only used here and in the legacy animations 155 // FIXME: This method is only used here and in the legacy animations
153 // implementation. It should be made private or file-scope when the legacy 156 // implementation. It should be made private or file-scope when the legacy
154 // engine is removed. 157 // engine is removed.
155 static const StyleRuleKeyframes* matchScopedKeyframesRule(StyleResolver*, co nst Element*, const StringImpl*); 158 static const StyleRuleKeyframes* matchScopedKeyframesRule(StyleResolver*, co nst Element*, const StringImpl*);
156 159
157 static bool isAnimatableProperty(CSSPropertyID); 160 static bool isAnimatableProperty(CSSPropertyID);
158 static const StylePropertyShorthand& animatableProperties(); 161 static const StylePropertyShorthand& animatableProperties();
159 // FIXME: This should take a const ScopedStyleTree instead of a StyleResolve r. 162 // FIXME: This should take a const ScopedStyleTree instead of a StyleResolve r.
160 // We should also change the Element* to a const Element* 163 // We should also change the Element* to a const Element*
161 static PassOwnPtr<CSSAnimationUpdate> calculateUpdate(Element*, const Elemen t& parentElement, const RenderStyle&, RenderStyle* parentStyle, StyleResolver*); 164 static PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> calculateUpdate(Element*, const Element& parentElement, const RenderStyle&, RenderStyle* parentStyle, Styl eResolver*);
162 165
163 void setPendingUpdate(PassOwnPtr<CSSAnimationUpdate> update) { m_pendingUpda te = update; } 166 void setPendingUpdate(PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> update) { m _pendingUpdate = update; }
164 void maybeApplyPendingUpdate(Element*); 167 void maybeApplyPendingUpdate(Element*);
165 bool isEmpty() const { return m_animations.isEmpty() && m_transitions.isEmpt y() && !m_pendingUpdate; } 168 bool isEmpty() const { return m_animations.isEmpty() && m_transitions.isEmpt y() && !m_pendingUpdate; }
166 void cancel(); 169 void cancel();
167 170
171 void trace(Visitor*);
172
168 private: 173 private:
169 // Note that a single animation name may map to multiple players due to 174 // Note that a single animation name may map to multiple players due to
170 // the way in which we split up animations with incomplete keyframes. 175 // the way in which we split up animations with incomplete keyframes.
171 // FIXME: Once the Web Animations model supports groups, we could use a 176 // FIXME: Once the Web Animations model supports groups, we could use a
172 // ParGroup to drive multiple animations from a single AnimationPlayer. 177 // ParGroup to drive multiple animations from a single AnimationPlayer.
173 typedef HashMap<AtomicString, HashSet<RefPtr<AnimationPlayer> > > AnimationM ap; 178 typedef HashMap<AtomicString, HashSet<RefPtr<AnimationPlayer> > > AnimationM ap;
174 struct RunningTransition { 179 struct RunningTransition {
175 ALLOW_ONLY_INLINE_ALLOCATION(); 180 ALLOW_ONLY_INLINE_ALLOCATION();
176 public: 181 public:
177 void trace(Visitor* visitor) 182 void trace(Visitor* visitor)
178 { 183 {
179 visitor->trace(from); 184 visitor->trace(from);
180 visitor->trace(to); 185 visitor->trace(to);
181 } 186 }
182 187
183 Animation* transition; // The TransitionTimeline keeps the AnimationPlay ers alive 188 Animation* transition; // The TransitionTimeline keeps the AnimationPlay ers alive
184 RawPtrWillBeMember<const AnimatableValue> from; 189 RawPtrWillBeMember<const AnimatableValue> from;
185 RawPtrWillBeMember<const AnimatableValue> to; 190 RawPtrWillBeMember<const AnimatableValue> to;
186 }; 191 };
187 typedef WillBePersistentHeapHashMap<CSSPropertyID, RunningTransition> Transi tionMap; 192 typedef WillBeHeapHashMap<CSSPropertyID, RunningTransition> TransitionMap;
188 AnimationMap m_animations; 193 AnimationMap m_animations;
189 TransitionMap m_transitions; 194 TransitionMap m_transitions;
190 OwnPtr<CSSAnimationUpdate> m_pendingUpdate; 195 OwnPtrWillBeMember<CSSAnimationUpdate> m_pendingUpdate;
191 196
192 WillBePersistentHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > m_previousActiveInterpolationsForAnimations; 197 WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > m_previ ousActiveInterpolationsForAnimations;
193 198
194 static void calculateAnimationUpdate(CSSAnimationUpdate*, Element*, const El ement& parentElement, const RenderStyle&, RenderStyle* parentStyle, StyleResolve r*); 199 static void calculateAnimationUpdate(CSSAnimationUpdate*, Element*, const El ement& parentElement, const RenderStyle&, RenderStyle* parentStyle, StyleResolve r*);
195 static void calculateTransitionUpdate(CSSAnimationUpdate*, const Element*, c onst RenderStyle&); 200 static void calculateTransitionUpdate(CSSAnimationUpdate*, const Element*, c onst RenderStyle&);
196 static void calculateTransitionUpdateForProperty(CSSPropertyID, const CSSAni mationData*, const RenderStyle& oldStyle, const RenderStyle&, const TransitionMa p* activeTransitions, CSSAnimationUpdate*, const Element*); 201 static void calculateTransitionUpdateForProperty(CSSPropertyID, const CSSAni mationData*, const RenderStyle& oldStyle, const RenderStyle&, const TransitionMa p* activeTransitions, CSSAnimationUpdate*, const Element*);
197 202
198 static void calculateAnimationActiveInterpolations(CSSAnimationUpdate*, cons t Element*); 203 static void calculateAnimationActiveInterpolations(CSSAnimationUpdate*, cons t Element*);
199 static void calculateTransitionActiveInterpolations(CSSAnimationUpdate*, con st Element*); 204 static void calculateTransitionActiveInterpolations(CSSAnimationUpdate*, con st Element*);
200 205
201 class AnimationEventDelegate FINAL : public TimedItem::EventDelegate { 206 class AnimationEventDelegate FINAL : public TimedItem::EventDelegate {
202 public: 207 public:
(...skipping 19 matching lines...) Expand all
222 virtual void onEventCondition(const TimedItem*, bool isFirstSample, Time dItem::Phase previousPhase, double previousIteration) OVERRIDE; 227 virtual void onEventCondition(const TimedItem*, bool isFirstSample, Time dItem::Phase previousPhase, double previousIteration) OVERRIDE;
223 private: 228 private:
224 Element* m_target; 229 Element* m_target;
225 const CSSPropertyID m_property; 230 const CSSPropertyID m_property;
226 }; 231 };
227 }; 232 };
228 233
229 } // namespace WebCore 234 } // namespace WebCore
230 235
231 #endif 236 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698