| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 PassRefPtr<CSSVariableData> CSSVariableResolver::resolveCustomProperty( | 88 PassRefPtr<CSSVariableData> CSSVariableResolver::resolveCustomProperty( |
| 89 AtomicString name, | 89 AtomicString name, |
| 90 const CSSVariableData& variableData) { | 90 const CSSVariableData& variableData) { |
| 91 ASSERT(variableData.needsVariableResolution()); | 91 ASSERT(variableData.needsVariableResolution()); |
| 92 | 92 |
| 93 Vector<CSSParserToken> tokens; | 93 Vector<CSSParserToken> tokens; |
| 94 m_variablesSeen.add(name); | 94 m_variablesSeen.add(name); |
| 95 bool success = resolveTokenRange(variableData.tokens(), tokens); | 95 bool success = resolveTokenRange(variableData.tokens(), tokens); |
| 96 m_variablesSeen.remove(name); | 96 m_variablesSeen.remove(name); |
| 97 | 97 |
| 98 // The old variable data holds onto the backing string the new resolved CSSVar
iableData | 98 // The old variable data holds onto the backing string the new resolved |
| 99 // relies on. Ensure it will live beyond us overwriting the RefPtr in StyleInh
eritedVariables. | 99 // CSSVariableData relies on. Ensure it will live beyond us overwriting the |
| 100 // RefPtr in StyleInheritedVariables. |
| 100 ASSERT(variableData.refCount() > 1); | 101 ASSERT(variableData.refCount() > 1); |
| 101 | 102 |
| 102 if (!success || !m_cycleStartPoints.isEmpty()) { | 103 if (!success || !m_cycleStartPoints.isEmpty()) { |
| 103 m_cycleStartPoints.remove(name); | 104 m_cycleStartPoints.remove(name); |
| 104 return nullptr; | 105 return nullptr; |
| 105 } | 106 } |
| 106 return CSSVariableData::createResolved(tokens, variableData); | 107 return CSSVariableData::createResolved(tokens, variableData); |
| 107 } | 108 } |
| 108 | 109 |
| 109 bool CSSVariableResolver::resolveVariableReference( | 110 bool CSSVariableResolver::resolveVariableReference( |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 const CSSValue* CSSVariableResolver::resolvePendingSubstitutions( | 206 const CSSValue* CSSVariableResolver::resolvePendingSubstitutions( |
| 206 const StyleResolverState& state, | 207 const StyleResolverState& state, |
| 207 CSSPropertyID id, | 208 CSSPropertyID id, |
| 208 const CSSPendingSubstitutionValue& pendingValue) { | 209 const CSSPendingSubstitutionValue& pendingValue) { |
| 209 // Longhands from shorthand references follow this path. | 210 // Longhands from shorthand references follow this path. |
| 210 HeapHashMap<CSSPropertyID, Member<const CSSValue>>& propertyCache = | 211 HeapHashMap<CSSPropertyID, Member<const CSSValue>>& propertyCache = |
| 211 state.parsedPropertiesForPendingSubstitutionCache(pendingValue); | 212 state.parsedPropertiesForPendingSubstitutionCache(pendingValue); |
| 212 | 213 |
| 213 const CSSValue* value = propertyCache.get(id); | 214 const CSSValue* value = propertyCache.get(id); |
| 214 if (!value) { | 215 if (!value) { |
| 215 // TODO(timloh): We shouldn't retry this for all longhands if the shorthand
ends up invalid | 216 // TODO(timloh): We shouldn't retry this for all longhands if the shorthand |
| 217 // ends up invalid. |
| 216 CSSVariableReferenceValue* shorthandValue = pendingValue.shorthandValue(); | 218 CSSVariableReferenceValue* shorthandValue = pendingValue.shorthandValue(); |
| 217 CSSPropertyID shorthandPropertyId = pendingValue.shorthandPropertyId(); | 219 CSSPropertyID shorthandPropertyId = pendingValue.shorthandPropertyId(); |
| 218 | 220 |
| 219 CSSVariableResolver resolver(state); | 221 CSSVariableResolver resolver(state); |
| 220 | 222 |
| 221 Vector<CSSParserToken> tokens; | 223 Vector<CSSParserToken> tokens; |
| 222 if (resolver.resolveTokenRange( | 224 if (resolver.resolveTokenRange( |
| 223 shorthandValue->variableDataValue()->tokens(), tokens)) { | 225 shorthandValue->variableDataValue()->tokens(), tokens)) { |
| 224 CSSParserContext context(HTMLStandardMode, 0); | 226 CSSParserContext context(HTMLStandardMode, 0); |
| 225 | 227 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 : m_styleResolverState(state), | 270 : m_styleResolverState(state), |
| 269 m_inheritedVariables(state.style()->inheritedVariables()), | 271 m_inheritedVariables(state.style()->inheritedVariables()), |
| 270 m_nonInheritedVariables(state.style()->nonInheritedVariables()), | 272 m_nonInheritedVariables(state.style()->nonInheritedVariables()), |
| 271 m_registry(state.document().propertyRegistry()) {} | 273 m_registry(state.document().propertyRegistry()) {} |
| 272 | 274 |
| 273 DEFINE_TRACE(CSSVariableResolver) { | 275 DEFINE_TRACE(CSSVariableResolver) { |
| 274 visitor->trace(m_registry); | 276 visitor->trace(m_registry); |
| 275 } | 277 } |
| 276 | 278 |
| 277 } // namespace blink | 279 } // namespace blink |
| OLD | NEW |