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

Side by Side Diff: Source/core/css/parser/CSSParser.cpp

Issue 1169983004: Move fast-path color parsing from CSSPropertyParser to CSSParserFastPaths (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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/css/parser/CSSParser.h" 6 #include "core/css/parser/CSSParser.h"
7 7
8 #include "core/css/CSSKeyframeRule.h" 8 #include "core/css/CSSKeyframeRule.h"
9 #include "core/css/StyleColor.h" 9 #include "core/css/StyleColor.h"
10 #include "core/css/StylePropertySet.h" 10 #include "core/css/StylePropertySet.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 CSSParserImpl parser(strictCSSParserContext()); 102 CSSParserImpl parser(strictCSSParserContext());
103 return CSSSupportsParser::supportsCondition(scope.tokenRange(), parser) == C SSSupportsParser::Supported; 103 return CSSSupportsParser::supportsCondition(scope.tokenRange(), parser) == C SSSupportsParser::Supported;
104 } 104 }
105 105
106 bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict) 106 bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict)
107 { 107 {
108 if (string.isEmpty()) 108 if (string.isEmpty())
109 return false; 109 return false;
110 110
111 // First try creating a color specified by name, rgba(), rgb() or "#" syntax . 111 // First try creating a color specified by name, rgba(), rgb() or "#" syntax .
112 if (CSSPropertyParser::fastParseColor(color, string, strict)) 112 if (CSSParserFastPaths::parseColorAsRGBA32(color, string, !strict))
113 return true; 113 return true;
114 114
115 // In case the fast-path parser didn't understand the color, try the full pa rser. 115 // In case the fast-path parser didn't understand the color, try the full pa rser.
116 RefPtrWillBeRawPtr<MutableStylePropertySet> stylePropertySet = MutableStyleP ropertySet::create(); 116 RefPtrWillBeRawPtr<MutableStylePropertySet> stylePropertySet = MutableStyleP ropertySet::create();
117 // FIXME: The old CSS parser is only working in strict mode ignoring the str ict parameter. 117 // FIXME: The old CSS parser is only working in strict mode ignoring the str ict parameter.
118 // It needs to be investigated why. 118 // It needs to be investigated why.
119 if (!parseValue(stylePropertySet.get(), CSSPropertyColor, string, false, str ictCSSParserContext())) 119 if (!parseValue(stylePropertySet.get(), CSSPropertyColor, string, false, str ictCSSParserContext()))
120 return false; 120 return false;
121 121
122 RefPtrWillBeRawPtr<CSSValue> value = stylePropertySet->getPropertyCSSValue(C SSPropertyColor); 122 RefPtrWillBeRawPtr<CSSValue> value = stylePropertySet->getPropertyCSSValue(C SSPropertyColor);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 builder.appendLiteral(" : "); 162 builder.appendLiteral(" : ");
163 builder.append(propertyValue); 163 builder.append(propertyValue);
164 builder.appendLiteral("; }"); 164 builder.appendLiteral("; }");
165 RefPtrWillBeRawPtr<StyleRuleBase> rule = parseRule(context, builder.toString ()); 165 RefPtrWillBeRawPtr<StyleRuleBase> rule = parseRule(context, builder.toString ());
166 if (!rule || !rule->isFontFaceRule()) 166 if (!rule || !rule->isFontFaceRule())
167 return nullptr; 167 return nullptr;
168 return toStyleRuleFontFace(rule.get())->properties().getPropertyCSSValue(pro pertyID); 168 return toStyleRuleFontFace(rule.get())->properties().getPropertyCSSValue(pro pertyID);
169 } 169 }
170 170
171 } // namespace blink 171 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698