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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } else if (range.peek().type() == AtKeywordToken && equalIgnoringASCIICa
se(range.peek().value(), "apply") | 146 } else if (range.peek().type() == AtKeywordToken && equalIgnoringASCIICa
se(range.peek().value(), "apply") |
147 && RuntimeEnabledFeatures::cssApplyAtRulesEnabled()) { | 147 && RuntimeEnabledFeatures::cssApplyAtRulesEnabled()) { |
148 resolveApplyAtRule(range, result); | 148 resolveApplyAtRule(range, result); |
149 } else { | 149 } else { |
150 result.append(range.consume()); | 150 result.append(range.consume()); |
151 } | 151 } |
152 } | 152 } |
153 return success; | 153 return success; |
154 } | 154 } |
155 | 155 |
| 156 const CSSValue* CSSVariableResolver::resolveVariableReferences(const StyleResolv
erState& state, CSSPropertyID id, const CSSValue& value) |
| 157 { |
| 158 ASSERT(!isShorthandProperty(id)); |
| 159 |
| 160 if (value.isPendingSubstitutionValue()) |
| 161 return resolvePendingSubstitutions(state, id, toCSSPendingSubstitutionVa
lue(value)); |
| 162 |
| 163 if (value.isVariableReferenceValue()) |
| 164 return resolveVariableReferences(state, id, toCSSVariableReferenceValue(
value)); |
| 165 |
| 166 NOTREACHED(); |
| 167 return nullptr; |
| 168 } |
| 169 |
156 const CSSValue* CSSVariableResolver::resolveVariableReferences(const StyleResolv
erState& state, CSSPropertyID id, const CSSVariableReferenceValue& value) | 170 const CSSValue* CSSVariableResolver::resolveVariableReferences(const StyleResolv
erState& state, CSSPropertyID id, const CSSVariableReferenceValue& value) |
157 { | 171 { |
158 ASSERT(!isShorthandProperty(id)); | |
159 | |
160 CSSVariableResolver resolver(state); | 172 CSSVariableResolver resolver(state); |
161 Vector<CSSParserToken> tokens; | 173 Vector<CSSParserToken> tokens; |
162 if (!resolver.resolveTokenRange(value.variableDataValue()->tokens(), tokens)
) | 174 if (!resolver.resolveTokenRange(value.variableDataValue()->tokens(), tokens)
) |
163 return CSSUnsetValue::create(); | 175 return CSSUnsetValue::create(); |
164 const CSSValue* result = CSSPropertyParser::parseSingleValue(id, tokens, str
ictCSSParserContext()); | 176 const CSSValue* result = CSSPropertyParser::parseSingleValue(id, tokens, str
ictCSSParserContext()); |
165 if (!result) | 177 if (!result) |
166 return CSSUnsetValue::create(); | 178 return CSSUnsetValue::create(); |
167 return result; | 179 return result; |
168 } | 180 } |
169 | 181 |
170 const CSSValue* CSSVariableResolver::resolvePendingSubstitutions(StyleResolverSt
ate& state, CSSPropertyID id, const CSSPendingSubstitutionValue& pendingValue) | 182 const CSSValue* CSSVariableResolver::resolvePendingSubstitutions(const StyleReso
lverState& state, CSSPropertyID id, const CSSPendingSubstitutionValue& pendingVa
lue) |
171 { | 183 { |
172 // Longhands from shorthand references follow this path. | 184 // Longhands from shorthand references follow this path. |
173 HeapHashMap<CSSPropertyID, Member<const CSSValue>>& propertyCache = state.pa
rsedPropertiesForPendingSubstitution(pendingValue); | 185 HeapHashMap<CSSPropertyID, Member<const CSSValue>>& propertyCache = state.pa
rsedPropertiesForPendingSubstitutionCache(pendingValue); |
174 | 186 |
175 const CSSValue* value = propertyCache.get(id); | 187 const CSSValue* value = propertyCache.get(id); |
176 if (!value) { | 188 if (!value) { |
177 // TODO(timloh): We shouldn't retry this for all longhands if the shorth
and ends up invalid | 189 // TODO(timloh): We shouldn't retry this for all longhands if the shorth
and ends up invalid |
178 CSSVariableReferenceValue* shorthandValue = pendingValue.shorthandValue(
); | 190 CSSVariableReferenceValue* shorthandValue = pendingValue.shorthandValue(
); |
179 CSSPropertyID shorthandPropertyId = pendingValue.shorthandPropertyId(); | 191 CSSPropertyID shorthandPropertyId = pendingValue.shorthandPropertyId(); |
180 | 192 |
181 CSSVariableResolver resolver(state); | 193 CSSVariableResolver resolver(state); |
182 | 194 |
183 Vector<CSSParserToken> tokens; | 195 Vector<CSSParserToken> tokens; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 CSSVariableResolver::CSSVariableResolver(const StyleResolverState& state) | 229 CSSVariableResolver::CSSVariableResolver(const StyleResolverState& state) |
218 : m_styleResolverState(state) | 230 : m_styleResolverState(state) |
219 , m_styleVariableData(state.style()->variables()) | 231 , m_styleVariableData(state.style()->variables()) |
220 , m_registry(state.document().propertyRegistry()) | 232 , m_registry(state.document().propertyRegistry()) |
221 { | 233 { |
222 } | 234 } |
223 | 235 |
224 DEFINE_TRACE(CSSVariableResolver) { visitor->trace(m_registry); } | 236 DEFINE_TRACE(CSSVariableResolver) { visitor->trace(m_registry); } |
225 | 237 |
226 } // namespace blink | 238 } // namespace blink |
OLD | NEW |