OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "core/css/resolver/CSSVariableResolver.h" | 5 #include "core/css/resolver/CSSVariableResolver.h" |
6 | 6 |
7 #include "core/CSSPropertyNames.h" | 7 #include "core/CSSPropertyNames.h" |
8 #include "core/CSSValueKeywords.h" | 8 #include "core/CSSValueKeywords.h" |
9 #include "core/StyleBuilderFunctions.h" | 9 #include "core/StyleBuilderFunctions.h" |
10 #include "core/StylePropertyShorthand.h" | 10 #include "core/StylePropertyShorthand.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 } else if (range.peek().type() == AtKeywordToken && equalIgnoringASCIICa
se(range.peek().value(), "apply") | 123 } else if (range.peek().type() == AtKeywordToken && equalIgnoringASCIICa
se(range.peek().value(), "apply") |
124 && RuntimeEnabledFeatures::cssApplyAtRulesEnabled()) { | 124 && RuntimeEnabledFeatures::cssApplyAtRulesEnabled()) { |
125 resolveApplyAtRule(range, result); | 125 resolveApplyAtRule(range, result); |
126 } else { | 126 } else { |
127 result.append(range.consume()); | 127 result.append(range.consume()); |
128 } | 128 } |
129 } | 129 } |
130 return success; | 130 return success; |
131 } | 131 } |
132 | 132 |
133 CSSValue* CSSVariableResolver::resolveVariableReferences(StyleVariableData* styl
eVariableData, CSSPropertyID id, const CSSVariableReferenceValue& value) | 133 const CSSValue* CSSVariableResolver::resolveVariableReferences(StyleVariableData
* styleVariableData, CSSPropertyID id, const CSSVariableReferenceValue& value) |
134 { | 134 { |
135 ASSERT(!isShorthandProperty(id)); | 135 ASSERT(!isShorthandProperty(id)); |
136 | 136 |
137 CSSVariableResolver resolver(styleVariableData); | 137 CSSVariableResolver resolver(styleVariableData); |
138 Vector<CSSParserToken> tokens; | 138 Vector<CSSParserToken> tokens; |
139 if (!resolver.resolveTokenRange(value.variableDataValue()->tokens(), tokens)
) | 139 if (!resolver.resolveTokenRange(value.variableDataValue()->tokens(), tokens)
) |
140 return CSSUnsetValue::create(); | 140 return CSSUnsetValue::create(); |
141 CSSValue* result = CSSPropertyParser::parseSingleValue(id, tokens, strictCSS
ParserContext()); | 141 const CSSValue* result = CSSPropertyParser::parseSingleValue(id, tokens, str
ictCSSParserContext()); |
142 if (!result) | 142 if (!result) |
143 return CSSUnsetValue::create(); | 143 return CSSUnsetValue::create(); |
144 return result; | 144 return result; |
145 } | 145 } |
146 | 146 |
147 const CSSValue* CSSVariableResolver::resolveVariableReferences(StyleResolverStat
e& state, CSSPropertyID id, const CSSVariableReferenceValue& value) | 147 const CSSValue* CSSVariableResolver::resolveVariableReferences(StyleResolverStat
e& state, CSSPropertyID id, const CSSVariableReferenceValue& value) |
148 { | 148 { |
149 // Non-shorthand variable references follow this path. | 149 // Non-shorthand variable references follow this path. |
150 CSSVariableResolver resolver(state.style()->variables()); | 150 CSSVariableResolver resolver(state.style()->variables()); |
151 | 151 |
152 Vector<CSSParserToken> tokens; | 152 Vector<CSSParserToken> tokens; |
153 if (resolver.resolveTokenRange(value.variableDataValue()->tokens(), tokens))
{ | 153 if (resolver.resolveTokenRange(value.variableDataValue()->tokens(), tokens))
{ |
154 CSSParserContext context(HTMLStandardMode, nullptr); | 154 CSSParserContext context(HTMLStandardMode, nullptr); |
155 | 155 |
156 CSSValue* value = CSSPropertyParser::parseSingleValue(id, CSSParserToken
Range(tokens), context); | 156 const CSSValue* value = CSSPropertyParser::parseSingleValue(id, CSSParse
rTokenRange(tokens), context); |
157 if (value) | 157 if (value) |
158 return value; | 158 return value; |
159 } | 159 } |
160 | 160 |
161 return CSSUnsetValue::create(); | 161 return CSSUnsetValue::create(); |
162 } | 162 } |
163 | 163 |
164 const CSSValue* CSSVariableResolver::resolvePendingSubstitutions(StyleResolverSt
ate& state, CSSPropertyID id, const CSSPendingSubstitutionValue& pendingValue) | 164 const CSSValue* CSSVariableResolver::resolvePendingSubstitutions(StyleResolverSt
ate& state, CSSPropertyID id, const CSSPendingSubstitutionValue& pendingValue) |
165 { | 165 { |
166 // Longhands from shorthand references follow this path. | 166 // Longhands from shorthand references follow this path. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 variable.value = resolver.resolveCustomProperty(variable.key, *varia
ble.value); | 208 variable.value = resolver.resolveCustomProperty(variable.key, *varia
ble.value); |
209 } | 209 } |
210 } | 210 } |
211 | 211 |
212 CSSVariableResolver::CSSVariableResolver(StyleVariableData* styleVariableData) | 212 CSSVariableResolver::CSSVariableResolver(StyleVariableData* styleVariableData) |
213 : m_styleVariableData(styleVariableData) | 213 : m_styleVariableData(styleVariableData) |
214 { | 214 { |
215 } | 215 } |
216 | 216 |
217 } // namespace blink | 217 } // namespace blink |
OLD | NEW |