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

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

Issue 2100573002: Avoid copying strings when parsing CSS colors on the slow path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missing else. Created 4 years, 6 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 b4e834106660a9cb4b98eda4312a4ca50f1b1f57..f397430fb44e03be0d391ecb3d1dfda87761d647 100644
--- a/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp
+++ b/third_party/WebKit/Source/core/css/parser/CSSPropertyParserHelpers.cpp
@@ -402,10 +402,11 @@ static bool parseHSLParameters(CSSParserTokenRange& range, RGBA32& result, bool
static bool parseHexColor(CSSParserTokenRange& range, RGBA32& result, bool acceptQuirkyColors)
{
const CSSParserToken& token = range.peek();
- String color;
if (token.type() == HashToken) {
- color = token.value().toString();
+ if (!Color::parseHexColor(token.value(), result))
+ return false;
} else if (acceptQuirkyColors) {
+ String color;
if (token.type() == NumberToken || token.type() == DimensionToken) {
if (token.numericValueType() != IntegerValueType
|| token.numericValue() < 0. || token.numericValue() >= 1000000.)
@@ -422,9 +423,11 @@ static bool parseHexColor(CSSParserTokenRange& range, RGBA32& result, bool accep
unsigned length = color.length();
if (length != 3 && length != 6)
return false;
- }
- if (!Color::parseHexColor(color, result))
+ if (!Color::parseHexColor(color, result))
+ return false;
+ } else {
return false;
+ }
range.consumeIncludingWhitespace();
return true;
}

Powered by Google App Engine
This is Rietveld 408576698