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/CSSColorValue.h" | 8 #include "core/css/CSSColorValue.h" |
9 #include "core/css/CSSKeyframeRule.h" | 9 #include "core/css/CSSKeyframeRule.h" |
10 #include "core/css/StyleColor.h" | 10 #include "core/css/StyleColor.h" |
11 #include "core/css/StylePropertySet.h" | 11 #include "core/css/StylePropertySet.h" |
12 #include "core/css/StyleRule.h" | 12 #include "core/css/StyleRule.h" |
13 #include "core/css/StyleSheetContents.h" | 13 #include "core/css/StyleSheetContents.h" |
14 #include "core/css/parser/CSSParserFastPaths.h" | 14 #include "core/css/parser/CSSParserFastPaths.h" |
15 #include "core/css/parser/CSSParserImpl.h" | 15 #include "core/css/parser/CSSParserImpl.h" |
16 #include "core/css/parser/CSSPropertyParser.h" | 16 #include "core/css/parser/CSSPropertyParser.h" |
17 #include "core/css/parser/CSSSelectorParser.h" | 17 #include "core/css/parser/CSSSelectorParser.h" |
18 #include "core/css/parser/CSSSupportsParser.h" | 18 #include "core/css/parser/CSSSupportsParser.h" |
19 #include "core/css/parser/CSSTokenizer.h" | 19 #include "core/css/parser/CSSTokenizer.h" |
| 20 #include "core/css/parser/CSSVariableParser.h" |
20 #include "core/layout/LayoutTheme.h" | 21 #include "core/layout/LayoutTheme.h" |
21 | 22 |
22 namespace blink { | 23 namespace blink { |
23 | 24 |
24 bool CSSParser::parseDeclarationList(const CSSParserContext& context, MutableSty
lePropertySet* propertySet, const String& declaration) | 25 bool CSSParser::parseDeclarationList(const CSSParserContext& context, MutableSty
lePropertySet* propertySet, const String& declaration) |
25 { | 26 { |
26 return CSSParserImpl::parseDeclarationList(propertySet, declaration, context
); | 27 return CSSParserImpl::parseDeclarationList(propertySet, declaration, context
); |
27 } | 28 } |
28 | 29 |
29 void CSSParser::parseDeclarationListForInspector(const CSSParserContext& context
, const String& declaration, CSSParserObserver& observer) | 30 void CSSParser::parseDeclarationListForInspector(const CSSParserContext& context
, const String& declaration, CSSParserObserver& observer) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 if (value) | 63 if (value) |
63 return declaration->setProperty(CSSProperty(resolvedProperty, value.rele
ase(), important)); | 64 return declaration->setProperty(CSSProperty(resolvedProperty, value.rele
ase(), important)); |
64 CSSParserContext context(parserMode, 0); | 65 CSSParserContext context(parserMode, 0); |
65 if (styleSheet) { | 66 if (styleSheet) { |
66 context = styleSheet->parserContext(); | 67 context = styleSheet->parserContext(); |
67 context.setMode(parserMode); | 68 context.setMode(parserMode); |
68 } | 69 } |
69 return parseValue(declaration, unresolvedProperty, string, important, contex
t); | 70 return parseValue(declaration, unresolvedProperty, string, important, contex
t); |
70 } | 71 } |
71 | 72 |
| 73 bool CSSParser::parseValueForCustomProperty(MutableStylePropertySet* declaration
, const AtomicString& propertyName, const String& value, bool important, StyleSh
eetContents* styleSheet) |
| 74 { |
| 75 ASSERT(RuntimeEnabledFeatures::cssVariablesEnabled() && CSSVariableParser::i
sValidVariableName(propertyName)); |
| 76 if (value.isEmpty()) |
| 77 return false; |
| 78 CSSParserMode parserMode = declaration->cssParserMode(); |
| 79 CSSParserContext context(parserMode, 0); |
| 80 if (styleSheet) { |
| 81 context = styleSheet->parserContext(); |
| 82 context.setMode(parserMode); |
| 83 } |
| 84 return CSSParserImpl::parseVariableValue(declaration, propertyName, value, i
mportant, context); |
| 85 } |
| 86 |
72 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID u
nresolvedProperty, const String& string, bool important, const CSSParserContext&
context) | 87 bool CSSParser::parseValue(MutableStylePropertySet* declaration, CSSPropertyID u
nresolvedProperty, const String& string, bool important, const CSSParserContext&
context) |
73 { | 88 { |
74 return CSSParserImpl::parseValue(declaration, unresolvedProperty, string, im
portant, context); | 89 return CSSParserImpl::parseValue(declaration, unresolvedProperty, string, im
portant, context); |
75 } | 90 } |
76 | 91 |
77 PassRefPtrWillBeRawPtr<CSSValue> CSSParser::parseSingleValue(CSSPropertyID prope
rtyID, const String& string, const CSSParserContext& context) | 92 PassRefPtrWillBeRawPtr<CSSValue> CSSParser::parseSingleValue(CSSPropertyID prope
rtyID, const String& string, const CSSParserContext& context) |
78 { | 93 { |
79 if (string.isEmpty()) | 94 if (string.isEmpty()) |
80 return nullptr; | 95 return nullptr; |
81 if (RefPtrWillBeRawPtr<CSSValue> value = CSSParserFastPaths::maybeParseValue
(propertyID, string, context.mode())) | 96 if (RefPtrWillBeRawPtr<CSSValue> value = CSSParserFastPaths::maybeParseValue
(propertyID, string, context.mode())) |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 builder.appendLiteral(" : "); | 168 builder.appendLiteral(" : "); |
154 builder.append(propertyValue); | 169 builder.append(propertyValue); |
155 builder.appendLiteral("; }"); | 170 builder.appendLiteral("; }"); |
156 RefPtrWillBeRawPtr<StyleRuleBase> rule = parseRule(context, nullptr, builder
.toString()); | 171 RefPtrWillBeRawPtr<StyleRuleBase> rule = parseRule(context, nullptr, builder
.toString()); |
157 if (!rule || !rule->isFontFaceRule()) | 172 if (!rule || !rule->isFontFaceRule()) |
158 return nullptr; | 173 return nullptr; |
159 return toStyleRuleFontFace(rule.get())->properties().getPropertyCSSValue(pro
pertyID); | 174 return toStyleRuleFontFace(rule.get())->properties().getPropertyCSSValue(pro
pertyID); |
160 } | 175 } |
161 | 176 |
162 } // namespace blink | 177 } // namespace blink |
OLD | NEW |