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 23 matching lines...) Expand all Loading... |
34 #include "core/css/Pair.h" | 34 #include "core/css/Pair.h" |
35 #include "platform/Length.h" | 35 #include "platform/Length.h" |
36 #include "wtf/text/StringBuilder.h" | 36 #include "wtf/text/StringBuilder.h" |
37 | 37 |
38 using namespace WTF; | 38 using namespace WTF; |
39 | 39 |
40 namespace WebCore { | 40 namespace WebCore { |
41 | 41 |
42 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(CSSBasicShape) | 42 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(CSSBasicShape) |
43 | 43 |
44 static String buildRectangleString(const String& x, const String& y, const Strin
g& width, const String& height, const String& radiusX, const String& radiusY, co
nst String& layoutBox) | |
45 { | |
46 const char opening[] = "rectangle("; | |
47 const char separator[] = ", "; | |
48 StringBuilder result; | |
49 // Compute the required capacity in advance to reduce allocations. | |
50 result.reserveCapacity((sizeof(opening) - 1) + (5 * (sizeof(separator) - 1))
+ 1 + x.length() + y.length() + width.length() + height.length() + radiusX.leng
th() + radiusY.length() + (layoutBox.isEmpty() ? 0 : layoutBox.length() + 1)); | |
51 result.appendLiteral(opening); | |
52 result.append(x); | |
53 result.appendLiteral(separator); | |
54 result.append(y); | |
55 result.appendLiteral(separator); | |
56 result.append(width); | |
57 result.appendLiteral(separator); | |
58 result.append(height); | |
59 if (!radiusX.isNull()) { | |
60 result.appendLiteral(separator); | |
61 result.append(radiusX); | |
62 if (!radiusY.isNull()) { | |
63 result.appendLiteral(separator); | |
64 result.append(radiusY); | |
65 } | |
66 } | |
67 if (!layoutBox.isEmpty()) { | |
68 result.append(' '); | |
69 result.append(layoutBox); | |
70 } | |
71 result.append(')'); | |
72 return result.toString(); | |
73 } | |
74 | |
75 String CSSBasicShapeRectangle::cssText() const | |
76 { | |
77 return buildRectangleString(m_x->cssText(), | |
78 m_y->cssText(), | |
79 m_width->cssText(), | |
80 m_height->cssText(), | |
81 m_radiusX.get() ? m_radiusX->cssText() : String(), | |
82 m_radiusY.get() ? m_radiusY->cssText() : String(), | |
83 m_layoutBox ? m_layoutBox->cssText() : String()); | |
84 } | |
85 | |
86 bool CSSBasicShapeRectangle::equals(const CSSBasicShape& shape) const | |
87 { | |
88 if (shape.type() != CSSBasicShapeRectangleType) | |
89 return false; | |
90 | |
91 const CSSBasicShapeRectangle& other = static_cast<const CSSBasicShapeRectang
le&>(shape); | |
92 return compareCSSValuePtr(m_x, other.m_x) | |
93 && compareCSSValuePtr(m_y, other.m_y) | |
94 && compareCSSValuePtr(m_width, other.m_width) | |
95 && compareCSSValuePtr(m_height, other.m_height) | |
96 && compareCSSValuePtr(m_radiusX, other.m_radiusX) | |
97 && compareCSSValuePtr(m_radiusY, other.m_radiusY) | |
98 && compareCSSValuePtr(m_layoutBox, other.m_layoutBox); | |
99 } | |
100 | |
101 void CSSBasicShapeRectangle::trace(Visitor* visitor) | |
102 { | |
103 visitor->trace(m_y); | |
104 visitor->trace(m_x); | |
105 visitor->trace(m_width); | |
106 visitor->trace(m_height); | |
107 visitor->trace(m_radiusX); | |
108 visitor->trace(m_radiusY); | |
109 CSSBasicShape::trace(visitor); | |
110 } | |
111 | |
112 static String buildCircleString(const String& radius, const String& centerX, con
st String& centerY, const String& layoutBox) | 44 static String buildCircleString(const String& radius, const String& centerX, con
st String& centerY, const String& layoutBox) |
113 { | 45 { |
114 char at[] = "at"; | 46 char at[] = "at"; |
115 char separator[] = " "; | 47 char separator[] = " "; |
116 StringBuilder result; | 48 StringBuilder result; |
117 result.appendLiteral("circle("); | 49 result.appendLiteral("circle("); |
118 if (!radius.isNull()) | 50 if (!radius.isNull()) |
119 result.append(radius); | 51 result.append(radius); |
120 | 52 |
121 if (!centerX.isNull() || !centerY.isNull()) { | 53 if (!centerX.isNull() || !centerY.isNull()) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 } | 133 } |
202 | 134 |
203 void CSSBasicShapeCircle::trace(Visitor* visitor) | 135 void CSSBasicShapeCircle::trace(Visitor* visitor) |
204 { | 136 { |
205 visitor->trace(m_centerX); | 137 visitor->trace(m_centerX); |
206 visitor->trace(m_centerY); | 138 visitor->trace(m_centerY); |
207 visitor->trace(m_radius); | 139 visitor->trace(m_radius); |
208 CSSBasicShape::trace(visitor); | 140 CSSBasicShape::trace(visitor); |
209 } | 141 } |
210 | 142 |
211 static String buildDeprecatedCircleString(const String& x, const String& y, cons
t String& radius) | |
212 { | |
213 return "circle(" + x + ", " + y + ", " + radius + ')'; | |
214 } | |
215 | |
216 String CSSDeprecatedBasicShapeCircle::cssText() const | |
217 { | |
218 return buildDeprecatedCircleString(m_centerX->cssText(), m_centerY->cssText(
), m_radius->cssText()); | |
219 } | |
220 | |
221 bool CSSDeprecatedBasicShapeCircle::equals(const CSSBasicShape& shape) const | |
222 { | |
223 if (shape.type() != CSSDeprecatedBasicShapeCircleType) | |
224 return false; | |
225 | |
226 const CSSDeprecatedBasicShapeCircle& other = static_cast<const CSSDeprecated
BasicShapeCircle&>(shape); | |
227 return compareCSSValuePtr(m_centerX, other.m_centerX) | |
228 && compareCSSValuePtr(m_centerY, other.m_centerY) | |
229 && compareCSSValuePtr(m_radius, other.m_radius); | |
230 } | |
231 | |
232 void CSSDeprecatedBasicShapeCircle::trace(Visitor* visitor) | |
233 { | |
234 visitor->trace(m_centerX); | |
235 visitor->trace(m_centerY); | |
236 visitor->trace(m_radius); | |
237 CSSBasicShape::trace(visitor); | |
238 } | |
239 | |
240 static String buildEllipseString(const String& radiusX, const String& radiusY, c
onst String& centerX, const String& centerY, const String& box) | 143 static String buildEllipseString(const String& radiusX, const String& radiusY, c
onst String& centerX, const String& centerY, const String& box) |
241 { | 144 { |
242 char at[] = "at"; | 145 char at[] = "at"; |
243 char separator[] = " "; | 146 char separator[] = " "; |
244 StringBuilder result; | 147 StringBuilder result; |
245 result.appendLiteral("ellipse("); | 148 result.appendLiteral("ellipse("); |
246 bool needsSeparator = false; | 149 bool needsSeparator = false; |
247 if (!radiusX.isNull()) { | 150 if (!radiusX.isNull()) { |
248 result.append(radiusX); | 151 result.append(radiusX); |
249 needsSeparator = true; | 152 needsSeparator = true; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 202 |
300 void CSSBasicShapeEllipse::trace(Visitor* visitor) | 203 void CSSBasicShapeEllipse::trace(Visitor* visitor) |
301 { | 204 { |
302 visitor->trace(m_centerX); | 205 visitor->trace(m_centerX); |
303 visitor->trace(m_centerY); | 206 visitor->trace(m_centerY); |
304 visitor->trace(m_radiusX); | 207 visitor->trace(m_radiusX); |
305 visitor->trace(m_radiusY); | 208 visitor->trace(m_radiusY); |
306 CSSBasicShape::trace(visitor); | 209 CSSBasicShape::trace(visitor); |
307 } | 210 } |
308 | 211 |
309 static String buildDeprecatedEllipseString(const String& x, const String& y, con
st String& radiusX, const String& radiusY) | |
310 { | |
311 return "ellipse(" + x + ", " + y + ", " + radiusX + ", " + radiusY + ')'; | |
312 } | |
313 | |
314 String CSSDeprecatedBasicShapeEllipse::cssText() const | |
315 { | |
316 return buildDeprecatedEllipseString(m_centerX->cssText(), m_centerY->cssText
(), m_radiusX->cssText(), m_radiusY->cssText()); | |
317 } | |
318 | |
319 bool CSSDeprecatedBasicShapeEllipse::equals(const CSSBasicShape& shape) const | |
320 { | |
321 if (shape.type() != CSSDeprecatedBasicShapeEllipseType) | |
322 return false; | |
323 | |
324 const CSSDeprecatedBasicShapeEllipse& other = static_cast<const CSSDeprecate
dBasicShapeEllipse&>(shape); | |
325 return compareCSSValuePtr(m_centerX, other.m_centerX) | |
326 && compareCSSValuePtr(m_centerY, other.m_centerY) | |
327 && compareCSSValuePtr(m_radiusX, other.m_radiusX) | |
328 && compareCSSValuePtr(m_radiusY, other.m_radiusY); | |
329 } | |
330 | |
331 void CSSDeprecatedBasicShapeEllipse::trace(Visitor* visitor) | |
332 { | |
333 visitor->trace(m_centerX); | |
334 visitor->trace(m_centerY); | |
335 visitor->trace(m_radiusX); | |
336 visitor->trace(m_radiusY); | |
337 CSSBasicShape::trace(visitor); | |
338 } | |
339 | |
340 static String buildPolygonString(const WindRule& windRule, const Vector<String>&
points, const String& layoutBox) | 212 static String buildPolygonString(const WindRule& windRule, const Vector<String>&
points, const String& layoutBox) |
341 { | 213 { |
342 ASSERT(!(points.size() % 2)); | 214 ASSERT(!(points.size() % 2)); |
343 | 215 |
344 StringBuilder result; | 216 StringBuilder result; |
345 const char evenOddOpening[] = "polygon(evenodd, "; | 217 const char evenOddOpening[] = "polygon(evenodd, "; |
346 const char nonZeroOpening[] = "polygon("; | 218 const char nonZeroOpening[] = "polygon("; |
347 const char commaSeparator[] = ", "; | 219 const char commaSeparator[] = ", "; |
348 COMPILE_ASSERT(sizeof(evenOddOpening) > sizeof(nonZeroOpening), polygon_stri
ng_openings_have_same_length); | 220 COMPILE_ASSERT(sizeof(evenOddOpening) > sizeof(nonZeroOpening), polygon_stri
ng_openings_have_same_length); |
349 | 221 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 | 277 |
406 return compareCSSValueVector(m_values, rhs.m_values); | 278 return compareCSSValueVector(m_values, rhs.m_values); |
407 } | 279 } |
408 | 280 |
409 void CSSBasicShapePolygon::trace(Visitor* visitor) | 281 void CSSBasicShapePolygon::trace(Visitor* visitor) |
410 { | 282 { |
411 visitor->trace(m_values); | 283 visitor->trace(m_values); |
412 CSSBasicShape::trace(visitor); | 284 CSSBasicShape::trace(visitor); |
413 } | 285 } |
414 | 286 |
415 static String buildInsetRectangleString(const String& top, const String& right,
const String& bottom, const String& left, const String& radiusX, const String& r
adiusY, const String& layoutBox) | |
416 { | |
417 const char opening[] = "inset-rectangle("; | |
418 const char separator[] = ", "; | |
419 StringBuilder result; | |
420 // Compute the required capacity in advance to reduce allocations. | |
421 result.reserveCapacity((sizeof(opening) - 1) + (5 * (sizeof(separator) - 1))
+ 1 + top.length() + right.length() + bottom.length() + left.length() + radiusX
.length() + radiusY.length() + (layoutBox.isEmpty() ? 0 : layoutBox.length() + 1
)); | |
422 result.appendLiteral(opening); | |
423 result.append(top); | |
424 result.appendLiteral(separator); | |
425 result.append(right); | |
426 result.appendLiteral(separator); | |
427 result.append(bottom); | |
428 result.appendLiteral(separator); | |
429 result.append(left); | |
430 if (!radiusX.isNull()) { | |
431 result.appendLiteral(separator); | |
432 result.append(radiusX); | |
433 if (!radiusY.isNull()) { | |
434 result.appendLiteral(separator); | |
435 result.append(radiusY); | |
436 } | |
437 } | |
438 result.append(')'); | |
439 | |
440 if (!layoutBox.isEmpty()) { | |
441 result.append(' '); | |
442 result.append(layoutBox); | |
443 } | |
444 | |
445 return result.toString(); | |
446 } | |
447 | |
448 String CSSBasicShapeInsetRectangle::cssText() const | |
449 { | |
450 return buildInsetRectangleString(m_top->cssText(), | |
451 m_right->cssText(), | |
452 m_bottom->cssText(), | |
453 m_left->cssText(), | |
454 m_radiusX.get() ? m_radiusX->cssText() : String(), | |
455 m_radiusY.get() ? m_radiusY->cssText() : String(), | |
456 m_layoutBox ? m_layoutBox->cssText() : String()); | |
457 } | |
458 | |
459 bool CSSBasicShapeInsetRectangle::equals(const CSSBasicShape& shape) const | |
460 { | |
461 if (shape.type() != CSSBasicShapeInsetRectangleType) | |
462 return false; | |
463 | |
464 const CSSBasicShapeInsetRectangle& other = static_cast<const CSSBasicShapeIn
setRectangle&>(shape); | |
465 return compareCSSValuePtr(m_top, other.m_top) | |
466 && compareCSSValuePtr(m_right, other.m_right) | |
467 && compareCSSValuePtr(m_bottom, other.m_bottom) | |
468 && compareCSSValuePtr(m_left, other.m_left) | |
469 && compareCSSValuePtr(m_radiusX, other.m_radiusX) | |
470 && compareCSSValuePtr(m_radiusY, other.m_radiusY) | |
471 && compareCSSValuePtr(m_layoutBox, other.m_layoutBox); | |
472 } | |
473 | |
474 void CSSBasicShapeInsetRectangle::trace(Visitor* visitor) | |
475 { | |
476 visitor->trace(m_right); | |
477 visitor->trace(m_top); | |
478 visitor->trace(m_bottom); | |
479 visitor->trace(m_left); | |
480 visitor->trace(m_radiusX); | |
481 visitor->trace(m_radiusY); | |
482 CSSBasicShape::trace(visitor); | |
483 } | |
484 | |
485 static String buildInsetString(const String& top, const String& right, const Str
ing& bottom, const String& left, | 287 static String buildInsetString(const String& top, const String& right, const Str
ing& bottom, const String& left, |
486 const String& topLeftRadiusWidth, const String& topLeftRadiusHeight, | 288 const String& topLeftRadiusWidth, const String& topLeftRadiusHeight, |
487 const String& topRightRadiusWidth, const String& topRightRadiusHeight, | 289 const String& topRightRadiusWidth, const String& topRightRadiusHeight, |
488 const String& bottomRightRadiusWidth, const String& bottomRightRadiusHeight, | 290 const String& bottomRightRadiusWidth, const String& bottomRightRadiusHeight, |
489 const String& bottomLeftRadiusWidth, const String& bottomLeftRadiusHeight) | 291 const String& bottomLeftRadiusWidth, const String& bottomLeftRadiusHeight) |
490 { | 292 { |
491 char opening[] = "inset("; | 293 char opening[] = "inset("; |
492 char separator[] = " "; | 294 char separator[] = " "; |
493 char cornersSeparator[] = "round"; | 295 char cornersSeparator[] = "round"; |
494 StringBuilder result; | 296 StringBuilder result; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 visitor->trace(m_left); | 404 visitor->trace(m_left); |
603 visitor->trace(m_topLeftRadius); | 405 visitor->trace(m_topLeftRadius); |
604 visitor->trace(m_topRightRadius); | 406 visitor->trace(m_topRightRadius); |
605 visitor->trace(m_bottomRightRadius); | 407 visitor->trace(m_bottomRightRadius); |
606 visitor->trace(m_bottomLeftRadius); | 408 visitor->trace(m_bottomLeftRadius); |
607 CSSBasicShape::trace(visitor); | 409 CSSBasicShape::trace(visitor); |
608 } | 410 } |
609 | 411 |
610 } // namespace WebCore | 412 } // namespace WebCore |
611 | 413 |
OLD | NEW |