Changeset 165472 in webkit for trunk/Source/WebCore/css/CSSBasicShapes.cpp
- Timestamp:
- Mar 12, 2014, 8:41:55 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/css/CSSBasicShapes.cpp
r165277 r165472 41 41 namespace WebCore { 42 42 43 static String buildRectangleString(const String& x, const String& y, const String& width, const String& height, const String& radiusX, const String& radiusY, const String& box)44 {45 char opening[] = "rectangle(";46 char separator[] = ", ";47 StringBuilder result;48 // Compute the required capacity in advance to reduce allocations.49 result.reserveCapacity((sizeof(opening) - 1) + (5 * (sizeof(separator) - 1)) + 1 + x.length() + y.length() + width.length() + height.length() + radiusX.length() + radiusY.length() + (box.length() ? box.length() + 1 : 0));50 result.appendLiteral(opening);51 result.append(x);52 result.appendLiteral(separator);53 result.append(y);54 result.appendLiteral(separator);55 result.append(width);56 result.appendLiteral(separator);57 result.append(height);58 if (!radiusX.isNull()) {59 result.appendLiteral(separator);60 result.append(radiusX);61 if (!radiusY.isNull()) {62 result.appendLiteral(separator);63 result.append(radiusY);64 }65 }66 result.append(')');67 if (box.length()) {68 result.append(' ');69 result.append(box);70 }71 return result.toString();72 }73 74 String CSSBasicShapeRectangle::cssText() const75 {76 return buildRectangleString(m_x->cssText(),77 m_y->cssText(),78 m_width->cssText(),79 m_height->cssText(),80 m_radiusX.get() ? m_radiusX->cssText() : String(),81 m_radiusY.get() ? m_radiusY->cssText() : String(),82 m_layoutBox ? m_layoutBox->cssText() : String());83 }84 85 bool CSSBasicShapeRectangle::equals(const CSSBasicShape& shape) const86 {87 if (shape.type() != CSSBasicShapeRectangleType)88 return false;89 90 const CSSBasicShapeRectangle& other = static_cast<const CSSBasicShapeRectangle&>(shape);91 return compareCSSValuePtr(m_x, other.m_x)92 && compareCSSValuePtr(m_y, other.m_y)93 && compareCSSValuePtr(m_width, other.m_width)94 && compareCSSValuePtr(m_height, other.m_height)95 && compareCSSValuePtr(m_radiusX, other.m_radiusX)96 && compareCSSValuePtr(m_radiusY, other.m_radiusY)97 && compareCSSValuePtr(m_layoutBox, other.m_layoutBox);98 }99 100 43 static String serializePositionOffset(const Pair& offset, const Pair& other) 101 44 { … … 189 132 } 190 133 191 static String buildDeprecatedCircleString(const String& x, const String& y, const String& radius, const String& box)192 {193 StringBuilder result;194 char opening[] = "circle(";195 char separator[] = ", ";196 result.appendLiteral(opening);197 result.append(x);198 result.appendLiteral(separator);199 result.append(y);200 result.appendLiteral(separator);201 result.append(radius);202 result.append(')');203 if (box.length()) {204 result.append(' ');205 result.append(box);206 }207 return result.toString();208 }209 210 String CSSDeprecatedBasicShapeCircle::cssText() const211 {212 return buildDeprecatedCircleString(m_centerX->cssText(), m_centerY->cssText(), m_radius->cssText(), m_layoutBox ? m_layoutBox->cssText() : String());213 }214 215 bool CSSDeprecatedBasicShapeCircle::equals(const CSSBasicShape& shape) const216 {217 if (shape.type() != CSSDeprecatedBasicShapeCircleType)218 return false;219 220 const CSSDeprecatedBasicShapeCircle& other = static_cast<const CSSDeprecatedBasicShapeCircle&>(shape);221 return compareCSSValuePtr(m_centerX, other.m_centerX)222 && compareCSSValuePtr(m_centerY, other.m_centerY)223 && compareCSSValuePtr(m_radius, other.m_radius)224 && compareCSSValuePtr(m_layoutBox, other.m_layoutBox);225 }226 227 134 static String buildEllipseString(const String& radiusX, const String& radiusY, const String& centerX, const String& centerY, const String& box) 228 135 { … … 279 186 280 187 const CSSBasicShapeEllipse& other = static_cast<const CSSBasicShapeEllipse&>(shape); 281 return compareCSSValuePtr(m_centerX, other.m_centerX)282 && compareCSSValuePtr(m_centerY, other.m_centerY)283 && compareCSSValuePtr(m_radiusX, other.m_radiusX)284 && compareCSSValuePtr(m_radiusY, other.m_radiusY)285 && compareCSSValuePtr(m_layoutBox, other.m_layoutBox);286 }287 288 static String buildDeprecatedEllipseString(const String& x, const String& y, const String& radiusX, const String& radiusY, const String& box)289 {290 StringBuilder result;291 char opening[] = "ellipse(";292 char separator[] = ", ";293 result.appendLiteral(opening);294 result.append(x);295 result.appendLiteral(separator);296 result.append(y);297 result.appendLiteral(separator);298 result.append(radiusX);299 result.appendLiteral(separator);300 result.append(radiusY);301 result.append(')');302 if (box.length()) {303 result.append(' ');304 result.append(box);305 }306 return result.toString();307 }308 309 String CSSDeprecatedBasicShapeEllipse::cssText() const310 {311 return buildDeprecatedEllipseString(m_centerX->cssText(), m_centerY->cssText(), m_radiusX->cssText(), m_radiusY->cssText(), m_layoutBox ? m_layoutBox->cssText() : String());312 }313 314 bool CSSDeprecatedBasicShapeEllipse::equals(const CSSBasicShape& shape) const315 {316 if (shape.type() != CSSDeprecatedBasicShapeEllipseType)317 return false;318 319 const CSSDeprecatedBasicShapeEllipse& other = static_cast<const CSSDeprecatedBasicShapeEllipse&>(shape);320 188 return compareCSSValuePtr(m_centerX, other.m_centerX) 321 189 && compareCSSValuePtr(m_centerY, other.m_centerY) … … 393 261 } 394 262 395 static String buildInsetRectangleString(const String& top, const String& right, const String& bottom, const String& left, const String& radiusX, const String& radiusY, const String& box)396 {397 char opening[] = "inset-rectangle(";398 char separator[] = ", ";399 StringBuilder result;400 // Compute the required capacity in advance to reduce allocations.401 result.reserveCapacity((sizeof(opening) - 1) + (5 * (sizeof(separator) - 1)) + 1 + top.length() + right.length() + bottom.length() + left.length() + radiusX.length() + radiusY.length() + (box.length() ? box.length() + 1 : 0));402 result.appendLiteral(opening);403 result.append(top);404 result.appendLiteral(separator);405 result.append(right);406 result.appendLiteral(separator);407 result.append(bottom);408 result.appendLiteral(separator);409 result.append(left);410 if (!radiusX.isNull()) {411 result.appendLiteral(separator);412 result.append(radiusX);413 if (!radiusY.isNull()) {414 result.appendLiteral(separator);415 result.append(radiusY);416 }417 }418 result.append(')');419 if (box.length()) {420 result.append(' ');421 result.append(box);422 }423 return result.toString();424 }425 426 String CSSBasicShapeInsetRectangle::cssText() const427 {428 return buildInsetRectangleString(m_top->cssText(),429 m_right->cssText(),430 m_bottom->cssText(),431 m_left->cssText(),432 m_radiusX.get() ? m_radiusX->cssText() : String(),433 m_radiusY.get() ? m_radiusY->cssText() : String(),434 m_layoutBox ? m_layoutBox->cssText() : String());435 }436 437 bool CSSBasicShapeInsetRectangle::equals(const CSSBasicShape& shape) const438 {439 if (shape.type() != CSSBasicShapeInsetRectangleType)440 return false;441 442 const CSSBasicShapeInsetRectangle& other = static_cast<const CSSBasicShapeInsetRectangle&>(shape);443 return compareCSSValuePtr(m_top, other.m_top)444 && compareCSSValuePtr(m_right, other.m_right)445 && compareCSSValuePtr(m_bottom, other.m_bottom)446 && compareCSSValuePtr(m_left, other.m_left)447 && compareCSSValuePtr(m_radiusX, other.m_radiusX)448 && compareCSSValuePtr(m_radiusY, other.m_radiusY)449 && compareCSSValuePtr(m_layoutBox, other.m_layoutBox);450 }451 452 263 static String buildInsetString(const String& top, const String& right, const String& bottom, const String& left, 453 264 const String& topLeftRadiusWidth, const String& topLeftRadiusHeight,
Note:
See TracChangeset
for help on using the changeset viewer.