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 virtual PropertyHandleSet properties() const override; | 38 virtual 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 virtual const PassRefPtrWillBeRawPtr<AnimatableValue> getAnimatableValue
() const override final { return m_animatableValueCache.get(); } | 49 virtual const AnimatableValue* getAnimatableValue() const override final
{ return m_animatableValueCache.get(); } |
50 void setAnimatableValue(PassRefPtrWillBeRawPtr<AnimatableValue> value) {
m_animatableValueCache = value; } | 50 void setAnimatableValue(AnimatableValue* value) { m_animatableValueCache
= value; } |
51 | 51 |
52 virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> neutr
alKeyframe(double offset, PassRefPtr<TimingFunction> easing) const override fina
l; | 52 virtual Keyframe::PropertySpecificKeyframe* neutralKeyframe(double offse
t, PassRefPtr<TimingFunction> easing) const override final; |
53 virtual PassRefPtrWillBeRawPtr<Interpolation> maybeCreateInterpolation(P
ropertyHandle, Keyframe::PropertySpecificKeyframe& end, Element*, const Computed
Style* baseStyle) const override final; | 53 virtual Interpolation* maybeCreateInterpolation(PropertyHandle, Keyframe
::PropertySpecificKeyframe& end, Element*, const ComputedStyle* baseStyle) const
override final; |
54 | 54 |
55 DECLARE_VIRTUAL_TRACE(); | 55 DECLARE_VIRTUAL_TRACE(); |
56 | 56 |
57 private: | 57 private: |
58 CSSPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> ea
sing, CSSValue*); | 58 CSSPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> ea
sing, CSSValue*); |
59 | 59 |
60 virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> clone
WithOffset(double offset) const; | 60 virtual Keyframe::PropertySpecificKeyframe* cloneWithOffset(double offse
t) const; |
61 virtual bool isCSSPropertySpecificKeyframe() const override { return tru
e; } | 61 virtual bool isCSSPropertySpecificKeyframe() const override { return tru
e; } |
62 | 62 |
63 static bool createInterpolationsFromCSSValues(CSSPropertyID, CSSValue* f
romCSSValue, CSSValue* toCSSValue, Element*, OwnPtrWillBeRawPtr<WillBeHeapVector
<RefPtrWillBeMember<Interpolation>>>& interpolations); | 63 static bool createInterpolationsFromCSSValues(CSSPropertyID, CSSValue* f
romCSSValue, CSSValue* toCSSValue, Element*, HeapVector<Member<Interpolation>>*
interpolations); |
64 | 64 |
65 void populateAnimatableValueCaches(CSSPropertyID, Keyframe::PropertySpec
ificKeyframe&, Element*, CSSValue& fromCSSValue, CSSValue& toCSSValue) const; | 65 void populateAnimatableValueCaches(CSSPropertyID, Keyframe::PropertySpec
ificKeyframe&, Element*, CSSValue& fromCSSValue, CSSValue& toCSSValue) const; |
66 | 66 |
67 RefPtrWillBeMember<CSSValue> m_value; | 67 RefPtrWillBeMember<CSSValue> m_value; |
68 mutable RefPtrWillBeMember<AnimatableValue> m_animatableValueCache; | 68 mutable Member<AnimatableValue> m_animatableValueCache; |
69 }; | 69 }; |
70 | 70 |
71 class SVGPropertySpecificKeyframe : public Keyframe::PropertySpecificKeyfram
e { | 71 class SVGPropertySpecificKeyframe : public Keyframe::PropertySpecificKeyfram
e { |
72 public: | 72 public: |
73 SVGPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> ea
sing, const String&, EffectModel::CompositeOperation); | 73 SVGPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> ea
sing, const String&, EffectModel::CompositeOperation); |
74 | 74 |
75 const String& value() const { return m_value; } | 75 const String& value() const { return m_value; } |
76 | 76 |
77 virtual PassOwnPtrWillBeRawPtr<PropertySpecificKeyframe> cloneWithOffset
(double offset) const override final; | 77 virtual PropertySpecificKeyframe* cloneWithOffset(double offset) const o
verride final; |
78 | 78 |
79 virtual const PassRefPtrWillBeRawPtr<AnimatableValue> getAnimatableValue
() const override final { return nullptr; } | 79 virtual const AnimatableValue* getAnimatableValue() const override final
{ return nullptr; } |
80 | 80 |
81 virtual PassOwnPtrWillBeRawPtr<PropertySpecificKeyframe> neutralKeyframe
(double offset, PassRefPtr<TimingFunction> easing) const override final; | 81 virtual PropertySpecificKeyframe* neutralKeyframe(double offset, PassRef
Ptr<TimingFunction> easing) const override final; |
82 virtual PassRefPtrWillBeRawPtr<Interpolation> maybeCreateInterpolation(P
ropertyHandle, Keyframe::PropertySpecificKeyframe& end, Element*, const Computed
Style* baseStyle) const override final; | 82 virtual Interpolation* maybeCreateInterpolation(PropertyHandle, Keyframe
::PropertySpecificKeyframe& end, Element*, const ComputedStyle* baseStyle) const
override final; |
83 | 83 |
84 DECLARE_VIRTUAL_TRACE(); | 84 DECLARE_VIRTUAL_TRACE(); |
85 | 85 |
86 private: | 86 private: |
87 SVGPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> ea
sing, const String&); | 87 SVGPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> ea
sing, const String&); |
88 | 88 |
89 virtual bool isSVGPropertySpecificKeyframe() const override { return tru
e; } | 89 virtual bool isSVGPropertySpecificKeyframe() const override { return tru
e; } |
90 | 90 |
91 String m_value; | 91 String m_value; |
92 }; | 92 }; |
93 | 93 |
94 private: | 94 private: |
95 StringKeyframe() | 95 StringKeyframe() |
96 : m_propertySet(MutableStylePropertySet::create()) | 96 : m_propertySet(MutableStylePropertySet::create()) |
97 { } | 97 { } |
98 | 98 |
99 StringKeyframe(const StringKeyframe& copyFrom); | 99 StringKeyframe(const StringKeyframe& copyFrom); |
100 | 100 |
101 virtual PassRefPtrWillBeRawPtr<Keyframe> clone() const override; | 101 virtual Keyframe* clone() const override; |
102 virtual PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> createPro
pertySpecificKeyframe(PropertyHandle) const override; | 102 virtual Keyframe::PropertySpecificKeyframe* createPropertySpecificKeyframe(P
ropertyHandle) const override; |
103 | 103 |
104 virtual bool isStringKeyframe() const override { return true; } | 104 virtual bool isStringKeyframe() const override { return true; } |
105 | 105 |
106 RefPtrWillBeMember<MutableStylePropertySet> m_propertySet; | 106 RefPtrWillBeMember<MutableStylePropertySet> m_propertySet; |
107 HashMap<const QualifiedName*, String> m_svgPropertyMap; | 107 HashMap<const QualifiedName*, String> m_svgPropertyMap; |
108 }; | 108 }; |
109 | 109 |
110 using CSSPropertySpecificKeyframe = StringKeyframe::CSSPropertySpecificKeyframe; | 110 using CSSPropertySpecificKeyframe = StringKeyframe::CSSPropertySpecificKeyframe; |
111 using SVGPropertySpecificKeyframe = StringKeyframe::SVGPropertySpecificKeyframe; | 111 using SVGPropertySpecificKeyframe = StringKeyframe::SVGPropertySpecificKeyframe; |
112 | 112 |
113 DEFINE_TYPE_CASTS(StringKeyframe, Keyframe, value, value->isStringKeyframe(), va
lue.isStringKeyframe()); | 113 DEFINE_TYPE_CASTS(StringKeyframe, Keyframe, value, value->isStringKeyframe(), va
lue.isStringKeyframe()); |
114 DEFINE_TYPE_CASTS(CSSPropertySpecificKeyframe, Keyframe::PropertySpecificKeyfram
e, value, value->isCSSPropertySpecificKeyframe(), value.isCSSPropertySpecificKey
frame()); | 114 DEFINE_TYPE_CASTS(CSSPropertySpecificKeyframe, Keyframe::PropertySpecificKeyfram
e, value, value->isCSSPropertySpecificKeyframe(), value.isCSSPropertySpecificKey
frame()); |
115 DEFINE_TYPE_CASTS(SVGPropertySpecificKeyframe, Keyframe::PropertySpecificKeyfram
e, value, value->isSVGPropertySpecificKeyframe(), value.isSVGPropertySpecificKey
frame()); | 115 DEFINE_TYPE_CASTS(SVGPropertySpecificKeyframe, Keyframe::PropertySpecificKeyfram
e, value, value->isSVGPropertySpecificKeyframe(), value.isSVGPropertySpecificKey
frame()); |
116 | 116 |
117 } | 117 } |
118 | 118 |
119 #endif | 119 #endif |
OLD | NEW |