| 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 235 |
| 236 const CSSValue* CSSVariableResolver::resolvePendingSubstitutions( | 236 const CSSValue* CSSVariableResolver::resolvePendingSubstitutions( |
| 237 const StyleResolverState& state, | 237 const StyleResolverState& state, |
| 238 CSSPropertyID id, | 238 CSSPropertyID id, |
| 239 const CSSPendingSubstitutionValue& pendingValue, | 239 const CSSPendingSubstitutionValue& pendingValue, |
| 240 bool disallowAnimationTainted) { | 240 bool disallowAnimationTainted) { |
| 241 // Longhands from shorthand references follow this path. | 241 // Longhands from shorthand references follow this path. |
| 242 HeapHashMap<CSSPropertyID, Member<const CSSValue>>& propertyCache = | 242 HeapHashMap<CSSPropertyID, Member<const CSSValue>>& propertyCache = |
| 243 state.parsedPropertiesForPendingSubstitutionCache(pendingValue); | 243 state.parsedPropertiesForPendingSubstitutionCache(pendingValue); |
| 244 | 244 |
| 245 const CSSValue* value = propertyCache.get(id); | 245 const CSSValue* value = propertyCache.at(id); |
| 246 if (!value) { | 246 if (!value) { |
| 247 // TODO(timloh): We shouldn't retry this for all longhands if the shorthand | 247 // TODO(timloh): We shouldn't retry this for all longhands if the shorthand |
| 248 // ends up invalid. | 248 // ends up invalid. |
| 249 CSSVariableReferenceValue* shorthandValue = pendingValue.shorthandValue(); | 249 CSSVariableReferenceValue* shorthandValue = pendingValue.shorthandValue(); |
| 250 CSSPropertyID shorthandPropertyId = pendingValue.shorthandPropertyId(); | 250 CSSPropertyID shorthandPropertyId = pendingValue.shorthandPropertyId(); |
| 251 | 251 |
| 252 CSSVariableResolver resolver(state); | 252 CSSVariableResolver resolver(state); |
| 253 | 253 |
| 254 Vector<CSSParserToken> tokens; | 254 Vector<CSSParserToken> tokens; |
| 255 bool isAnimationTainted = false; | 255 bool isAnimationTainted = false; |
| 256 if (resolver.resolveTokenRange( | 256 if (resolver.resolveTokenRange( |
| 257 shorthandValue->variableDataValue()->tokens(), | 257 shorthandValue->variableDataValue()->tokens(), |
| 258 disallowAnimationTainted, tokens, isAnimationTainted)) { | 258 disallowAnimationTainted, tokens, isAnimationTainted)) { |
| 259 CSSParserContext* context = CSSParserContext::create(HTMLStandardMode); | 259 CSSParserContext* context = CSSParserContext::create(HTMLStandardMode); |
| 260 | 260 |
| 261 HeapVector<CSSProperty, 256> parsedProperties; | 261 HeapVector<CSSProperty, 256> parsedProperties; |
| 262 | 262 |
| 263 if (CSSPropertyParser::parseValue( | 263 if (CSSPropertyParser::parseValue( |
| 264 shorthandPropertyId, false, CSSParserTokenRange(tokens), context, | 264 shorthandPropertyId, false, CSSParserTokenRange(tokens), context, |
| 265 parsedProperties, StyleRule::RuleType::Style)) { | 265 parsedProperties, StyleRule::RuleType::Style)) { |
| 266 unsigned parsedPropertiesCount = parsedProperties.size(); | 266 unsigned parsedPropertiesCount = parsedProperties.size(); |
| 267 for (unsigned i = 0; i < parsedPropertiesCount; ++i) { | 267 for (unsigned i = 0; i < parsedPropertiesCount; ++i) { |
| 268 propertyCache.set(parsedProperties[i].id(), | 268 propertyCache.set(parsedProperties[i].id(), |
| 269 parsedProperties[i].value()); | 269 parsedProperties[i].value()); |
| 270 } | 270 } |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 value = propertyCache.get(id); | 273 value = propertyCache.at(id); |
| 274 } | 274 } |
| 275 | 275 |
| 276 if (value) | 276 if (value) |
| 277 return value; | 277 return value; |
| 278 | 278 |
| 279 return CSSUnsetValue::create(); | 279 return CSSUnsetValue::create(); |
| 280 } | 280 } |
| 281 | 281 |
| 282 void CSSVariableResolver::resolveVariableDefinitions( | 282 void CSSVariableResolver::resolveVariableDefinitions( |
| 283 const StyleResolverState& state) { | 283 const StyleResolverState& state) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 } | 327 } |
| 328 } | 328 } |
| 329 } | 329 } |
| 330 | 330 |
| 331 CSSVariableResolver::CSSVariableResolver(const StyleResolverState& state) | 331 CSSVariableResolver::CSSVariableResolver(const StyleResolverState& state) |
| 332 : m_inheritedVariables(state.style()->inheritedVariables()), | 332 : m_inheritedVariables(state.style()->inheritedVariables()), |
| 333 m_nonInheritedVariables(state.style()->nonInheritedVariables()), | 333 m_nonInheritedVariables(state.style()->nonInheritedVariables()), |
| 334 m_registry(state.document().propertyRegistry()) {} | 334 m_registry(state.document().propertyRegistry()) {} |
| 335 | 335 |
| 336 } // namespace blink | 336 } // namespace blink |
| OLD | NEW |