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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 NullableCSSValue referenceBox() const { return m_referenceBox; } | 55 const NullableCSSValue& referenceBox() const { return m_referenceBox; } |
56 void setReferenceBox(CSSPrimitiveValue referenceBox) { m_referenceBox = refe
renceBox; } | 56 void setReferenceBox(const CSSPrimitiveValue& referenceBox) { m_referenceBox
= referenceBox; } |
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 NullableCSSValue 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 NullableCSSValue centerX() const { return m_centerX; } | 77 const NullableCSSValue& centerX() const { return m_centerX; } |
78 NullableCSSValue centerY() const { return m_centerY; } | 78 const NullableCSSValue& centerY() const { return m_centerY; } |
79 NullableCSSValue radius() const { return m_radius; } | 79 const NullableCSSValue& radius() const { return m_radius; } |
80 | 80 |
81 void setCenterX(CSSPrimitiveValue centerX) { m_centerX = centerX; } | 81 void setCenterX(const CSSPrimitiveValue& centerX) { m_centerX = centerX; } |
82 void setCenterY(CSSPrimitiveValue centerY) { m_centerY = centerY; } | 82 void setCenterY(const CSSPrimitiveValue& centerY) { m_centerY = centerY; } |
83 void setRadius(CSSPrimitiveValue radius) { m_radius = radius; } | 83 void setRadius(const 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 NullableCSSValue m_centerX; | 92 NullableCSSValue m_centerX; |
93 NullableCSSValue m_centerY; | 93 NullableCSSValue m_centerY; |
94 NullableCSSValue 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 NullableCSSValue centerX() const { return m_centerX; } | 104 const NullableCSSValue& centerX() const { return m_centerX; } |
105 NullableCSSValue centerY() const { return m_centerY; } | 105 const NullableCSSValue& centerY() const { return m_centerY; } |
106 NullableCSSValue radiusX() const { return m_radiusX; } | 106 const NullableCSSValue& radiusX() const { return m_radiusX; } |
107 NullableCSSValue radiusY() const { return m_radiusY; } | 107 const NullableCSSValue& radiusY() const { return m_radiusY; } |
108 | 108 |
109 void setCenterX(CSSPrimitiveValue centerX) { m_centerX = centerX; } | 109 void setCenterX(CSSPrimitiveValue centerX) { m_centerX = centerX; } |
110 void setCenterY(CSSPrimitiveValue centerY) { m_centerY = centerY; } | 110 void setCenterY(CSSPrimitiveValue centerY) { m_centerY = centerY; } |
111 void setRadiusX(CSSPrimitiveValue radiusX) { m_radiusX = radiusX; } | 111 void setRadiusX(CSSPrimitiveValue radiusX) { m_radiusX = radiusX; } |
112 void setRadiusY(CSSPrimitiveValue radiusY) { m_radiusY = 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 NullableCSSValue m_centerX; | 121 NullableCSSValue m_centerX; |
122 NullableCSSValue m_centerY; | 122 NullableCSSValue m_centerY; |
123 NullableCSSValue m_radiusX; | 123 NullableCSSValue m_radiusX; |
124 NullableCSSValue 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(CSSPrimitiveValue x, CSSPrimitiveValue y) | 131 void appendPoint(const CSSPrimitiveValue& x, const 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 CSSPrimitiveValue getXAt(unsigned i) const { return toCSSPrimitiveValue(m_va
lues.at(i * 2)); } | 137 const CSSPrimitiveValue& getXAt(unsigned i) const { return toCSSPrimitiveVal
ue(m_values.at(i * 2)); } |
138 CSSPrimitiveValue getYAt(unsigned i) const { return toCSSPrimitiveValue(m_va
lues.at(i * 2 + 1)); } | 138 const CSSPrimitiveValue& getYAt(unsigned i) const { return toCSSPrimitiveVal
ue(m_values.at(i * 2 + 1)); } |
139 const WillBeHeapVector<CSSValue>& values() const { 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<CSSValue> 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 toCSSPrimitiveValue(*m_top); } | 165 const CSSPrimitiveValue& top() const { return toCSSPrimitiveValue(m_top); } |
166 CSSPrimitiveValue right() const { return toCSSPrimitiveValue(*m_right); } | 166 const CSSPrimitiveValue& right() const { return toCSSPrimitiveValue(m_right)
; } |
167 CSSPrimitiveValue bottom() const { return toCSSPrimitiveValue(*m_bottom); } | 167 const CSSPrimitiveValue& bottom() const { return toCSSPrimitiveValue(m_botto
m); } |
168 CSSPrimitiveValue left() const { return toCSSPrimitiveValue(*m_left); } | 168 const CSSPrimitiveValue& left() const { return toCSSPrimitiveValue(m_left);
} |
169 | 169 |
170 NullableCSSValue topLeftRadius() const { return m_topLeftRadius; } | 170 const NullableCSSValue& topLeftRadius() const { return m_topLeftRadius; } |
171 NullableCSSValue topRightRadius() const { return m_topRightRadius; } | 171 const NullableCSSValue& topRightRadius() const { return m_topRightRadius; } |
172 NullableCSSValue bottomRightRadius() const { return m_bottomRightRadius; } | 172 const NullableCSSValue& bottomRightRadius() const { return m_bottomRightRadi
us; } |
173 NullableCSSValue bottomLeftRadius() const { return m_bottomLeftRadius; } | 173 const NullableCSSValue& bottomLeftRadius() const { return m_bottomLeftRadius
; } |
174 | 174 |
175 void setTop(CSSPrimitiveValue top) { m_top = top; } | 175 void setTop(const CSSPrimitiveValue& top) { m_top = top; } |
176 void setRight(CSSPrimitiveValue right) { m_right = right; } | 176 void setRight(const CSSPrimitiveValue& right) { m_right = right; } |
177 void setBottom(CSSPrimitiveValue bottom) { m_bottom = bottom; } | 177 void setBottom(const CSSPrimitiveValue& bottom) { m_bottom = bottom; } |
178 void setLeft(CSSPrimitiveValue left) { m_left = left; } | 178 void setLeft(const CSSPrimitiveValue& left) { m_left = left; } |
179 | 179 |
180 void updateShapeSize4Values(CSSPrimitiveValue top, CSSPrimitiveValue right,
CSSPrimitiveValue bottom, CSSPrimitiveValue left) | 180 void updateShapeSize4Values(const CSSPrimitiveValue& top, const CSSPrimitive
Value& right, const CSSPrimitiveValue& bottom, const 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(const 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 val
ue2) | 193 void updateShapeSize2Values(const CSSPrimitiveValue& value1, const CSSPrimi
tiveValue& value2) |
194 { | 194 { |
195 updateShapeSize4Values(value1, value2, value1, value2); | 195 updateShapeSize4Values(value1, value2, value1, value2); |
196 } | 196 } |
197 | 197 |
198 void updateShapeSize3Values(CSSPrimitiveValue value1, CSSPrimitiveValue valu
e2, CSSPrimitiveValue value3) | 198 void updateShapeSize3Values(const CSSPrimitiveValue& value1, const CSSPrimit
iveValue& value2, const 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(CSSPrimitiveValue radius) { m_topLeftRadius = radius;
} | 204 void setTopLeftRadius(const CSSPrimitiveValue& radius) { m_topLeftRadius = r
adius; } |
205 void setTopRightRadius(CSSPrimitiveValue radius) { m_topRightRadius = radius
; } | 205 void setTopRightRadius(const CSSPrimitiveValue& radius) { m_topRightRadius =
radius; } |
206 void setBottomRightRadius(CSSPrimitiveValue radius) { m_bottomRightRadius =
radius; } | 206 void setBottomRightRadius(const CSSPrimitiveValue& radius) { m_bottomRightRa
dius = radius; } |
207 void setBottomLeftRadius(CSSPrimitiveValue radius) { m_bottomLeftRadius = ra
dius; } | 207 void setBottomLeftRadius(const CSSPrimitiveValue& radius) { m_bottomLeftRadi
us = radius; } |
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; } |
(...skipping 10 matching lines...) Expand all Loading... |
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 |