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 20 matching lines...) Expand all Loading... |
31 #define CSSBasicShapes_h | 31 #define CSSBasicShapes_h |
32 | 32 |
33 #include "core/css/CSSPrimitiveValue.h" | 33 #include "core/css/CSSPrimitiveValue.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 RefCounted<CSSBasicShape> { |
42 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(CSSBasicShape); | |
43 public: | 42 public: |
| 43 virtual ~CSSBasicShape() |
| 44 { |
| 45 } |
| 46 |
44 enum Type { | 47 enum Type { |
45 CSSBasicShapeEllipseType, | 48 CSSBasicShapeEllipseType, |
46 CSSBasicShapePolygonType, | 49 CSSBasicShapePolygonType, |
47 CSSBasicShapeCircleType, | 50 CSSBasicShapeCircleType, |
48 CSSBasicShapeInsetType | 51 CSSBasicShapeInsetType |
49 }; | 52 }; |
50 | 53 |
51 virtual Type type() const = 0; | 54 virtual Type type() const = 0; |
52 virtual String cssText() const = 0; | 55 virtual String cssText() const = 0; |
53 virtual bool equals(const CSSBasicShape&) const = 0; | 56 virtual bool equals(const CSSBasicShape&) const = 0; |
54 | 57 |
55 CSSPrimitiveValue* referenceBox() const { return m_referenceBox.get(); } | 58 CSSPrimitiveValue* referenceBox() const { return m_referenceBox.get(); } |
56 void setReferenceBox(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> referenceBox)
{ m_referenceBox = referenceBox; } | 59 void setReferenceBox(PassRefPtr<CSSPrimitiveValue> referenceBox) { m_referen
ceBox = referenceBox; } |
57 | 60 |
58 bool isEllipse() const { return type() == CSSBasicShapeEllipseType; } | 61 bool isEllipse() const { return type() == CSSBasicShapeEllipseType; } |
59 bool isPolygon() const { return type() == CSSBasicShapePolygonType; } | 62 bool isPolygon() const { return type() == CSSBasicShapePolygonType; } |
60 bool isCircle() const { return type() == CSSBasicShapeCircleType; } | 63 bool isCircle() const { return type() == CSSBasicShapeCircleType; } |
61 bool isInset() const { return type() == CSSBasicShapeInsetType; } | 64 bool isInset() const { return type() == CSSBasicShapeInsetType; } |
62 | 65 |
63 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_referenceBox); } | |
64 | |
65 protected: | 66 protected: |
66 CSSBasicShape() { } | 67 CSSBasicShape() { } |
67 RefPtrWillBeMember<CSSPrimitiveValue> m_referenceBox; | 68 RefPtr<CSSPrimitiveValue> m_referenceBox; |
68 }; | 69 }; |
69 | 70 |
70 class CSSBasicShapeCircle final : public CSSBasicShape { | 71 class CSSBasicShapeCircle final : public CSSBasicShape { |
71 public: | 72 public: |
72 static PassRefPtrWillBeRawPtr<CSSBasicShapeCircle> create() { return adoptRe
fWillBeNoop(new CSSBasicShapeCircle); } | 73 static PassRefPtr<CSSBasicShapeCircle> create() { return adoptRef(new CSSBas
icShapeCircle); } |
73 | 74 |
74 String cssText() const override; | 75 String cssText() const override; |
75 bool equals(const CSSBasicShape&) const override; | 76 bool equals(const CSSBasicShape&) const override; |
76 | 77 |
77 CSSPrimitiveValue* centerX() const { return m_centerX.get(); } | 78 CSSPrimitiveValue* centerX() const { return m_centerX.get(); } |
78 CSSPrimitiveValue* centerY() const { return m_centerY.get(); } | 79 CSSPrimitiveValue* centerY() const { return m_centerY.get(); } |
79 CSSPrimitiveValue* radius() const { return m_radius.get(); } | 80 CSSPrimitiveValue* radius() const { return m_radius.get(); } |
80 | 81 |
81 void setCenterX(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> centerX) { m_cente
rX = centerX; } | 82 void setCenterX(PassRefPtr<CSSPrimitiveValue> centerX) { m_centerX = centerX
; } |
82 void setCenterY(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> centerY) { m_cente
rY = centerY; } | 83 void setCenterY(PassRefPtr<CSSPrimitiveValue> centerY) { m_centerY = centerY
; } |
83 void setRadius(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> radius) { m_radius
= radius; } | 84 void setRadius(PassRefPtr<CSSPrimitiveValue> radius) { m_radius = radius; } |
84 | |
85 DECLARE_VIRTUAL_TRACE(); | |
86 | 85 |
87 private: | 86 private: |
88 CSSBasicShapeCircle() { } | 87 CSSBasicShapeCircle() { } |
89 | 88 |
90 Type type() const override { return CSSBasicShapeCircleType; } | 89 Type type() const override { return CSSBasicShapeCircleType; } |
91 | 90 |
92 RefPtrWillBeMember<CSSPrimitiveValue> m_centerX; | 91 RefPtr<CSSPrimitiveValue> m_centerX; |
93 RefPtrWillBeMember<CSSPrimitiveValue> m_centerY; | 92 RefPtr<CSSPrimitiveValue> m_centerY; |
94 RefPtrWillBeMember<CSSPrimitiveValue> m_radius; | 93 RefPtr<CSSPrimitiveValue> m_radius; |
95 }; | 94 }; |
96 | 95 |
97 class CSSBasicShapeEllipse final : public CSSBasicShape { | 96 class CSSBasicShapeEllipse final : public CSSBasicShape { |
98 public: | 97 public: |
99 static PassRefPtrWillBeRawPtr<CSSBasicShapeEllipse> create() { return adoptR
efWillBeNoop(new CSSBasicShapeEllipse); } | 98 static PassRefPtr<CSSBasicShapeEllipse> create() { return adoptRef(new CSSBa
sicShapeEllipse); } |
100 | 99 |
101 String cssText() const override; | 100 String cssText() const override; |
102 bool equals(const CSSBasicShape&) const override; | 101 bool equals(const CSSBasicShape&) const override; |
103 | 102 |
104 CSSPrimitiveValue* centerX() const { return m_centerX.get(); } | 103 CSSPrimitiveValue* centerX() const { return m_centerX.get(); } |
105 CSSPrimitiveValue* centerY() const { return m_centerY.get(); } | 104 CSSPrimitiveValue* centerY() const { return m_centerY.get(); } |
106 CSSPrimitiveValue* radiusX() const { return m_radiusX.get(); } | 105 CSSPrimitiveValue* radiusX() const { return m_radiusX.get(); } |
107 CSSPrimitiveValue* radiusY() const { return m_radiusY.get(); } | 106 CSSPrimitiveValue* radiusY() const { return m_radiusY.get(); } |
108 | 107 |
109 void setCenterX(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> centerX) { m_cente
rX = centerX; } | 108 void setCenterX(PassRefPtr<CSSPrimitiveValue> centerX) { m_centerX = centerX
; } |
110 void setCenterY(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> centerY) { m_cente
rY = centerY; } | 109 void setCenterY(PassRefPtr<CSSPrimitiveValue> centerY) { m_centerY = centerY
; } |
111 void setRadiusX(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> radiusX) { m_radiu
sX = radiusX; } | 110 void setRadiusX(PassRefPtr<CSSPrimitiveValue> radiusX) { m_radiusX = radiusX
; } |
112 void setRadiusY(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> radiusY) { m_radiu
sY = radiusY; } | 111 void setRadiusY(PassRefPtr<CSSPrimitiveValue> radiusY) { m_radiusY = radiusY
; } |
113 | |
114 DECLARE_VIRTUAL_TRACE(); | |
115 | 112 |
116 private: | 113 private: |
117 CSSBasicShapeEllipse() { } | 114 CSSBasicShapeEllipse() { } |
118 | 115 |
119 Type type() const override { return CSSBasicShapeEllipseType; } | 116 Type type() const override { return CSSBasicShapeEllipseType; } |
120 | 117 |
121 RefPtrWillBeMember<CSSPrimitiveValue> m_centerX; | 118 RefPtr<CSSPrimitiveValue> m_centerX; |
122 RefPtrWillBeMember<CSSPrimitiveValue> m_centerY; | 119 RefPtr<CSSPrimitiveValue> m_centerY; |
123 RefPtrWillBeMember<CSSPrimitiveValue> m_radiusX; | 120 RefPtr<CSSPrimitiveValue> m_radiusX; |
124 RefPtrWillBeMember<CSSPrimitiveValue> m_radiusY; | 121 RefPtr<CSSPrimitiveValue> m_radiusY; |
125 }; | 122 }; |
126 | 123 |
127 class CSSBasicShapePolygon final : public CSSBasicShape { | 124 class CSSBasicShapePolygon final : public CSSBasicShape { |
128 public: | 125 public: |
129 static PassRefPtrWillBeRawPtr<CSSBasicShapePolygon> create() { return adoptR
efWillBeNoop(new CSSBasicShapePolygon); } | 126 static PassRefPtr<CSSBasicShapePolygon> create() { return adoptRef(new CSSBa
sicShapePolygon); } |
130 | 127 |
131 void appendPoint(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> x, PassRefPtrWill
BeRawPtr<CSSPrimitiveValue> y) | 128 void appendPoint(PassRefPtr<CSSPrimitiveValue> x, PassRefPtr<CSSPrimitiveVal
ue> y) |
132 { | 129 { |
133 m_values.append(x); | 130 m_values.append(x); |
134 m_values.append(y); | 131 m_values.append(y); |
135 } | 132 } |
136 | 133 |
137 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> getXAt(unsigned i) const { return
m_values.at(i * 2); } | 134 PassRefPtr<CSSPrimitiveValue> getXAt(unsigned i) const { return m_values.at(
i * 2); } |
138 PassRefPtrWillBeRawPtr<CSSPrimitiveValue> getYAt(unsigned i) const { return
m_values.at(i * 2 + 1); } | 135 PassRefPtr<CSSPrimitiveValue> getYAt(unsigned i) const { return m_values.at(
i * 2 + 1); } |
139 const WillBeHeapVector<RefPtrWillBeMember<CSSPrimitiveValue>>& values() cons
t { return m_values; } | 136 const Vector<RefPtr<CSSPrimitiveValue>>& values() const { return m_values; } |
140 | 137 |
141 void setWindRule(WindRule w) { m_windRule = w; } | 138 void setWindRule(WindRule w) { m_windRule = w; } |
142 WindRule windRule() const { return m_windRule; } | 139 WindRule windRule() const { return m_windRule; } |
143 | 140 |
144 String cssText() const override; | 141 String cssText() const override; |
145 bool equals(const CSSBasicShape&) const override; | 142 bool equals(const CSSBasicShape&) const override; |
146 | 143 |
147 DECLARE_VIRTUAL_TRACE(); | |
148 | |
149 private: | 144 private: |
150 CSSBasicShapePolygon() | 145 CSSBasicShapePolygon() |
151 : m_windRule(RULE_NONZERO) | 146 : m_windRule(RULE_NONZERO) |
152 { | 147 { |
153 } | 148 } |
154 | 149 |
155 Type type() const override { return CSSBasicShapePolygonType; } | 150 Type type() const override { return CSSBasicShapePolygonType; } |
156 | 151 |
157 WillBeHeapVector<RefPtrWillBeMember<CSSPrimitiveValue>> m_values; | 152 Vector<RefPtr<CSSPrimitiveValue>> m_values; |
158 WindRule m_windRule; | 153 WindRule m_windRule; |
159 }; | 154 }; |
160 | 155 |
161 class CSSBasicShapeInset final : public CSSBasicShape { | 156 class CSSBasicShapeInset final : public CSSBasicShape { |
162 public: | 157 public: |
163 static PassRefPtrWillBeRawPtr<CSSBasicShapeInset> create() { return adoptRef
WillBeNoop(new CSSBasicShapeInset); } | 158 static PassRefPtr<CSSBasicShapeInset> create() { return adoptRef(new CSSBasi
cShapeInset); } |
164 | 159 |
165 CSSPrimitiveValue* top() const { return m_top.get(); } | 160 CSSPrimitiveValue* top() const { return m_top.get(); } |
166 CSSPrimitiveValue* right() const { return m_right.get(); } | 161 CSSPrimitiveValue* right() const { return m_right.get(); } |
167 CSSPrimitiveValue* bottom() const { return m_bottom.get(); } | 162 CSSPrimitiveValue* bottom() const { return m_bottom.get(); } |
168 CSSPrimitiveValue* left() const { return m_left.get(); } | 163 CSSPrimitiveValue* left() const { return m_left.get(); } |
169 | 164 |
170 CSSPrimitiveValue* topLeftRadius() const { return m_topLeftRadius.get(); } | 165 CSSPrimitiveValue* topLeftRadius() const { return m_topLeftRadius.get(); } |
171 CSSPrimitiveValue* topRightRadius() const { return m_topRightRadius.get(); } | 166 CSSPrimitiveValue* topRightRadius() const { return m_topRightRadius.get(); } |
172 CSSPrimitiveValue* bottomRightRadius() const { return m_bottomRightRadius.ge
t(); } | 167 CSSPrimitiveValue* bottomRightRadius() const { return m_bottomRightRadius.ge
t(); } |
173 CSSPrimitiveValue* bottomLeftRadius() const { return m_bottomLeftRadius.get(
); } | 168 CSSPrimitiveValue* bottomLeftRadius() const { return m_bottomLeftRadius.get(
); } |
174 | 169 |
175 void setTop(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> top) { m_top = top; } | 170 void setTop(PassRefPtr<CSSPrimitiveValue> top) { m_top = top; } |
176 void setRight(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> right) { m_right = r
ight; } | 171 void setRight(PassRefPtr<CSSPrimitiveValue> right) { m_right = right; } |
177 void setBottom(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> bottom) { m_bottom
= bottom; } | 172 void setBottom(PassRefPtr<CSSPrimitiveValue> bottom) { m_bottom = bottom; } |
178 void setLeft(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> left) { m_left = left
; } | 173 void setLeft(PassRefPtr<CSSPrimitiveValue> left) { m_left = left; } |
179 | 174 |
180 void updateShapeSize4Values(CSSPrimitiveValue* top, CSSPrimitiveValue* right
, CSSPrimitiveValue* bottom, CSSPrimitiveValue* left) | 175 void updateShapeSize4Values(CSSPrimitiveValue* top, CSSPrimitiveValue* right
, CSSPrimitiveValue* bottom, CSSPrimitiveValue* left) |
181 { | 176 { |
182 setTop(top); | 177 setTop(top); |
183 setRight(right); | 178 setRight(right); |
184 setBottom(bottom); | 179 setBottom(bottom); |
185 setLeft(left); | 180 setLeft(left); |
186 } | 181 } |
187 | 182 |
188 void updateShapeSize1Value(CSSPrimitiveValue* value1) | 183 void updateShapeSize1Value(CSSPrimitiveValue* value1) |
189 { | 184 { |
190 updateShapeSize4Values(value1, value1, value1, value1); | 185 updateShapeSize4Values(value1, value1, value1, value1); |
191 } | 186 } |
192 | 187 |
193 void updateShapeSize2Values(CSSPrimitiveValue* value1, CSSPrimitiveValue* v
alue2) | 188 void updateShapeSize2Values(CSSPrimitiveValue* value1, CSSPrimitiveValue* v
alue2) |
194 { | 189 { |
195 updateShapeSize4Values(value1, value2, value1, value2); | 190 updateShapeSize4Values(value1, value2, value1, value2); |
196 } | 191 } |
197 | 192 |
198 void updateShapeSize3Values(CSSPrimitiveValue* value1, CSSPrimitiveValue* va
lue2, CSSPrimitiveValue* value3) | 193 void updateShapeSize3Values(CSSPrimitiveValue* value1, CSSPrimitiveValue* va
lue2, CSSPrimitiveValue* value3) |
199 { | 194 { |
200 updateShapeSize4Values(value1, value2, value3, value2); | 195 updateShapeSize4Values(value1, value2, value3, value2); |
201 } | 196 } |
202 | 197 |
203 | 198 |
204 void setTopLeftRadius(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> radius) { m_
topLeftRadius = radius; } | 199 void setTopLeftRadius(PassRefPtr<CSSPrimitiveValue> radius) { m_topLeftRadiu
s = radius; } |
205 void setTopRightRadius(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> radius) { m
_topRightRadius = radius; } | 200 void setTopRightRadius(PassRefPtr<CSSPrimitiveValue> radius) { m_topRightRad
ius = radius; } |
206 void setBottomRightRadius(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> radius)
{ m_bottomRightRadius = radius; } | 201 void setBottomRightRadius(PassRefPtr<CSSPrimitiveValue> radius) { m_bottomRi
ghtRadius = radius; } |
207 void setBottomLeftRadius(PassRefPtrWillBeRawPtr<CSSPrimitiveValue> radius) {
m_bottomLeftRadius = radius; } | 202 void setBottomLeftRadius(PassRefPtr<CSSPrimitiveValue> radius) { m_bottomLef
tRadius = radius; } |
208 | 203 |
209 String cssText() const override; | 204 String cssText() const override; |
210 bool equals(const CSSBasicShape&) const override; | 205 bool equals(const CSSBasicShape&) const override; |
211 | 206 |
212 DECLARE_VIRTUAL_TRACE(); | |
213 | |
214 private: | 207 private: |
215 CSSBasicShapeInset() { } | 208 CSSBasicShapeInset() { } |
216 | 209 |
217 Type type() const override { return CSSBasicShapeInsetType; } | 210 Type type() const override { return CSSBasicShapeInsetType; } |
218 | 211 |
219 RefPtrWillBeMember<CSSPrimitiveValue> m_top; | 212 RefPtr<CSSPrimitiveValue> m_top; |
220 RefPtrWillBeMember<CSSPrimitiveValue> m_right; | 213 RefPtr<CSSPrimitiveValue> m_right; |
221 RefPtrWillBeMember<CSSPrimitiveValue> m_bottom; | 214 RefPtr<CSSPrimitiveValue> m_bottom; |
222 RefPtrWillBeMember<CSSPrimitiveValue> m_left; | 215 RefPtr<CSSPrimitiveValue> m_left; |
223 | 216 |
224 RefPtrWillBeMember<CSSPrimitiveValue> m_topLeftRadius; | 217 RefPtr<CSSPrimitiveValue> m_topLeftRadius; |
225 RefPtrWillBeMember<CSSPrimitiveValue> m_topRightRadius; | 218 RefPtr<CSSPrimitiveValue> m_topRightRadius; |
226 RefPtrWillBeMember<CSSPrimitiveValue> m_bottomRightRadius; | 219 RefPtr<CSSPrimitiveValue> m_bottomRightRadius; |
227 RefPtrWillBeMember<CSSPrimitiveValue> m_bottomLeftRadius; | 220 RefPtr<CSSPrimitiveValue> m_bottomLeftRadius; |
228 }; | 221 }; |
229 | 222 |
230 DEFINE_TYPE_CASTS(CSSBasicShapeCircle, CSSBasicShape, shape, shape->isCircle(),
shape.isCircle()); | 223 DEFINE_TYPE_CASTS(CSSBasicShapeCircle, CSSBasicShape, shape, shape->isCircle(),
shape.isCircle()); |
231 DEFINE_TYPE_CASTS(CSSBasicShapeEllipse, CSSBasicShape, shape, shape->isEllipse()
, shape.isEllipse()); | 224 DEFINE_TYPE_CASTS(CSSBasicShapeEllipse, CSSBasicShape, shape, shape->isEllipse()
, shape.isEllipse()); |
232 DEFINE_TYPE_CASTS(CSSBasicShapePolygon, CSSBasicShape, shape, shape->isPolygon()
, shape.isPolygon()); | 225 DEFINE_TYPE_CASTS(CSSBasicShapePolygon, CSSBasicShape, shape, shape->isPolygon()
, shape.isPolygon()); |
233 DEFINE_TYPE_CASTS(CSSBasicShapeInset, CSSBasicShape, shape, shape->isInset(), sh
ape.isInset()); | 226 DEFINE_TYPE_CASTS(CSSBasicShapeInset, CSSBasicShape, shape, shape->isInset(), sh
ape.isInset()); |
234 | 227 |
235 } // namespace blink | 228 } // namespace blink |
236 | 229 |
237 #endif // CSSBasicShapes_h | 230 #endif // CSSBasicShapes_h |
OLD | NEW |