| Index: third_party/WebKit/Source/platform/graphics/Color.cpp
|
| diff --git a/third_party/WebKit/Source/platform/graphics/Color.cpp b/third_party/WebKit/Source/platform/graphics/Color.cpp
|
| index 3ad2e4d84d59cb85ee67ae9928e4615f93b9b2ee..3b406bf1a1addf7976e8fa71e0d6b7eb4ab519bc 100644
|
| --- a/third_party/WebKit/Source/platform/graphics/Color.cpp
|
| +++ b/third_party/WebKit/Source/platform/graphics/Color.cpp
|
| @@ -210,7 +210,16 @@ String Color::serializedAsCSSComponentValue() const {
|
| result.appendNumber(static_cast<unsigned char>(blue()));
|
| if (colorHasAlpha) {
|
| result.append(", ");
|
| - result.appendNumber(alpha() / 255.0f, 6);
|
| + // See <alphavalue> section in
|
| + // http://dev.w3.org/csswg/cssom/#serializing-css-values
|
| + int alphavalue = alpha();
|
| + float rounded = round(alphavalue * 100 / 255.0f) / 100;
|
| + if (round(rounded * 255) == alphavalue) {
|
| + result.appendNumber(rounded, 2);
|
| + } else {
|
| + rounded = round(alphavalue * 1000 / 255.0f) / 1000;
|
| + result.appendNumber(rounded, 3);
|
| + }
|
| }
|
|
|
| result.append(')');
|
|
|