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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 void CSSParser::parseSheet(const CSSParserContext& context, StyleSheetContents*
styleSheet, const String& text, const TextPosition& startPosition, CSSParserObse
rver* observer, bool logErrors) | 50 void CSSParser::parseSheet(const CSSParserContext& context, StyleSheetContents*
styleSheet, const String& text, const TextPosition& startPosition, CSSParserObse
rver* observer, bool logErrors) |
51 { | 51 { |
52 if (RuntimeEnabledFeatures::newCSSParserEnabled()) { | 52 if (RuntimeEnabledFeatures::newCSSParserEnabled()) { |
53 if (observer) | 53 if (observer) |
54 return CSSParserImpl::parseStyleSheetForInspector(text, context, *ob
server); | 54 return CSSParserImpl::parseStyleSheetForInspector(text, context, *ob
server); |
55 return CSSParserImpl::parseStyleSheet(text, context, styleSheet); | 55 return CSSParserImpl::parseStyleSheet(text, context, styleSheet); |
56 } | 56 } |
57 BisonCSSParser(context).parseSheet(styleSheet, text, startPosition, observer
, logErrors); | 57 BisonCSSParser(context).parseSheet(styleSheet, text, startPosition, observer
, logErrors); |
58 } | 58 } |
59 | 59 |
60 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID p
ropertyID, const String& string, bool important, CSSParserMode parserMode, Style
SheetContents* styleSheet) | 60 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID u
nresolvedProperty, const String& string, bool important, CSSParserMode parserMod
e, StyleSheetContents* styleSheet) |
61 { | 61 { |
62 if (string.isEmpty()) | 62 if (string.isEmpty()) |
63 return false; | 63 return false; |
64 if (parseFastPath(declaration, propertyID, string, important, parserMode)) | 64 if (parseFastPath(declaration, unresolvedProperty, string, important, parser
Mode)) |
65 return true; | 65 return true; |
66 CSSParserContext context(parserMode, 0); | 66 CSSParserContext context(parserMode, 0); |
67 if (styleSheet) { | 67 if (styleSheet) { |
68 context = styleSheet->parserContext(); | 68 context = styleSheet->parserContext(); |
69 context.setMode(parserMode); | 69 context.setMode(parserMode); |
70 } | 70 } |
71 return parseValue(declaration, propertyID, string, important, context); | 71 return parseValue(declaration, unresolvedProperty, string, important, contex
t); |
72 } | 72 } |
73 | 73 |
74 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID p
ropertyID, const String& string, bool important, const CSSParserContext& context
) | 74 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID u
nresolvedProperty, const String& string, bool important, const CSSParserContext&
context) |
75 { | 75 { |
76 if (RuntimeEnabledFeatures::newCSSParserEnabled()) | 76 if (RuntimeEnabledFeatures::newCSSParserEnabled()) |
77 return CSSParserImpl::parseValue(declaration, propertyID, string, import
ant, context); | 77 return CSSParserImpl::parseValue(declaration, unresolvedProperty, string
, important, context); |
78 return BisonCSSParser::parseValue(declaration, propertyID, string, important
, context); | 78 return BisonCSSParser::parseValue(declaration, unresolvedProperty, string, i
mportant, context); |
79 } | 79 } |
80 | 80 |
81 bool CSSParser::parseFastPath(MutableStylePropertySet* declaration, CSSPropertyI
D propertyID, const String& string, bool important, CSSParserMode parserMode) | 81 bool CSSParser::parseFastPath(MutableStylePropertySet* declaration, CSSPropertyI
D unresolvedProperty, const String& string, bool important, CSSParserMode parser
Mode) |
82 { | 82 { |
83 RefPtrWillBeRawPtr<CSSValue> value = CSSParserFastPaths::maybeParseValue(pro
pertyID, string, parserMode); | 83 CSSPropertyID resolvedProperty = resolveCSSPropertyID(unresolvedProperty); |
| 84 RefPtrWillBeRawPtr<CSSValue> value = CSSParserFastPaths::maybeParseValue(res
olvedProperty, string, parserMode); |
84 if (!value) | 85 if (!value) |
85 return false; | 86 return false; |
86 declaration->addParsedProperty(CSSProperty(propertyID, value.release(), impo
rtant)); | 87 declaration->addParsedProperty(CSSProperty(resolvedProperty, value.release()
, important)); |
87 return true; | 88 return true; |
88 } | 89 } |
89 | 90 |
90 PassRefPtrWillBeRawPtr<CSSValue> CSSParser::parseSingleValue(CSSPropertyID prope
rtyID, const String& string, const CSSParserContext& context) | 91 PassRefPtrWillBeRawPtr<CSSValue> CSSParser::parseSingleValue(CSSPropertyID prope
rtyID, const String& string, const CSSParserContext& context) |
91 { | 92 { |
92 if (string.isEmpty()) | 93 if (string.isEmpty()) |
93 return nullptr; | 94 return nullptr; |
94 RefPtrWillBeRawPtr<MutableStylePropertySet> stylePropertySet = MutableStyleP
ropertySet::create(); | 95 RefPtrWillBeRawPtr<MutableStylePropertySet> stylePropertySet = MutableStyleP
ropertySet::create(); |
95 bool success = parseFastPath(stylePropertySet.get(), propertyID, string, fal
se, context.mode()) | 96 bool success = parseFastPath(stylePropertySet.get(), propertyID, string, fal
se, context.mode()) |
96 || parseValue(stylePropertySet.get(), propertyID, string, false, context
); | 97 || parseValue(stylePropertySet.get(), propertyID, string, false, context
); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 CSSValueID id = cssValueKeywordID(cssColor); | 177 CSSValueID id = cssValueKeywordID(cssColor); |
177 if (!CSSPropertyParser::isSystemColor(id)) | 178 if (!CSSPropertyParser::isSystemColor(id)) |
178 return false; | 179 return false; |
179 | 180 |
180 Color parsedColor = LayoutTheme::theme().systemColor(id); | 181 Color parsedColor = LayoutTheme::theme().systemColor(id); |
181 color = parsedColor.rgb(); | 182 color = parsedColor.rgb(); |
182 return true; | 183 return true; |
183 } | 184 } |
184 | 185 |
185 } // namespace blink | 186 } // namespace blink |
OLD | NEW |