Index: Source/core/css/CSSBasicShapes.cpp |
diff --git a/Source/core/css/CSSBasicShapes.cpp b/Source/core/css/CSSBasicShapes.cpp |
index 72bfcef26d5af2c9cc68b41243562c6bc75579b9..692fff7539c0ff83bb3580700a5eece02d92197e 100644 |
--- a/Source/core/css/CSSBasicShapes.cpp |
+++ b/Source/core/css/CSSBasicShapes.cpp |
@@ -284,6 +284,23 @@ void CSSBasicShapePolygon::trace(Visitor* visitor) |
CSSBasicShape::trace(visitor); |
} |
+static bool buildInsetRadii(Vector<String> &radii, const String& topLeftRadius, const String& topRightRadius, const String& bottomRightRadius, const String& bottomLeftRadius) |
+{ |
+ bool showBottomLeft = topRightRadius != bottomLeftRadius; |
+ bool showBottomRight = showBottomLeft || (bottomRightRadius != topLeftRadius); |
+ bool showTopRight = showBottomRight || (topRightRadius != topLeftRadius); |
+ |
+ radii.append(topLeftRadius); |
+ if (showTopRight) |
+ radii.append(topRightRadius); |
+ if (showBottomRight) |
+ radii.append(bottomRightRadius); |
+ if (showBottomLeft) |
+ radii.append(bottomLeftRadius); |
+ |
+ return radii.size() == 1 && radii[0] == "0px"; |
+} |
+ |
static String buildInsetString(const String& top, const String& right, const String& bottom, const String& left, |
const String& topLeftRadiusWidth, const String& topLeftRadiusHeight, |
const String& topRightRadiusWidth, const String& topRightRadiusHeight, |
@@ -296,43 +313,47 @@ static String buildInsetString(const String& top, const String& right, const Str |
StringBuilder result; |
result.appendLiteral(opening); |
result.append(top); |
- if (!right.isNull()) { |
+ bool showLeftArg = !left.isNull() && left != right; |
+ bool showBottomArg = !bottom.isNull() && (bottom != top || showLeftArg); |
+ bool showRightArg = !right.isNull() && (right != top || showBottomArg); |
+ if (showRightArg) { |
result.appendLiteral(separator); |
result.append(right); |
} |
- if (!bottom.isNull()) { |
+ if (showBottomArg) { |
result.appendLiteral(separator); |
result.append(bottom); |
} |
- if (!left.isNull()) { |
+ if (showLeftArg) { |
result.appendLiteral(separator); |
result.append(left); |
} |
if (!topLeftRadiusWidth.isNull() && !topLeftRadiusHeight.isNull()) { |
- result.appendLiteral(separator); |
- result.appendLiteral(cornersSeparator); |
- result.appendLiteral(separator); |
+ Vector<String> horizontalRadii; |
+ bool areDefaultCornerRadii = buildInsetRadii(horizontalRadii, topLeftRadiusWidth, topRightRadiusWidth, bottomRightRadiusWidth, bottomLeftRadiusWidth); |
- result.append(topLeftRadiusWidth); |
- result.appendLiteral(separator); |
- result.append(topRightRadiusWidth); |
- result.appendLiteral(separator); |
- result.append(bottomRightRadiusWidth); |
- result.appendLiteral(separator); |
- result.append(bottomLeftRadiusWidth); |
+ Vector<String> verticalRadii; |
+ areDefaultCornerRadii &= buildInsetRadii(verticalRadii, topLeftRadiusHeight, topRightRadiusHeight, bottomRightRadiusHeight, bottomLeftRadiusHeight); |
- result.appendLiteral(separator); |
- result.appendLiteral("/"); |
- result.appendLiteral(separator); |
- |
- result.append(topLeftRadiusHeight); |
- result.appendLiteral(separator); |
- result.append(topRightRadiusHeight); |
- result.appendLiteral(separator); |
- result.append(bottomRightRadiusHeight); |
- result.appendLiteral(separator); |
- result.append(bottomLeftRadiusHeight); |
+ if (!areDefaultCornerRadii) { |
+ result.appendLiteral(separator); |
+ result.appendLiteral(cornersSeparator); |
+ |
+ for (size_t i = 0; i < horizontalRadii.size(); ++i) { |
+ result.appendLiteral(separator); |
+ result.append(horizontalRadii[i]); |
+ } |
+ if (horizontalRadii != verticalRadii) { |
+ result.appendLiteral(separator); |
+ result.appendLiteral("/"); |
+ |
+ for (size_t i = 0; i < verticalRadii.size(); ++i) { |
+ result.appendLiteral(separator); |
+ result.append(verticalRadii[i]); |
+ } |
+ } |
+ } |
} |
result.append(')'); |