OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef StringKeyframe_h | 5 #ifndef StringKeyframe_h |
6 #define StringKeyframe_h | 6 #define StringKeyframe_h |
7 | 7 |
8 #include "core/animation/Keyframe.h" | 8 #include "core/animation/Keyframe.h" |
9 #include "core/css/StylePropertySet.h" | 9 #include "core/css/StylePropertySet.h" |
10 | 10 |
11 #include "wtf/HashMap.h" | 11 #include "wtf/HashMap.h" |
12 | 12 |
13 namespace blink { | 13 namespace blink { |
14 | 14 |
15 class StyleSheetContents; | 15 class StyleSheetContents; |
16 | 16 |
17 class StringKeyframe : public Keyframe { | 17 class StringKeyframe : public Keyframe { |
18 public: | 18 public: |
19 static PassRefPtrWillBeRawPtr<StringKeyframe> create() | 19 static StringKeyframe* create() |
20 { | 20 { |
21 return adoptRefWillBeNoop(new StringKeyframe); | 21 return new StringKeyframe; |
22 } | 22 } |
23 | 23 |
24 void setPropertyValue(CSSPropertyID, const String& value, Element*, StyleShe
etContents*); | 24 void setPropertyValue(CSSPropertyID, const String& value, Element*, StyleShe
etContents*); |
25 void setPropertyValue(CSSPropertyID, PassRefPtrWillBeRawPtr<CSSValue>); | 25 void setPropertyValue(CSSPropertyID, PassRefPtrWillBeRawPtr<CSSValue>); |
26 void setPropertyValue(const QualifiedName&, const String& value, Element*); | 26 void setPropertyValue(const QualifiedName&, const String& value, Element*); |
27 CSSValue* cssPropertyValue(CSSPropertyID property) const | 27 CSSValue* cssPropertyValue(CSSPropertyID property) const |
28 { | 28 { |
29 int index = m_propertySet->findPropertyIndex(property); | 29 int index = m_propertySet->findPropertyIndex(property); |
30 RELEASE_ASSERT(index >= 0); | 30 RELEASE_ASSERT(index >= 0); |
31 return m_propertySet->propertyAt(static_cast<unsigned>(index)).value(); | 31 return m_propertySet->propertyAt(static_cast<unsigned>(index)).value(); |
32 } | 32 } |
33 String svgPropertyValue(const QualifiedName& attributeName) const | 33 String svgPropertyValue(const QualifiedName& attributeName) const |
34 { | 34 { |
35 return m_svgPropertyMap.get(&attributeName); | 35 return m_svgPropertyMap.get(&attributeName); |
36 } | 36 } |
37 | 37 |
38 PropertyHandleSet properties() const override; | 38 PropertyHandleSet properties() const override; |
39 | 39 |
40 DECLARE_VIRTUAL_TRACE(); | 40 DECLARE_VIRTUAL_TRACE(); |
41 | 41 |
42 class CSSPropertySpecificKeyframe : public Keyframe::PropertySpecificKeyfram
e { | 42 class CSSPropertySpecificKeyframe : public Keyframe::PropertySpecificKeyfram
e { |
43 public: | 43 public: |
44 CSSPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> ea
sing, CSSValue*, EffectModel::CompositeOperation); | 44 CSSPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> ea
sing, CSSValue*, EffectModel::CompositeOperation); |
45 | 45 |
46 CSSValue* value() const { return m_value.get(); } | 46 CSSValue* value() const { return m_value.get(); } |
47 | 47 |
48 virtual void populateAnimatableValue(CSSPropertyID, Element&, const Comp
utedStyle* baseStyle) const; | 48 virtual void populateAnimatableValue(CSSPropertyID, Element&, const Comp
utedStyle* baseStyle) const; |
49 const PassRefPtrWillBeRawPtr<AnimatableValue> getAnimatableValue() const
final { return m_animatableValueCache.get(); } | 49 AnimatableValue* getAnimatableValue() const final { return m_animatableV
alueCache.get(); } |
50 void setAnimatableValue(PassRefPtrWillBeRawPtr<AnimatableValue> value) {
m_animatableValueCache = value; } | 50 void setAnimatableValue(AnimatableValue* value) { m_animatableValueCache
= value; } |
51 | 51 |
52 bool isNeutral() const final { return !m_value; } | 52 bool isNeutral() const final { return !m_value; } |
53 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> neutralKeyfra
me(double offset, PassRefPtr<TimingFunction> easing) const final; | 53 Keyframe::PropertySpecificKeyframe* neutralKeyframe(double offset, PassR
efPtr<TimingFunction> easing) const final; |
54 PassRefPtrWillBeRawPtr<Interpolation> maybeCreateInterpolation(PropertyH
andle, Keyframe::PropertySpecificKeyframe& end, Element*, const ComputedStyle* b
aseStyle) const final; | 54 Interpolation* maybeCreateInterpolation(PropertyHandle, Keyframe::Proper
tySpecificKeyframe& end, Element*, const ComputedStyle* baseStyle) const final; |
55 | 55 |
56 DECLARE_VIRTUAL_TRACE(); | 56 DECLARE_VIRTUAL_TRACE(); |
57 | 57 |
58 private: | 58 private: |
59 CSSPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> ea
sing, CSSValue*); | 59 CSSPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> ea
sing, CSSValue*); |
60 | 60 |
61 virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> clone
WithOffset(double offset) const; | 61 virtual Keyframe::PropertySpecificKeyframe* cloneWithOffset(double offse
t) const; |
62 bool isCSSPropertySpecificKeyframe() const override { return true; } | 62 bool isCSSPropertySpecificKeyframe() const override { return true; } |
63 | 63 |
64 PassRefPtrWillBeRawPtr<Interpolation> createLegacyStyleInterpolation(CSS
PropertyID, Keyframe::PropertySpecificKeyframe& end, Element*, const ComputedSty
le* baseStyle) const; | 64 Interpolation* createLegacyStyleInterpolation(CSSPropertyID, Keyframe::P
ropertySpecificKeyframe& end, Element*, const ComputedStyle* baseStyle) const; |
65 static bool createInterpolationsFromCSSValues(CSSPropertyID, CSSValue* f
romCSSValue, CSSValue* toCSSValue, Element*, OwnPtrWillBeRawPtr<WillBeHeapVector
<RefPtrWillBeMember<Interpolation>>>& interpolations); | 65 static bool createInterpolationsFromCSSValues(CSSPropertyID, CSSValue* f
romCSSValue, CSSValue* toCSSValue, Element*, HeapVector<Member<Interpolation>>*
interpolations); |
66 | 66 |
67 void populateAnimatableValueCaches(CSSPropertyID, Keyframe::PropertySpec
ificKeyframe&, Element*, CSSValue& fromCSSValue, CSSValue& toCSSValue) const; | 67 void populateAnimatableValueCaches(CSSPropertyID, Keyframe::PropertySpec
ificKeyframe&, Element*, CSSValue& fromCSSValue, CSSValue& toCSSValue) const; |
68 | 68 |
69 RefPtrWillBeMember<CSSValue> m_value; | 69 RefPtrWillBeMember<CSSValue> m_value; |
70 mutable RefPtrWillBeMember<AnimatableValue> m_animatableValueCache; | 70 mutable Member<AnimatableValue> m_animatableValueCache; |
71 }; | 71 }; |
72 | 72 |
73 class SVGPropertySpecificKeyframe : public Keyframe::PropertySpecificKeyfram
e { | 73 class SVGPropertySpecificKeyframe : public Keyframe::PropertySpecificKeyfram
e { |
74 public: | 74 public: |
75 SVGPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> ea
sing, const String&, EffectModel::CompositeOperation); | 75 SVGPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> ea
sing, const String&, EffectModel::CompositeOperation); |
76 | 76 |
77 const String& value() const { return m_value; } | 77 const String& value() const { return m_value; } |
78 | 78 |
79 PassOwnPtrWillBeRawPtr<PropertySpecificKeyframe> cloneWithOffset(double
offset) const final; | 79 PropertySpecificKeyframe* cloneWithOffset(double offset) const final; |
80 | 80 |
81 const PassRefPtrWillBeRawPtr<AnimatableValue> getAnimatableValue() const
final { return nullptr; } | 81 AnimatableValue* getAnimatableValue() const final { return nullptr; } |
82 | 82 |
83 PassOwnPtrWillBeRawPtr<PropertySpecificKeyframe> neutralKeyframe(double
offset, PassRefPtr<TimingFunction> easing) const final; | 83 PropertySpecificKeyframe* neutralKeyframe(double offset, PassRefPtr<Timi
ngFunction> easing) const final; |
84 PassRefPtrWillBeRawPtr<Interpolation> maybeCreateInterpolation(PropertyH
andle, Keyframe::PropertySpecificKeyframe& end, Element*, const ComputedStyle* b
aseStyle) const final; | 84 Interpolation* maybeCreateInterpolation(PropertyHandle, Keyframe::Proper
tySpecificKeyframe& end, Element*, const ComputedStyle* baseStyle) const final; |
85 | 85 |
86 DECLARE_VIRTUAL_TRACE(); | 86 DECLARE_VIRTUAL_TRACE(); |
87 | 87 |
88 private: | 88 private: |
89 SVGPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> ea
sing, const String&); | 89 SVGPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> ea
sing, const String&); |
90 | 90 |
91 bool isSVGPropertySpecificKeyframe() const override { return true; } | 91 bool isSVGPropertySpecificKeyframe() const override { return true; } |
92 | 92 |
93 String m_value; | 93 String m_value; |
94 }; | 94 }; |
95 | 95 |
96 private: | 96 private: |
97 StringKeyframe() | 97 StringKeyframe() |
98 : m_propertySet(MutableStylePropertySet::create()) | 98 : m_propertySet(MutableStylePropertySet::create()) |
99 { } | 99 { } |
100 | 100 |
101 StringKeyframe(const StringKeyframe& copyFrom); | 101 StringKeyframe(const StringKeyframe& copyFrom); |
102 | 102 |
103 PassRefPtrWillBeRawPtr<Keyframe> clone() const override; | 103 Keyframe* clone() const override; |
104 PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> createPropertySpe
cificKeyframe(PropertyHandle) const override; | 104 Keyframe::PropertySpecificKeyframe* createPropertySpecificKeyframe(PropertyH
andle) const override; |
105 | 105 |
106 bool isStringKeyframe() const override { return true; } | 106 bool isStringKeyframe() const override { return true; } |
107 | 107 |
108 RefPtrWillBeMember<MutableStylePropertySet> m_propertySet; | 108 RefPtrWillBeMember<MutableStylePropertySet> m_propertySet; |
109 HashMap<const QualifiedName*, String> m_svgPropertyMap; | 109 HashMap<const QualifiedName*, String> m_svgPropertyMap; |
110 }; | 110 }; |
111 | 111 |
112 using CSSPropertySpecificKeyframe = StringKeyframe::CSSPropertySpecificKeyframe; | 112 using CSSPropertySpecificKeyframe = StringKeyframe::CSSPropertySpecificKeyframe; |
113 using SVGPropertySpecificKeyframe = StringKeyframe::SVGPropertySpecificKeyframe; | 113 using SVGPropertySpecificKeyframe = StringKeyframe::SVGPropertySpecificKeyframe; |
114 | 114 |
115 DEFINE_TYPE_CASTS(StringKeyframe, Keyframe, value, value->isStringKeyframe(), va
lue.isStringKeyframe()); | 115 DEFINE_TYPE_CASTS(StringKeyframe, Keyframe, value, value->isStringKeyframe(), va
lue.isStringKeyframe()); |
116 DEFINE_TYPE_CASTS(CSSPropertySpecificKeyframe, Keyframe::PropertySpecificKeyfram
e, value, value->isCSSPropertySpecificKeyframe(), value.isCSSPropertySpecificKey
frame()); | 116 DEFINE_TYPE_CASTS(CSSPropertySpecificKeyframe, Keyframe::PropertySpecificKeyfram
e, value, value->isCSSPropertySpecificKeyframe(), value.isCSSPropertySpecificKey
frame()); |
117 DEFINE_TYPE_CASTS(SVGPropertySpecificKeyframe, Keyframe::PropertySpecificKeyfram
e, value, value->isSVGPropertySpecificKeyframe(), value.isSVGPropertySpecificKey
frame()); | 117 DEFINE_TYPE_CASTS(SVGPropertySpecificKeyframe, Keyframe::PropertySpecificKeyfram
e, value, value->isSVGPropertySpecificKeyframe(), value.isSVGPropertySpecificKey
frame()); |
118 | 118 |
119 } | 119 } |
120 | 120 |
121 #endif | 121 #endif |
OLD | NEW |