Index: Source/core/css/CSSBasicShapes.cpp |
diff --git a/Source/core/css/CSSBasicShapes.cpp b/Source/core/css/CSSBasicShapes.cpp |
index 72bfcef26d5af2c9cc68b41243562c6bc75579b9..c65717e6bf47f1bdf0db2eb386d97fee295ab28c 100644 |
--- a/Source/core/css/CSSBasicShapes.cpp |
+++ b/Source/core/css/CSSBasicShapes.cpp |
@@ -296,43 +296,67 @@ 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); |
- |
- result.append(topLeftRadiusWidth); |
- result.appendLiteral(separator); |
- result.append(topRightRadiusWidth); |
- result.appendLiteral(separator); |
- result.append(bottomRightRadiusWidth); |
- result.appendLiteral(separator); |
- result.append(bottomLeftRadiusWidth); |
- |
- 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); |
+ bool showHorizontalBottomLeft = topRightRadiusWidth != bottomLeftRadiusWidth; |
+ bool showHorizontalBottomRight = showHorizontalBottomLeft || (bottomRightRadiusWidth != topLeftRadiusWidth); |
+ bool showHorizontalTopRight = showHorizontalBottomRight || (topRightRadiusWidth != topLeftRadiusWidth); |
+ |
+ Vector<String> horizontalRadii; |
Bear Travis
2014/04/08 19:08:35
Would it be possible / worth it to factor out the
|
+ horizontalRadii.append(topLeftRadiusWidth); |
+ if (showHorizontalTopRight) |
+ horizontalRadii.append(topRightRadiusWidth); |
+ if (showHorizontalBottomRight) |
+ horizontalRadii.append(bottomRightRadiusWidth); |
+ if (showHorizontalBottomLeft) |
+ horizontalRadii.append(bottomLeftRadiusWidth); |
+ |
+ bool showVerticalBottomLeft = topRightRadiusHeight != bottomLeftRadiusHeight; |
+ bool showVerticalBottomRight = showVerticalBottomLeft || (bottomRightRadiusHeight != topLeftRadiusHeight); |
+ bool showVerticalTopRight = showVerticalBottomRight || (topRightRadiusHeight != topLeftRadiusHeight); |
+ |
+ Vector<String> verticalRadii; |
+ verticalRadii.append(topLeftRadiusHeight); |
+ if (showVerticalTopRight) |
+ verticalRadii.append(topRightRadiusHeight); |
+ if (showVerticalBottomRight) |
+ verticalRadii.append(bottomRightRadiusHeight); |
+ if (showVerticalBottomLeft) |
+ verticalRadii.append(bottomLeftRadiusHeight); |
+ |
+ if (!(horizontalRadii.size() == 1 && horizontalRadii[0] == "0px" && verticalRadii[0] == "0px")) { |
Bear Travis
2014/04/08 19:08:35
I think this also needs to check for verticalRadii
|
+ 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(')'); |