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

Unified Diff: Source/core/css/parser/CSSParser.cpp

Issue 1196533002: Clean up fast path CSS color parsing (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | Source/core/css/parser/CSSParserFastPaths.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/parser/CSSParser.cpp
diff --git a/Source/core/css/parser/CSSParser.cpp b/Source/core/css/parser/CSSParser.cpp
index 4d82c9f8ccf1c9a72e7ccfce0ea5760045a87849..8cbf6e359af5477ea4100296a0f50103060c65ae 100644
--- a/Source/core/css/parser/CSSParser.cpp
+++ b/Source/core/css/parser/CSSParser.cpp
@@ -112,18 +112,19 @@ bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict)
if (string.isEmpty())
return false;
- // First try creating a color specified by name, rgba(), rgb() or "#" syntax.
- if (CSSParserFastPaths::parseColorAsRGBA32(color, string, !strict))
+ // The regular color parsers don't resolve all named colors, so explicitly
+ // handle these first.
+ Color namedColor;
+ if (namedColor.setNamedColor(string)) {
+ color = namedColor.rgb();
return true;
+ }
- // In case the fast-path parser didn't understand the color, try the full parser.
- RefPtrWillBeRawPtr<MutableStylePropertySet> stylePropertySet = MutableStylePropertySet::create();
- // FIXME: The old CSS parser is only working in strict mode ignoring the strict parameter.
- // It needs to be investigated why.
- if (!parseValue(stylePropertySet.get(), CSSPropertyColor, string, false, strictCSSParserContext()))
- return false;
+ RefPtrWillBeRawPtr<CSSValue> value = CSSParserFastPaths::parseColor(string, !strict);
+ // TODO(timloh): Why is this always strict mode?
+ if (!value)
+ value = parseSingleValue(CSSPropertyColor, string, strictCSSParserContext());
- RefPtrWillBeRawPtr<CSSValue> value = stylePropertySet->getPropertyCSSValue(CSSPropertyColor);
if (!value || !value->isPrimitiveValue())
return false;
« no previous file with comments | « no previous file | Source/core/css/parser/CSSParserFastPaths.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698