Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Unified Diff: third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp

Issue 2606143002: Fix RGBA alpha parsing and serialization to adhere to W3 standard. (Closed)
Patch Set: fixes to address reviewer comments Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp
diff --git a/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp b/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp
index 5e9b730d9e27584da2dcf0e9f6d4547c31b0075a..649aa74f1812bed8b28f062594cba787ef7440ca 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp
@@ -407,10 +407,9 @@ static bool parseRGBParameters(CSSParserTokenRange& range,
double alpha;
if (!consumeNumberRaw(args, alpha))
return false;
- // Convert the floating pointer number of alpha to an integer in the range
- // [0, 256), with an equal distribution across all 256 values.
- int alphaComponent = static_cast<int>(clampTo<double>(alpha, 0.0, 1.0) *
- nextafter(256.0, 0.0));
+ // W3 standard stipulates a 2.55 alpha value multiplication factor.
+ int alphaComponent =
+ static_cast<int>(lroundf(clampTo<double>(alpha, 0.0, 1.0) * 255.0f));
result =
makeRGBA(colorArray[0], colorArray[1], colorArray[2], alphaComponent);
} else {

Powered by Google App Engine
This is Rietveld 408576698