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

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

Issue 2588293004: Clamp rgba(...) alpha value in the CSS fast-path parser (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/parser/CSSParserFastPathsTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp
diff --git a/third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp b/third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp
index b6055081c78276e0c4f9a86d6dbfaf386fe38ca8..19b0fb25922f37537ab040c552e34104e09ee99a 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSParserFastPaths.cpp
@@ -375,7 +375,9 @@ static inline bool parseAlphaValue(const CharacterType*& string,
double alpha = 0;
if (!parseDouble(string, end, terminator, alpha))
return false;
- value = negative ? 0 : static_cast<int>(alpha * nextafter(256.0, 0.0));
+ value = negative
+ ? 0
+ : static_cast<int>(std::min(alpha, 1.0) * nextafter(256.0, 0.0));
alancutter (OOO until 2018) 2016/12/20 23:31:24 Instead of static_cast can we use clampTo<int>?
fs 2016/12/21 08:53:00 We can, but it would be a waste of perfectly good
string = end;
return true;
}
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/parser/CSSParserFastPathsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698