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

Side by Side Diff: Source/core/animation/KeyframeEffectModel.h

Issue 851693007: Prepare for responsive CSS animations. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 10 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
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 using PropertySpecificKeyframeVector = WillBeHeapVector<OwnPtrWillBeMember<K eyframe::PropertySpecificKeyframe>>; 57 using PropertySpecificKeyframeVector = WillBeHeapVector<OwnPtrWillBeMember<K eyframe::PropertySpecificKeyframe>>;
58 class PropertySpecificKeyframeGroup : public NoBaseWillBeGarbageCollected<Pr opertySpecificKeyframeGroup> { 58 class PropertySpecificKeyframeGroup : public NoBaseWillBeGarbageCollected<Pr opertySpecificKeyframeGroup> {
59 public: 59 public:
60 void appendKeyframe(PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKey frame>); 60 void appendKeyframe(PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKey frame>);
61 const PropertySpecificKeyframeVector& keyframes() const { return m_keyfr ames; } 61 const PropertySpecificKeyframeVector& keyframes() const { return m_keyfr ames; }
62 62
63 void trace(Visitor*); 63 void trace(Visitor*);
64 64
65 private: 65 private:
66 void removeRedundantKeyframes(); 66 void removeRedundantKeyframes();
67 bool addSyntheticKeyframeIfRequired(); 67 bool addSyntheticKeyframeIfRequired(PassRefPtrWillBeRawPtr<TimingFunctio n> neutralKeyframeEasing);
68 68
69 PropertySpecificKeyframeVector m_keyframes; 69 PropertySpecificKeyframeVector m_keyframes;
70 70
71 friend class KeyframeEffectModelBase; 71 friend class KeyframeEffectModelBase;
72 }; 72 };
73 73
74 bool isReplaceOnly(); 74 bool isReplaceOnly();
75 75
76 PropertySet properties() const; 76 PropertySet properties() const;
77 77
(...skipping 24 matching lines...) Expand all
102 virtual void trace(Visitor*) override; 102 virtual void trace(Visitor*) override;
103 103
104 // FIXME: This is a hack used to resolve CSSValues to AnimatableValues while we have a valid handle on an element. 104 // FIXME: This is a hack used to resolve CSSValues to AnimatableValues while we have a valid handle on an element.
105 // This should be removed once StringKeyframes no longer uses InterpolableAn imatableValues. 105 // This should be removed once StringKeyframes no longer uses InterpolableAn imatableValues.
106 void forceConversionsToAnimatableValues(Element* element) 106 void forceConversionsToAnimatableValues(Element* element)
107 { 107 {
108 ensureKeyframeGroups(); 108 ensureKeyframeGroups();
109 ensureInterpolationEffect(element); 109 ensureInterpolationEffect(element);
110 } 110 }
111 111
112 // FIXME: Remove this once CompositorAnimations no longer depends on Animata bleValues
113 void snapshotCompositableProperties(const Element*, const LayoutStyle&);
114 void updateNeutralKeyframeAnimatableValues(CSSPropertyID, PassRefPtrWillBeRa wPtr<AnimatableValue>);
115
116 template<typename T>
117 inline void forEachInterpolation(const T& callback) { m_interpolationEffect- >forEachInterpolation(callback); }
118
112 static KeyframeVector normalizedKeyframesForInspector(const KeyframeVector& keyframes) { return normalizedKeyframes(keyframes); } 119 static KeyframeVector normalizedKeyframesForInspector(const KeyframeVector& keyframes) { return normalizedKeyframes(keyframes); }
113 120
121 bool affects(CSSPropertyID property) const override
122 {
123 ensureKeyframeGroups();
124 return m_keyframeGroups->contains(property);
125 }
126
114 protected: 127 protected:
128 KeyframeEffectModelBase(PassRefPtrWillBeRawPtr<TimingFunction> neutralKeyfra meEasing)
129 : m_neutralKeyframeEasing(neutralKeyframeEasing)
130 {
131 }
132
115 static KeyframeVector normalizedKeyframes(const KeyframeVector& keyframes); 133 static KeyframeVector normalizedKeyframes(const KeyframeVector& keyframes);
116 134
117 // Lazily computes the groups of property-specific keyframes. 135 // Lazily computes the groups of property-specific keyframes.
118 void ensureKeyframeGroups() const; 136 void ensureKeyframeGroups() const;
119 void ensureInterpolationEffect(Element* = nullptr) const; 137 void ensureInterpolationEffect(Element* = nullptr) const;
120 138
121 KeyframeVector m_keyframes; 139 KeyframeVector m_keyframes;
122 // The spec describes filtering the normalized keyframes at sampling time 140 // The spec describes filtering the normalized keyframes at sampling time
123 // to get the 'property-specific keyframes'. For efficiency, we cache the 141 // to get the 'property-specific keyframes'. For efficiency, we cache the
124 // property-specific lists. 142 // property-specific lists.
125 using KeyframeGroupMap = WillBeHeapHashMap<CSSPropertyID, OwnPtrWillBeMember <PropertySpecificKeyframeGroup>>; 143 using KeyframeGroupMap = WillBeHeapHashMap<CSSPropertyID, OwnPtrWillBeMember <PropertySpecificKeyframeGroup>>;
126 mutable OwnPtrWillBeMember<KeyframeGroupMap> m_keyframeGroups; 144 mutable OwnPtrWillBeMember<KeyframeGroupMap> m_keyframeGroups;
127 mutable RefPtrWillBeMember<InterpolationEffect> m_interpolationEffect; 145 mutable RefPtrWillBeMember<InterpolationEffect> m_interpolationEffect;
146 RefPtrWillBeMember<TimingFunction> m_neutralKeyframeEasing;
128 147
129 mutable bool m_hasSyntheticKeyframes; 148 mutable bool m_hasSyntheticKeyframes;
130 149
131 friend class KeyframeEffectModelTest; 150 friend class KeyframeEffectModelTest;
132
133 bool affects(CSSPropertyID property) const override
134 {
135 ensureKeyframeGroups();
136 return m_keyframeGroups->contains(property);
137 }
138 }; 151 };
139 152
140 template <class Keyframe> 153 template <class Keyframe>
141 class KeyframeEffectModel final : public KeyframeEffectModelBase { 154 class KeyframeEffectModel final : public KeyframeEffectModelBase {
142 public: 155 public:
143 using KeyframeVector = WillBeHeapVector<RefPtrWillBeMember<Keyframe>>; 156 using KeyframeVector = WillBeHeapVector<RefPtrWillBeMember<Keyframe>>;
144 static PassRefPtrWillBeRawPtr<KeyframeEffectModel<Keyframe>> create(const Ke yframeVector& keyframes) { return adoptRefWillBeNoop(new KeyframeEffectModel(key frames)); } 157 static PassRefPtrWillBeRawPtr<KeyframeEffectModel<Keyframe>> create(const Ke yframeVector& keyframes, PassRefPtrWillBeRawPtr<TimingFunction> neutralKeyframeE asing = nullptr)
158 {
159 return adoptRefWillBeNoop(new KeyframeEffectModel(keyframes, neutralKeyf rameEasing));
160 }
145 161
146 private: 162 private:
147 KeyframeEffectModel(const KeyframeVector& keyframes) 163 KeyframeEffectModel(const KeyframeVector& keyframes, PassRefPtrWillBeRawPtr< TimingFunction> neutralKeyframeEasing)
164 : KeyframeEffectModelBase(neutralKeyframeEasing)
148 { 165 {
149 m_keyframes.appendVector(keyframes); 166 m_keyframes.appendVector(keyframes);
150 } 167 }
151 168
152 virtual bool isAnimatableValueKeyframeEffectModel() const { return false; } 169 virtual bool isAnimatableValueKeyframeEffectModel() const { return false; }
153 virtual bool isStringKeyframeEffectModel() const { return false; } 170 virtual bool isStringKeyframeEffectModel() const { return false; }
154
155 }; 171 };
156 172
157 using KeyframeVector = KeyframeEffectModelBase::KeyframeVector; 173 using KeyframeVector = KeyframeEffectModelBase::KeyframeVector;
158 using PropertySpecificKeyframeVector = KeyframeEffectModelBase::PropertySpecific KeyframeVector; 174 using PropertySpecificKeyframeVector = KeyframeEffectModelBase::PropertySpecific KeyframeVector;
159 175
160 using AnimatableValueKeyframeEffectModel = KeyframeEffectModel<AnimatableValueKe yframe>; 176 using AnimatableValueKeyframeEffectModel = KeyframeEffectModel<AnimatableValueKe yframe>;
161 using AnimatableValueKeyframeVector = AnimatableValueKeyframeEffectModel::Keyfra meVector; 177 using AnimatableValueKeyframeVector = AnimatableValueKeyframeEffectModel::Keyfra meVector;
162 using AnimatableValuePropertySpecificKeyframeVector = AnimatableValueKeyframeEff ectModel::PropertySpecificKeyframeVector; 178 using AnimatableValuePropertySpecificKeyframeVector = AnimatableValueKeyframeEff ectModel::PropertySpecificKeyframeVector;
163 179
164 using StringKeyframeEffectModel = KeyframeEffectModel<StringKeyframe>; 180 using StringKeyframeEffectModel = KeyframeEffectModel<StringKeyframe>;
165 using StringKeyframeVector = StringKeyframeEffectModel::KeyframeVector; 181 using StringKeyframeVector = StringKeyframeEffectModel::KeyframeVector;
166 using StringPropertySpecificKeyframeVector = StringKeyframeEffectModel::Property SpecificKeyframeVector; 182 using StringPropertySpecificKeyframeVector = StringKeyframeEffectModel::Property SpecificKeyframeVector;
167 183
168 DEFINE_TYPE_CASTS(KeyframeEffectModelBase, AnimationEffect, value, value->isKeyf rameEffectModel(), value.isKeyframeEffectModel()); 184 DEFINE_TYPE_CASTS(KeyframeEffectModelBase, AnimationEffect, value, value->isKeyf rameEffectModel(), value.isKeyframeEffectModel());
169 DEFINE_TYPE_CASTS(AnimatableValueKeyframeEffectModel, KeyframeEffectModelBase, v alue, value->isAnimatableValueKeyframeEffectModel(), value.isAnimatableValueKeyf rameEffectModel()); 185 DEFINE_TYPE_CASTS(AnimatableValueKeyframeEffectModel, KeyframeEffectModelBase, v alue, value->isAnimatableValueKeyframeEffectModel(), value.isAnimatableValueKeyf rameEffectModel());
186 DEFINE_TYPE_CASTS(StringKeyframeEffectModel, KeyframeEffectModelBase, value, val ue->isStringKeyframeEffectModel(), value.isStringKeyframeEffectModel());
170 187
171 inline const AnimatableValueKeyframeEffectModel* toAnimatableValueKeyframeEffect Model(const AnimationEffect* base) 188 inline const AnimatableValueKeyframeEffectModel* toAnimatableValueKeyframeEffect Model(const AnimationEffect* base)
172 { 189 {
173 return toAnimatableValueKeyframeEffectModel(toKeyframeEffectModelBase(base)) ; 190 return toAnimatableValueKeyframeEffectModel(toKeyframeEffectModelBase(base)) ;
174 } 191 }
175 192
176 inline AnimatableValueKeyframeEffectModel* toAnimatableValueKeyframeEffectModel( AnimationEffect* base) 193 inline AnimatableValueKeyframeEffectModel* toAnimatableValueKeyframeEffectModel( AnimationEffect* base)
177 { 194 {
178 return toAnimatableValueKeyframeEffectModel(toKeyframeEffectModelBase(base)) ; 195 return toAnimatableValueKeyframeEffectModel(toKeyframeEffectModelBase(base)) ;
179 } 196 }
180 197
198 inline const StringKeyframeEffectModel* toStringKeyframeEffectModel(const Animat ionEffect* base)
199 {
200 return toStringKeyframeEffectModel(toKeyframeEffectModelBase(base));
201 }
202
203 inline StringKeyframeEffectModel* toStringKeyframeEffectModel(AnimationEffect* b ase)
204 {
205 return toStringKeyframeEffectModel(toKeyframeEffectModelBase(base));
206 }
207
181 template <> 208 template <>
182 inline bool KeyframeEffectModel<AnimatableValueKeyframe>::isAnimatableValueKeyfr ameEffectModel() const { return true; } 209 inline bool KeyframeEffectModel<AnimatableValueKeyframe>::isAnimatableValueKeyfr ameEffectModel() const { return true; }
183 210
184 template <> 211 template <>
185 inline bool KeyframeEffectModel<StringKeyframe>::isStringKeyframeEffectModel() c onst { return true; } 212 inline bool KeyframeEffectModel<StringKeyframe>::isStringKeyframeEffectModel() c onst { return true; }
186 213
187 } // namespace blink 214 } // namespace blink
188 215
189 #endif // KeyframeEffectModel_h 216 #endif // KeyframeEffectModel_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698