Chromium Code Reviews| 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(); | 101 DECLARE_VIRTUAL_TRACE(); |
| 104 | 102 |
| 105 // FIXME: This is a hack used to resolve CSSValues to AnimatableValues while we have a valid handle on an element. | 103 // 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. | 104 // This should be removed once AnimatableValues are obsolete. |
| 107 void forceConversionsToAnimatableValues(Element&, const ComputedStyle* baseS tyle); | 105 void forceConversionsToAnimatableValues(Element&, const ComputedStyle* baseS tyle); |
| 108 bool updateNeutralKeyframeAnimatableValues(CSSPropertyID, PassRefPtrWillBeRa wPtr<AnimatableValue>); | 106 bool updateNeutralKeyframeAnimatableValues(CSSPropertyID, PassRefPtr<Animata bleValue>); |
| 109 | 107 |
| 110 template<typename T> | 108 template<typename T> |
| 111 inline void forEachInterpolation(const T& callback) { m_interpolationEffect- >forEachInterpolation(callback); } | 109 inline void forEachInterpolation(const T& callback) { m_interpolationEffect- >forEachInterpolation(callback); } |
| 112 | 110 |
| 113 static KeyframeVector normalizedKeyframesForInspector(const KeyframeVector& keyframes) { return normalizedKeyframes(keyframes); } | 111 static KeyframeVector normalizedKeyframesForInspector(const KeyframeVector& keyframes) { return normalizedKeyframes(keyframes); } |
| 114 | 112 |
| 115 bool affects(PropertyHandle property) const override | 113 bool affects(PropertyHandle property) const override |
| 116 { | 114 { |
| 117 ensureKeyframeGroups(); | 115 ensureKeyframeGroups(); |
| 118 return m_keyframeGroups->contains(property); | 116 return m_keyframeGroups->contains(property); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 130 | 128 |
| 131 // Lazily computes the groups of property-specific keyframes. | 129 // Lazily computes the groups of property-specific keyframes. |
| 132 void ensureKeyframeGroups() const; | 130 void ensureKeyframeGroups() const; |
| 133 void ensureInterpolationEffect(Element* = nullptr, const ComputedStyle* base Style = nullptr) const; | 131 void ensureInterpolationEffect(Element* = nullptr, const ComputedStyle* base Style = nullptr) const; |
| 134 void snapshotCompositableProperties(Element&, const ComputedStyle* baseStyle ); | 132 void snapshotCompositableProperties(Element&, const ComputedStyle* baseStyle ); |
| 135 | 133 |
| 136 KeyframeVector m_keyframes; | 134 KeyframeVector m_keyframes; |
| 137 // The spec describes filtering the normalized keyframes at sampling time | 135 // The spec describes filtering the normalized keyframes at sampling time |
| 138 // to get the 'property-specific keyframes'. For efficiency, we cache the | 136 // to get the 'property-specific keyframes'. For efficiency, we cache the |
| 139 // property-specific lists. | 137 // property-specific lists. |
| 140 using KeyframeGroupMap = WillBeHeapHashMap<PropertyHandle, OwnPtrWillBeMembe r<PropertySpecificKeyframeGroup>>; | 138 using KeyframeGroupMap = WillBeHeapHashMap<PropertyHandle, OwnPtrWillBeMembe r<PropertySpecificKeyframeGroup>>; |
|
sof
2015/09/02 13:02:12
The value type doesn't look correct now. OwnPtr<>
| |
| 141 mutable OwnPtrWillBeMember<KeyframeGroupMap> m_keyframeGroups; | 139 mutable OwnPtr<KeyframeGroupMap> m_keyframeGroups; |
| 142 mutable Member<InterpolationEffect> m_interpolationEffect; | 140 mutable RefPtr<InterpolationEffect> m_interpolationEffect; |
| 143 RefPtr<TimingFunction> m_neutralKeyframeEasing; | 141 RefPtr<TimingFunction> m_neutralKeyframeEasing; |
| 144 | 142 |
| 145 mutable bool m_hasSyntheticKeyframes; | 143 mutable bool m_hasSyntheticKeyframes; |
| 146 | 144 |
| 147 friend class KeyframeEffectModelTest; | 145 friend class KeyframeEffectModelTest; |
| 148 }; | 146 }; |
| 149 | 147 |
| 150 template <class Keyframe> | 148 template <class Keyframe> |
| 151 class KeyframeEffectModel final : public KeyframeEffectModelBase { | 149 class KeyframeEffectModel final : public KeyframeEffectModelBase { |
| 152 public: | 150 public: |
| 153 using KeyframeVector = WillBeHeapVector<RefPtrWillBeMember<Keyframe>>; | 151 using KeyframeVector = Vector<RefPtr<Keyframe>>; |
| 154 static KeyframeEffectModel<Keyframe>* create(const KeyframeVector& keyframes , PassRefPtrWillBeRawPtr<TimingFunction> neutralKeyframeEasing = nullptr) | 152 static KeyframeEffectModel<Keyframe>* create(const KeyframeVector& keyframes , PassRefPtrWillBeRawPtr<TimingFunction> neutralKeyframeEasing = nullptr) |
| 155 { | 153 { |
| 156 return new KeyframeEffectModel(keyframes, neutralKeyframeEasing); | 154 return new KeyframeEffectModel(keyframes, neutralKeyframeEasing); |
| 157 } | 155 } |
| 158 | 156 |
| 159 private: | 157 private: |
| 160 KeyframeEffectModel(const KeyframeVector& keyframes, PassRefPtrWillBeRawPtr< TimingFunction> neutralKeyframeEasing) | 158 KeyframeEffectModel(const KeyframeVector& keyframes, PassRefPtrWillBeRawPtr< TimingFunction> neutralKeyframeEasing) |
| 161 : KeyframeEffectModelBase(neutralKeyframeEasing) | 159 : KeyframeEffectModelBase(neutralKeyframeEasing) |
| 162 { | 160 { |
| 163 m_keyframes.appendVector(keyframes); | 161 m_keyframes.appendVector(keyframes); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 | 202 |
| 205 template <> | 203 template <> |
| 206 inline bool KeyframeEffectModel<AnimatableValueKeyframe>::isAnimatableValueKeyfr ameEffectModel() const { return true; } | 204 inline bool KeyframeEffectModel<AnimatableValueKeyframe>::isAnimatableValueKeyfr ameEffectModel() const { return true; } |
| 207 | 205 |
| 208 template <> | 206 template <> |
| 209 inline bool KeyframeEffectModel<StringKeyframe>::isStringKeyframeEffectModel() c onst { return true; } | 207 inline bool KeyframeEffectModel<StringKeyframe>::isStringKeyframeEffectModel() c onst { return true; } |
| 210 | 208 |
| 211 } // namespace blink | 209 } // namespace blink |
| 212 | 210 |
| 213 #endif // KeyframeEffectModel_h | 211 #endif // KeyframeEffectModel_h |
| OLD | NEW |