OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2011 Adobe Systems Incorporated. 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
10 * disclaimer. | 10 * disclaimer. |
(...skipping 12 matching lines...) Expand all Loading... |
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR | 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |
25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF | 25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF |
26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
27 * SUCH DAMAGE. | 27 * SUCH DAMAGE. |
28 */ | 28 */ |
29 | 29 |
30 #ifndef CSSBasicShapes_h | 30 #ifndef CSSBasicShapes_h |
31 #define CSSBasicShapes_h | 31 #define CSSBasicShapes_h |
32 | 32 |
33 #include "core/css/CSSPrimitiveValue.h" | 33 #include "core/css/CSSValue.h" |
34 #include "platform/graphics/GraphicsTypes.h" | 34 #include "platform/graphics/GraphicsTypes.h" |
35 #include "wtf/RefPtr.h" | 35 #include "wtf/RefPtr.h" |
36 #include "wtf/Vector.h" | 36 #include "wtf/Vector.h" |
37 #include "wtf/text/WTFString.h" | 37 #include "wtf/text/WTFString.h" |
38 | 38 |
39 namespace blink { | 39 namespace blink { |
40 | 40 |
41 class CSSBasicShape : public RefCountedWillBeGarbageCollected<CSSBasicShape> { | 41 class CSSBasicShape : public RefCountedWillBeGarbageCollectedFinalized<CSSBasicS
hape> { |
42 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(CSSBasicShape); | 42 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(CSSBasicShape); |
43 public: | 43 public: |
44 enum Type { | 44 enum Type { |
45 CSSBasicShapeEllipseType, | 45 CSSBasicShapeEllipseType, |
46 CSSBasicShapePolygonType, | 46 CSSBasicShapePolygonType, |
47 CSSBasicShapeCircleType, | 47 CSSBasicShapeCircleType, |
48 CSSBasicShapeInsetType | 48 CSSBasicShapeInsetType |
49 }; | 49 }; |
50 | 50 |
51 virtual Type type() const = 0; | 51 virtual Type type() const = 0; |
52 virtual String cssText() const = 0; | 52 virtual String cssText() const = 0; |
53 virtual bool equals(const CSSBasicShape&) const = 0; | 53 virtual bool equals(const CSSBasicShape&) const = 0; |
54 | 54 |
55 CSSPrimitiveValue* referenceBox() const { return m_referenceBox.get(); } | 55 NullableCSSValue referenceBox() const { return m_referenceBox; } |
56 void setReferenceBox(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> referenceBox)
{ m_referenceBox = referenceBox; } | 56 void setReferenceBox(CSSPrimitiveValue referenceBox) { m_referenceBox = refe
renceBox; } |
57 | 57 |
58 bool isEllipse() const { return type() == CSSBasicShapeEllipseType; } | 58 bool isEllipse() const { return type() == CSSBasicShapeEllipseType; } |
59 bool isPolygon() const { return type() == CSSBasicShapePolygonType; } | 59 bool isPolygon() const { return type() == CSSBasicShapePolygonType; } |
60 bool isCircle() const { return type() == CSSBasicShapeCircleType; } | 60 bool isCircle() const { return type() == CSSBasicShapeCircleType; } |
61 bool isInset() const { return type() == CSSBasicShapeInsetType; } | 61 bool isInset() const { return type() == CSSBasicShapeInsetType; } |
62 | 62 |
63 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_referenceBox); } | 63 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_referenceBox); } |
64 | 64 |
65 protected: | 65 protected: |
66 CSSBasicShape() { } | 66 CSSBasicShape() { } |
67 RefPtrWillBeMember<CSSPrimitiveValue> m_referenceBox; | 67 NullableCSSValue m_referenceBox; |
68 }; | 68 }; |
69 | 69 |
70 class CSSBasicShapeCircle final : public CSSBasicShape { | 70 class CSSBasicShapeCircle final : public CSSBasicShape { |
71 public: | 71 public: |
72 static PassRefPtrWillBeRawPtr<CSSBasicShapeCircle> create() { return adoptRe
fWillBeNoop(new CSSBasicShapeCircle); } | 72 static PassRefPtrWillBeRawPtr<CSSBasicShapeCircle> create() { return adoptRe
fWillBeNoop(new CSSBasicShapeCircle); } |
73 | 73 |
74 virtual String cssText() const override; | 74 virtual String cssText() const override; |
75 virtual bool equals(const CSSBasicShape&) const override; | 75 virtual bool equals(const CSSBasicShape&) const override; |
76 | 76 |
77 CSSPrimitiveValue* centerX() const { return m_centerX.get(); } | 77 NullableCSSValue centerX() const { return m_centerX; } |
78 CSSPrimitiveValue* centerY() const { return m_centerY.get(); } | 78 NullableCSSValue centerY() const { return m_centerY; } |
79 CSSPrimitiveValue* radius() const { return m_radius.get(); } | 79 NullableCSSValue radius() const { return m_radius; } |
80 | 80 |
81 void setCenterX(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> centerX) { m_cente
rX = centerX; } | 81 void setCenterX(CSSPrimitiveValue centerX) { m_centerX = centerX; } |
82 void setCenterY(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> centerY) { m_cente
rY = centerY; } | 82 void setCenterY(CSSPrimitiveValue centerY) { m_centerY = centerY; } |
83 void setRadius(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> radius) { m_radius
= radius; } | 83 void setRadius(CSSPrimitiveValue radius) { m_radius = radius; } |
84 | 84 |
85 DECLARE_VIRTUAL_TRACE(); | 85 DECLARE_VIRTUAL_TRACE(); |
86 | 86 |
87 private: | 87 private: |
88 CSSBasicShapeCircle() { } | 88 CSSBasicShapeCircle() { } |
89 | 89 |
90 virtual Type type() const override { return CSSBasicShapeCircleType; } | 90 virtual Type type() const override { return CSSBasicShapeCircleType; } |
91 | 91 |
92 RefPtrWillBeMember<CSSPrimitiveValue> m_centerX; | 92 NullableCSSValue m_centerX; |
93 RefPtrWillBeMember<CSSPrimitiveValue> m_centerY; | 93 NullableCSSValue m_centerY; |
94 RefPtrWillBeMember<CSSPrimitiveValue> m_radius; | 94 NullableCSSValue m_radius; |
95 }; | 95 }; |
96 | 96 |
97 class CSSBasicShapeEllipse final : public CSSBasicShape { | 97 class CSSBasicShapeEllipse final : public CSSBasicShape { |
98 public: | 98 public: |
99 static PassRefPtrWillBeRawPtr<CSSBasicShapeEllipse> create() { return adoptR
efWillBeNoop(new CSSBasicShapeEllipse); } | 99 static PassRefPtrWillBeRawPtr<CSSBasicShapeEllipse> create() { return adoptR
efWillBeNoop(new CSSBasicShapeEllipse); } |
100 | 100 |
101 virtual String cssText() const override; | 101 virtual String cssText() const override; |
102 virtual bool equals(const CSSBasicShape&) const override; | 102 virtual bool equals(const CSSBasicShape&) const override; |
103 | 103 |
104 CSSPrimitiveValue* centerX() const { return m_centerX.get(); } | 104 NullableCSSValue centerX() const { return m_centerX; } |
105 CSSPrimitiveValue* centerY() const { return m_centerY.get(); } | 105 NullableCSSValue centerY() const { return m_centerY; } |
106 CSSPrimitiveValue* radiusX() const { return m_radiusX.get(); } | 106 NullableCSSValue radiusX() const { return m_radiusX; } |
107 CSSPrimitiveValue* radiusY() const { return m_radiusY.get(); } | 107 NullableCSSValue radiusY() const { return m_radiusY; } |
108 | 108 |
109 void setCenterX(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> centerX) { m_cente
rX = centerX; } | 109 void setCenterX(CSSPrimitiveValue centerX) { m_centerX = centerX; } |
110 void setCenterY(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> centerY) { m_cente
rY = centerY; } | 110 void setCenterY(CSSPrimitiveValue centerY) { m_centerY = centerY; } |
111 void setRadiusX(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> radiusX) { m_radiu
sX = radiusX; } | 111 void setRadiusX(CSSPrimitiveValue radiusX) { m_radiusX = radiusX; } |
112 void setRadiusY(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> radiusY) { m_radiu
sY = radiusY; } | 112 void setRadiusY(CSSPrimitiveValue radiusY) { m_radiusY = radiusY; } |
113 | 113 |
114 DECLARE_VIRTUAL_TRACE(); | 114 DECLARE_VIRTUAL_TRACE(); |
115 | 115 |
116 private: | 116 private: |
117 CSSBasicShapeEllipse() { } | 117 CSSBasicShapeEllipse() { } |
118 | 118 |
119 virtual Type type() const override { return CSSBasicShapeEllipseType; } | 119 virtual Type type() const override { return CSSBasicShapeEllipseType; } |
120 | 120 |
121 RefPtrWillBeMember<CSSPrimitiveValue> m_centerX; | 121 NullableCSSValue m_centerX; |
122 RefPtrWillBeMember<CSSPrimitiveValue> m_centerY; | 122 NullableCSSValue m_centerY; |
123 RefPtrWillBeMember<CSSPrimitiveValue> m_radiusX; | 123 NullableCSSValue m_radiusX; |
124 RefPtrWillBeMember<CSSPrimitiveValue> m_radiusY; | 124 NullableCSSValue m_radiusY; |
125 }; | 125 }; |
126 | 126 |
127 class CSSBasicShapePolygon final : public CSSBasicShape { | 127 class CSSBasicShapePolygon final : public CSSBasicShape { |
128 public: | 128 public: |
129 static PassRefPtrWillBeRawPtr<CSSBasicShapePolygon> create() { return adoptR
efWillBeNoop(new CSSBasicShapePolygon); } | 129 static PassRefPtrWillBeRawPtr<CSSBasicShapePolygon> create() { return adoptR
efWillBeNoop(new CSSBasicShapePolygon); } |
130 | 130 |
131 void appendPoint(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> x, PassRefPtrWill
BeRawPtr<CSSPrimitiveValue> y) | 131 void appendPoint(CSSPrimitiveValue x, CSSPrimitiveValue y) |
132 { | 132 { |
133 m_values.append(x); | 133 m_values.append(x); |
134 m_values.append(y); | 134 m_values.append(y); |
135 } | 135 } |
136 | 136 |
137 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> getXAt(unsigned i) const { return
m_values.at(i * 2); } | 137 CSSPrimitiveValue getXAt(unsigned i) const { return toCSSPrimitiveValue(m_va
lues.at(i * 2)); } |
138 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> getYAt(unsigned i) const { return
m_values.at(i * 2 + 1); } | 138 CSSPrimitiveValue getYAt(unsigned i) const { return toCSSPrimitiveValue(m_va
lues.at(i * 2 + 1)); } |
139 const WillBeHeapVector<RefPtrWillBeMember<CSSPrimitiveValue>>& values() cons
t { return m_values; } | 139 const WillBeHeapVector<CSSValue>& values() const { return m_values; } |
140 | 140 |
141 void setWindRule(WindRule w) { m_windRule = w; } | 141 void setWindRule(WindRule w) { m_windRule = w; } |
142 WindRule windRule() const { return m_windRule; } | 142 WindRule windRule() const { return m_windRule; } |
143 | 143 |
144 virtual String cssText() const override; | 144 virtual String cssText() const override; |
145 virtual bool equals(const CSSBasicShape&) const override; | 145 virtual bool equals(const CSSBasicShape&) const override; |
146 | 146 |
147 DECLARE_VIRTUAL_TRACE(); | 147 DECLARE_VIRTUAL_TRACE(); |
148 | 148 |
149 private: | 149 private: |
150 CSSBasicShapePolygon() | 150 CSSBasicShapePolygon() |
151 : m_windRule(RULE_NONZERO) | 151 : m_windRule(RULE_NONZERO) |
152 { | 152 { |
153 } | 153 } |
154 | 154 |
155 virtual Type type() const override { return CSSBasicShapePolygonType; } | 155 virtual Type type() const override { return CSSBasicShapePolygonType; } |
156 | 156 |
157 WillBeHeapVector<RefPtrWillBeMember<CSSPrimitiveValue>> m_values; | 157 WillBeHeapVector<CSSValue> m_values; |
158 WindRule m_windRule; | 158 WindRule m_windRule; |
159 }; | 159 }; |
160 | 160 |
161 class CSSBasicShapeInset final : public CSSBasicShape { | 161 class CSSBasicShapeInset final : public CSSBasicShape { |
162 public: | 162 public: |
163 static PassRefPtrWillBeRawPtr<CSSBasicShapeInset> create() { return adoptRef
WillBeNoop(new CSSBasicShapeInset); } | 163 static PassRefPtrWillBeRawPtr<CSSBasicShapeInset> create() { return adoptRef
WillBeNoop(new CSSBasicShapeInset); } |
164 | 164 |
165 CSSPrimitiveValue* top() const { return m_top.get(); } | 165 CSSPrimitiveValue top() const { return toCSSPrimitiveValue(*m_top); } |
166 CSSPrimitiveValue* right() const { return m_right.get(); } | 166 CSSPrimitiveValue right() const { return toCSSPrimitiveValue(*m_right); } |
167 CSSPrimitiveValue* bottom() const { return m_bottom.get(); } | 167 CSSPrimitiveValue bottom() const { return toCSSPrimitiveValue(*m_bottom); } |
168 CSSPrimitiveValue* left() const { return m_left.get(); } | 168 CSSPrimitiveValue left() const { return toCSSPrimitiveValue(*m_left); } |
169 | 169 |
170 CSSPrimitiveValue* topLeftRadius() const { return m_topLeftRadius.get(); } | 170 NullableCSSValue topLeftRadius() const { return m_topLeftRadius; } |
171 CSSPrimitiveValue* topRightRadius() const { return m_topRightRadius.get(); } | 171 NullableCSSValue topRightRadius() const { return m_topRightRadius; } |
172 CSSPrimitiveValue* bottomRightRadius() const { return m_bottomRightRadius.ge
t(); } | 172 NullableCSSValue bottomRightRadius() const { return m_bottomRightRadius; } |
173 CSSPrimitiveValue* bottomLeftRadius() const { return m_bottomLeftRadius.get(
); } | 173 NullableCSSValue bottomLeftRadius() const { return m_bottomLeftRadius; } |
174 | 174 |
175 void setTop(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> top) { m_top = top; } | 175 void setTop(CSSPrimitiveValue top) { m_top = top; } |
176 void setRight(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> right) { m_right = r
ight; } | 176 void setRight(CSSPrimitiveValue right) { m_right = right; } |
177 void setBottom(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> bottom) { m_bottom
= bottom; } | 177 void setBottom(CSSPrimitiveValue bottom) { m_bottom = bottom; } |
178 void setLeft(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> left) { m_left = left
; } | 178 void setLeft(CSSPrimitiveValue left) { m_left = left; } |
179 | 179 |
180 void updateShapeSize4Values(CSSPrimitiveValue* top, CSSPrimitiveValue* right
, CSSPrimitiveValue* bottom, CSSPrimitiveValue* left) | 180 void updateShapeSize4Values(CSSPrimitiveValue top, CSSPrimitiveValue right,
CSSPrimitiveValue bottom, CSSPrimitiveValue left) |
181 { | 181 { |
182 setTop(top); | 182 setTop(top); |
183 setRight(right); | 183 setRight(right); |
184 setBottom(bottom); | 184 setBottom(bottom); |
185 setLeft(left); | 185 setLeft(left); |
186 } | 186 } |
187 | 187 |
188 void updateShapeSize1Value(CSSPrimitiveValue* value1) | 188 void updateShapeSize1Value(CSSPrimitiveValue value1) |
189 { | 189 { |
190 updateShapeSize4Values(value1, value1, value1, value1); | 190 updateShapeSize4Values(value1, value1, value1, value1); |
191 } | 191 } |
192 | 192 |
193 void updateShapeSize2Values(CSSPrimitiveValue* value1, CSSPrimitiveValue* v
alue2) | 193 void updateShapeSize2Values(CSSPrimitiveValue value1, CSSPrimitiveValue val
ue2) |
194 { | 194 { |
195 updateShapeSize4Values(value1, value2, value1, value2); | 195 updateShapeSize4Values(value1, value2, value1, value2); |
196 } | 196 } |
197 | 197 |
198 void updateShapeSize3Values(CSSPrimitiveValue* value1, CSSPrimitiveValue* va
lue2, CSSPrimitiveValue* value3) | 198 void updateShapeSize3Values(CSSPrimitiveValue value1, CSSPrimitiveValue valu
e2, CSSPrimitiveValue value3) |
199 { | 199 { |
200 updateShapeSize4Values(value1, value2, value3, value2); | 200 updateShapeSize4Values(value1, value2, value3, value2); |
201 } | 201 } |
202 | 202 |
203 | 203 |
204 void setTopLeftRadius(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> radius) { m_
topLeftRadius = radius; } | 204 void setTopLeftRadius(CSSPrimitiveValue radius) { m_topLeftRadius = radius;
} |
205 void setTopRightRadius(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> radius) { m
_topRightRadius = radius; } | 205 void setTopRightRadius(CSSPrimitiveValue radius) { m_topRightRadius = radius
; } |
206 void setBottomRightRadius(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> radius)
{ m_bottomRightRadius = radius; } | 206 void setBottomRightRadius(CSSPrimitiveValue radius) { m_bottomRightRadius =
radius; } |
207 void setBottomLeftRadius(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> radius) {
m_bottomLeftRadius = radius; } | 207 void setBottomLeftRadius(CSSPrimitiveValue radius) { m_bottomLeftRadius = ra
dius; } |
208 | 208 |
209 virtual String cssText() const override; | 209 virtual String cssText() const override; |
210 virtual bool equals(const CSSBasicShape&) const override; | 210 virtual bool equals(const CSSBasicShape&) const override; |
211 | 211 |
212 DECLARE_VIRTUAL_TRACE(); | 212 DECLARE_VIRTUAL_TRACE(); |
213 | 213 |
214 private: | 214 private: |
215 CSSBasicShapeInset() { } | 215 CSSBasicShapeInset() { } |
216 | 216 |
217 virtual Type type() const override { return CSSBasicShapeInsetType; } | 217 virtual Type type() const override { return CSSBasicShapeInsetType; } |
218 | 218 |
219 RefPtrWillBeMember<CSSPrimitiveValue> m_top; | 219 NullableCSSValue m_top; |
220 RefPtrWillBeMember<CSSPrimitiveValue> m_right; | 220 NullableCSSValue m_right; |
221 RefPtrWillBeMember<CSSPrimitiveValue> m_bottom; | 221 NullableCSSValue m_bottom; |
222 RefPtrWillBeMember<CSSPrimitiveValue> m_left; | 222 NullableCSSValue m_left; |
223 | 223 |
224 RefPtrWillBeMember<CSSPrimitiveValue> m_topLeftRadius; | 224 NullableCSSValue m_topLeftRadius; |
225 RefPtrWillBeMember<CSSPrimitiveValue> m_topRightRadius; | 225 NullableCSSValue m_topRightRadius; |
226 RefPtrWillBeMember<CSSPrimitiveValue> m_bottomRightRadius; | 226 NullableCSSValue m_bottomRightRadius; |
227 RefPtrWillBeMember<CSSPrimitiveValue> m_bottomLeftRadius; | 227 NullableCSSValue m_bottomLeftRadius; |
228 }; | 228 }; |
229 | 229 |
230 DEFINE_TYPE_CASTS(CSSBasicShapeCircle, CSSBasicShape, shape, shape->isCircle(),
shape.isCircle()); | 230 DEFINE_TYPE_CASTS(CSSBasicShapeCircle, CSSBasicShape, shape, shape->isCircle(),
shape.isCircle()); |
231 DEFINE_TYPE_CASTS(CSSBasicShapeEllipse, CSSBasicShape, shape, shape->isEllipse()
, shape.isEllipse()); | 231 DEFINE_TYPE_CASTS(CSSBasicShapeEllipse, CSSBasicShape, shape, shape->isEllipse()
, shape.isEllipse()); |
232 DEFINE_TYPE_CASTS(CSSBasicShapePolygon, CSSBasicShape, shape, shape->isPolygon()
, shape.isPolygon()); | 232 DEFINE_TYPE_CASTS(CSSBasicShapePolygon, CSSBasicShape, shape, shape->isPolygon()
, shape.isPolygon()); |
233 DEFINE_TYPE_CASTS(CSSBasicShapeInset, CSSBasicShape, shape, shape->isInset(), sh
ape.isInset()); | 233 DEFINE_TYPE_CASTS(CSSBasicShapeInset, CSSBasicShape, shape, shape->isInset(), sh
ape.isInset()); |
234 | 234 |
235 } // namespace blink | 235 } // namespace blink |
236 | 236 |
237 #endif // CSSBasicShapes_h | 237 #endif // CSSBasicShapes_h |
OLD | NEW |