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