OLD | NEW |
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/StyleRule.h" | 10 #include "core/css/StyleRule.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 { | 27 { |
28 // FIXME: Add inspector observer support in the new CSS parser | 28 // FIXME: Add inspector observer support in the new CSS parser |
29 if (!observer && RuntimeEnabledFeatures::newCSSParserEnabled()) | 29 if (!observer && RuntimeEnabledFeatures::newCSSParserEnabled()) |
30 return CSSParserImpl::parseDeclaration(propertySet, declaration, m_bison
Parser.m_context); | 30 return CSSParserImpl::parseDeclaration(propertySet, declaration, m_bison
Parser.m_context); |
31 return m_bisonParser.parseDeclaration(propertySet, declaration, observer, st
yleSheet); | 31 return m_bisonParser.parseDeclaration(propertySet, declaration, observer, st
yleSheet); |
32 } | 32 } |
33 | 33 |
34 void CSSParser::parseSelector(const String& selector, CSSSelectorList& selectorL
ist) | 34 void CSSParser::parseSelector(const String& selector, CSSSelectorList& selectorL
ist) |
35 { | 35 { |
36 if (RuntimeEnabledFeatures::newCSSParserEnabled()) { | 36 if (RuntimeEnabledFeatures::newCSSParserEnabled()) { |
37 Vector<CSSParserToken> tokens; | 37 CSSTokenizer::Scope scope(selector); |
38 CSSTokenizer::tokenize(selector, tokens); | 38 CSSSelectorParser::parseSelector(scope.tokenRange(), m_bisonParser.m_con
text, starAtom, nullptr, selectorList); |
39 CSSSelectorParser::parseSelector(tokens, m_bisonParser.m_context, starAt
om, nullptr, selectorList); | |
40 return; | 39 return; |
41 } | 40 } |
42 m_bisonParser.parseSelector(selector, selectorList); | 41 m_bisonParser.parseSelector(selector, selectorList); |
43 } | 42 } |
44 | 43 |
45 PassRefPtrWillBeRawPtr<StyleRuleBase> CSSParser::parseRule(const CSSParserContex
t& context, StyleSheetContents* styleSheet, const String& rule) | 44 PassRefPtrWillBeRawPtr<StyleRuleBase> CSSParser::parseRule(const CSSParserContex
t& context, StyleSheetContents* styleSheet, const String& rule) |
46 { | 45 { |
47 if (RuntimeEnabledFeatures::newCSSParserEnabled()) | 46 if (RuntimeEnabledFeatures::newCSSParserEnabled()) |
48 return CSSParserImpl::parseRule(rule, context, CSSParserImpl::AllowImpor
tRules); | 47 return CSSParserImpl::parseRule(rule, context, CSSParserImpl::AllowImpor
tRules); |
49 return BisonCSSParser(context).parseRule(styleSheet, rule); | 48 return BisonCSSParser(context).parseRule(styleSheet, rule); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 if (RuntimeEnabledFeatures::newCSSParserEnabled()) { | 116 if (RuntimeEnabledFeatures::newCSSParserEnabled()) { |
118 RefPtrWillBeRawPtr<StyleRuleBase> keyframe = CSSParserImpl::parseRule(ru
le, context, CSSParserImpl::KeyframeRules); | 117 RefPtrWillBeRawPtr<StyleRuleBase> keyframe = CSSParserImpl::parseRule(ru
le, context, CSSParserImpl::KeyframeRules); |
119 return toStyleRuleKeyframe(keyframe.get()); | 118 return toStyleRuleKeyframe(keyframe.get()); |
120 } | 119 } |
121 return BisonCSSParser(context).parseKeyframeRule(styleSheet, rule); | 120 return BisonCSSParser(context).parseKeyframeRule(styleSheet, rule); |
122 } | 121 } |
123 | 122 |
124 bool CSSParser::parseSupportsCondition(const String& condition) | 123 bool CSSParser::parseSupportsCondition(const String& condition) |
125 { | 124 { |
126 if (RuntimeEnabledFeatures::newCSSParserEnabled()) { | 125 if (RuntimeEnabledFeatures::newCSSParserEnabled()) { |
127 Vector<CSSParserToken> tokens; | 126 CSSTokenizer::Scope scope(condition); |
128 CSSTokenizer::tokenize(condition, tokens); | 127 CSSParserImpl parser(strictCSSParserContext()); |
129 CSSParserImpl parser(strictCSSParserContext(), ""); | 128 return CSSSupportsParser::supportsCondition(scope.tokenRange(), parser)
== CSSSupportsParser::Supported; |
130 return CSSSupportsParser::supportsCondition(tokens, parser) == CSSSuppor
tsParser::Supported; | |
131 } | 129 } |
132 return BisonCSSParser(CSSParserContext(HTMLStandardMode, 0)).parseSupportsCo
ndition(condition); | 130 return BisonCSSParser(CSSParserContext(HTMLStandardMode, 0)).parseSupportsCo
ndition(condition); |
133 } | 131 } |
134 | 132 |
135 bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict) | 133 bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict) |
136 { | 134 { |
137 if (string.isEmpty()) | 135 if (string.isEmpty()) |
138 return false; | 136 return false; |
139 | 137 |
140 // First try creating a color specified by name, rgba(), rgb() or "#" syntax
. | 138 // First try creating a color specified by name, rgba(), rgb() or "#" syntax
. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 CSSValueID id = cssValueKeywordID(cssColor); | 175 CSSValueID id = cssValueKeywordID(cssColor); |
178 if (!CSSPropertyParser::isSystemColor(id)) | 176 if (!CSSPropertyParser::isSystemColor(id)) |
179 return false; | 177 return false; |
180 | 178 |
181 Color parsedColor = LayoutTheme::theme().systemColor(id); | 179 Color parsedColor = LayoutTheme::theme().systemColor(id); |
182 color = parsedColor.rgb(); | 180 color = parsedColor.rgb(); |
183 return true; | 181 return true; |
184 } | 182 } |
185 | 183 |
186 } // namespace blink | 184 } // namespace blink |
OLD | NEW |