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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 namespace blink { | 50 namespace blink { |
51 | 51 |
52 class Element; | 52 class Element; |
53 class KeyframeEffectModelTest; | 53 class KeyframeEffectModelTest; |
54 | 54 |
55 class CORE_EXPORT KeyframeEffectModelBase : public EffectModel { | 55 class CORE_EXPORT KeyframeEffectModelBase : public EffectModel { |
56 public: | 56 public: |
57 // FIXME: Implement accumulation. | 57 // FIXME: Implement accumulation. |
58 | 58 |
59 using PropertySpecificKeyframeVector = WillBeHeapVector<OwnPtrWillBeMember<K
eyframe::PropertySpecificKeyframe>>; | 59 using PropertySpecificKeyframeVector = Vector<OwnPtr<Keyframe::PropertySpeci
ficKeyframe>>; |
60 class PropertySpecificKeyframeGroup : public NoBaseWillBeGarbageCollected<Pr
opertySpecificKeyframeGroup> { | 60 class PropertySpecificKeyframeGroup { |
61 public: | 61 public: |
62 void appendKeyframe(PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKey
frame>); | 62 void appendKeyframe(PassOwnPtr<Keyframe::PropertySpecificKeyframe>); |
63 const PropertySpecificKeyframeVector& keyframes() const { return m_keyfr
ames; } | 63 const PropertySpecificKeyframeVector& keyframes() const { return m_keyfr
ames; } |
64 | 64 |
65 DECLARE_TRACE(); | |
66 | |
67 private: | 65 private: |
68 void removeRedundantKeyframes(); | 66 void removeRedundantKeyframes(); |
69 bool addSyntheticKeyframeIfRequired(PassRefPtr<TimingFunction> neutralKe
yframeEasing); | 67 bool addSyntheticKeyframeIfRequired(PassRefPtr<TimingFunction> neutralKe
yframeEasing); |
70 | 68 |
71 PropertySpecificKeyframeVector m_keyframes; | 69 PropertySpecificKeyframeVector m_keyframes; |
72 | 70 |
73 friend class KeyframeEffectModelBase; | 71 friend class KeyframeEffectModelBase; |
74 }; | 72 }; |
75 | 73 |
76 bool isReplaceOnly(); | 74 bool isReplaceOnly(); |
77 | 75 |
78 PropertyHandleSet properties() const; | 76 PropertyHandleSet properties() const; |
79 | 77 |
80 using KeyframeVector = WillBeHeapVector<RefPtrWillBeMember<Keyframe>>; | 78 using KeyframeVector = Vector<RefPtr<Keyframe>>; |
81 const KeyframeVector& getFrames() const { return m_keyframes; } | 79 const KeyframeVector& getFrames() const { return m_keyframes; } |
82 void setFrames(KeyframeVector& keyframes); | 80 void setFrames(KeyframeVector& keyframes); |
83 | 81 |
84 const PropertySpecificKeyframeVector& getPropertySpecificKeyframes(PropertyH
andle property) const | 82 const PropertySpecificKeyframeVector& getPropertySpecificKeyframes(PropertyH
andle property) const |
85 { | 83 { |
86 ensureKeyframeGroups(); | 84 ensureKeyframeGroups(); |
87 return m_keyframeGroups->get(property)->keyframes(); | 85 return m_keyframeGroups->get(property)->keyframes(); |
88 } | 86 } |
89 | 87 |
90 // EffectModel implementation. | 88 // EffectModel implementation. |
91 void sample(int iteration, double fraction, double iterationDuration, OwnPtr
WillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>>&) const overri
de; | 89 void sample(int iteration, double fraction, double iterationDuration, OwnPtr
WillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>>&) const overri
de; |
92 | 90 |
93 bool isKeyframeEffectModel() const override { return true; } | 91 bool isKeyframeEffectModel() const override { return true; } |
94 | 92 |
95 virtual bool isAnimatableValueKeyframeEffectModel() const { return false; } | 93 virtual bool isAnimatableValueKeyframeEffectModel() const { return false; } |
96 virtual bool isStringKeyframeEffectModel() const { return false; } | 94 virtual bool isStringKeyframeEffectModel() const { return false; } |
97 | 95 |
98 bool hasSyntheticKeyframes() const | 96 bool hasSyntheticKeyframes() const |
99 { | 97 { |
100 ensureKeyframeGroups(); | 98 ensureKeyframeGroups(); |
101 return m_hasSyntheticKeyframes; | 99 return m_hasSyntheticKeyframes; |
102 } | 100 } |
103 | 101 |
104 DECLARE_VIRTUAL_TRACE(); | 102 DECLARE_VIRTUAL_TRACE(); |
105 | 103 |
106 // 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. |
107 // This should be removed once AnimatableValues are obsolete. | 105 // This should be removed once AnimatableValues are obsolete. |
108 void forceConversionsToAnimatableValues(Element&, const ComputedStyle* baseS
tyle); | 106 void forceConversionsToAnimatableValues(Element&, const ComputedStyle* baseS
tyle); |
109 bool updateNeutralKeyframeAnimatableValues(CSSPropertyID, PassRefPtrWillBeRa
wPtr<AnimatableValue>); | 107 bool updateNeutralKeyframeAnimatableValues(CSSPropertyID, PassRefPtr<Animata
bleValue>); |
110 | 108 |
111 template<typename T> | 109 template<typename T> |
112 inline void forEachInterpolation(const T& callback) { m_interpolationEffect-
>forEachInterpolation(callback); } | 110 inline void forEachInterpolation(const T& callback) { m_interpolationEffect-
>forEachInterpolation(callback); } |
113 | 111 |
114 static KeyframeVector normalizedKeyframesForInspector(const KeyframeVector&
keyframes) { return normalizedKeyframes(keyframes); } | 112 static KeyframeVector normalizedKeyframesForInspector(const KeyframeVector&
keyframes) { return normalizedKeyframes(keyframes); } |
115 | 113 |
116 bool affects(PropertyHandle property) const override | 114 bool affects(PropertyHandle property) const override |
117 { | 115 { |
118 ensureKeyframeGroups(); | 116 ensureKeyframeGroups(); |
119 return m_keyframeGroups->contains(property); | 117 return m_keyframeGroups->contains(property); |
(...skipping 11 matching lines...) Expand all Loading... |
131 | 129 |
132 // Lazily computes the groups of property-specific keyframes. | 130 // Lazily computes the groups of property-specific keyframes. |
133 void ensureKeyframeGroups() const; | 131 void ensureKeyframeGroups() const; |
134 void ensureInterpolationEffect(Element* = nullptr, const ComputedStyle* base
Style = nullptr) const; | 132 void ensureInterpolationEffect(Element* = nullptr, const ComputedStyle* base
Style = nullptr) const; |
135 void snapshotCompositableProperties(Element&, const ComputedStyle* baseStyle
); | 133 void snapshotCompositableProperties(Element&, const ComputedStyle* baseStyle
); |
136 | 134 |
137 KeyframeVector m_keyframes; | 135 KeyframeVector m_keyframes; |
138 // The spec describes filtering the normalized keyframes at sampling time | 136 // The spec describes filtering the normalized keyframes at sampling time |
139 // to get the 'property-specific keyframes'. For efficiency, we cache the | 137 // to get the 'property-specific keyframes'. For efficiency, we cache the |
140 // property-specific lists. | 138 // property-specific lists. |
141 using KeyframeGroupMap = WillBeHeapHashMap<PropertyHandle, OwnPtrWillBeMembe
r<PropertySpecificKeyframeGroup>>; | 139 using KeyframeGroupMap = HashMap<PropertyHandle, OwnPtr<PropertySpecificKeyf
rameGroup>>; |
142 mutable OwnPtrWillBeMember<KeyframeGroupMap> m_keyframeGroups; | 140 mutable OwnPtr<KeyframeGroupMap> m_keyframeGroups; |
143 mutable RefPtrWillBeMember<InterpolationEffect> m_interpolationEffect; | 141 mutable RefPtrWillBeMember<InterpolationEffect> m_interpolationEffect; |
144 RefPtr<TimingFunction> m_neutralKeyframeEasing; | 142 RefPtr<TimingFunction> m_neutralKeyframeEasing; |
145 | 143 |
146 mutable bool m_hasSyntheticKeyframes; | 144 mutable bool m_hasSyntheticKeyframes; |
147 | 145 |
148 friend class KeyframeEffectModelTest; | 146 friend class KeyframeEffectModelTest; |
149 }; | 147 }; |
150 | 148 |
151 template <class Keyframe> | 149 template <class Keyframe> |
152 class KeyframeEffectModel final : public KeyframeEffectModelBase { | 150 class KeyframeEffectModel final : public KeyframeEffectModelBase { |
153 public: | 151 public: |
154 using KeyframeVector = WillBeHeapVector<RefPtrWillBeMember<Keyframe>>; | 152 using KeyframeVector = Vector<RefPtr<Keyframe>>; |
155 static PassRefPtrWillBeRawPtr<KeyframeEffectModel<Keyframe>> create(const Ke
yframeVector& keyframes, PassRefPtrWillBeRawPtr<TimingFunction> neutralKeyframeE
asing = nullptr) | 153 static PassRefPtrWillBeRawPtr<KeyframeEffectModel<Keyframe>> create(const Ke
yframeVector& keyframes, PassRefPtrWillBeRawPtr<TimingFunction> neutralKeyframeE
asing = nullptr) |
156 { | 154 { |
157 return adoptRefWillBeNoop(new KeyframeEffectModel(keyframes, neutralKeyf
rameEasing)); | 155 return adoptRefWillBeNoop(new KeyframeEffectModel(keyframes, neutralKeyf
rameEasing)); |
158 } | 156 } |
159 | 157 |
160 private: | 158 private: |
161 KeyframeEffectModel(const KeyframeVector& keyframes, PassRefPtrWillBeRawPtr<
TimingFunction> neutralKeyframeEasing) | 159 KeyframeEffectModel(const KeyframeVector& keyframes, PassRefPtrWillBeRawPtr<
TimingFunction> neutralKeyframeEasing) |
162 : KeyframeEffectModelBase(neutralKeyframeEasing) | 160 : KeyframeEffectModelBase(neutralKeyframeEasing) |
163 { | 161 { |
164 m_keyframes.appendVector(keyframes); | 162 m_keyframes.appendVector(keyframes); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 | 203 |
206 template <> | 204 template <> |
207 inline bool KeyframeEffectModel<AnimatableValueKeyframe>::isAnimatableValueKeyfr
ameEffectModel() const { return true; } | 205 inline bool KeyframeEffectModel<AnimatableValueKeyframe>::isAnimatableValueKeyfr
ameEffectModel() const { return true; } |
208 | 206 |
209 template <> | 207 template <> |
210 inline bool KeyframeEffectModel<StringKeyframe>::isStringKeyframeEffectModel() c
onst { return true; } | 208 inline bool KeyframeEffectModel<StringKeyframe>::isStringKeyframeEffectModel() c
onst { return true; } |
211 | 209 |
212 } // namespace blink | 210 } // namespace blink |
213 | 211 |
214 #endif // KeyframeEffectModel_h | 212 #endif // KeyframeEffectModel_h |
OLD | NEW |