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 "config.h" | 5 #include "config.h" |
6 #include "core/css/resolver/CSSVariableResolver.h" | 6 #include "core/css/resolver/CSSVariableResolver.h" |
7 | 7 |
8 #include "core/CSSPropertyNames.h" | 8 #include "core/CSSPropertyNames.h" |
9 #include "core/CSSValueKeywords.h" | 9 #include "core/CSSValueKeywords.h" |
10 #include "core/StyleBuilderFunctions.h" | 10 #include "core/StyleBuilderFunctions.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 Vector<CSSParserToken> tokens; | 54 Vector<CSSParserToken> tokens; |
55 if (variableData->needsVariableResolution()) { | 55 if (variableData->needsVariableResolution()) { |
56 m_variablesSeen.add(variableName); | 56 m_variablesSeen.add(variableName); |
57 resolveVariableReferencesFromTokens(variableData->tokens(), result,
context); | 57 resolveVariableReferencesFromTokens(variableData->tokens(), result,
context); |
58 m_variablesSeen.remove(variableName); | 58 m_variablesSeen.remove(variableName); |
59 | 59 |
60 // The old variable data holds onto the backing string the new resol
ved CSSVariableData | 60 // The old variable data holds onto the backing string the new resol
ved CSSVariableData |
61 // relies on. Ensure it will live beyond us overwriting the RefPtr i
n StyleVariableData. | 61 // relies on. Ensure it will live beyond us overwriting the RefPtr i
n StyleVariableData. |
62 ASSERT(variableData->refCount() > 1); | 62 ASSERT(variableData->refCount() > 1); |
63 | 63 |
64 m_styleVariableData->setVariable(variableName, CSSVariableData::crea
teResolved(tokens)); | 64 m_styleVariableData->setVariable(variableName, CSSVariableData::crea
teResolved(tokens, variableData)); |
65 if (!context.cycleStartPoints.isEmpty()) { | 65 if (!context.cycleStartPoints.isEmpty()) { |
66 if (context.cycleStartPoints.contains(variableName)) | 66 if (context.cycleStartPoints.contains(variableName)) |
67 context.cycleStartPoints.remove(variableName); | 67 context.cycleStartPoints.remove(variableName); |
68 | 68 |
69 if (!context.cycleStartPoints.isEmpty()) { | 69 if (!context.cycleStartPoints.isEmpty()) { |
70 resolveFallback(range, trash, context); | 70 resolveFallback(range, trash, context); |
71 return; | 71 return; |
72 } | 72 } |
73 } | 73 } |
74 } else { | 74 } else { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 | 136 |
137 for (auto& variable : variables->m_data) { | 137 for (auto& variable : variables->m_data) { |
138 if (!variable.value->needsVariableResolution()) | 138 if (!variable.value->needsVariableResolution()) |
139 continue; | 139 continue; |
140 Vector<CSSParserToken> resolvedTokens; | 140 Vector<CSSParserToken> resolvedTokens; |
141 | 141 |
142 CSSVariableResolver resolver(variables, variable.key); | 142 CSSVariableResolver resolver(variables, variable.key); |
143 ResolutionState context; | 143 ResolutionState context; |
144 resolver.resolveVariableReferencesFromTokens(variable.value->tokens(), r
esolvedTokens, context); | 144 resolver.resolveVariableReferencesFromTokens(variable.value->tokens(), r
esolvedTokens, context); |
145 | 145 |
146 variable.value = CSSVariableData::createResolved(resolvedTokens); | 146 variable.value = CSSVariableData::createResolved(resolvedTokens, variabl
e.value); |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 CSSVariableResolver::CSSVariableResolver(StyleVariableData* styleVariableData) | 150 CSSVariableResolver::CSSVariableResolver(StyleVariableData* styleVariableData) |
151 : m_styleVariableData(styleVariableData) | 151 : m_styleVariableData(styleVariableData) |
152 { | 152 { |
153 } | 153 } |
154 | 154 |
155 CSSVariableResolver::CSSVariableResolver(StyleVariableData* styleVariableData, A
tomicString& variable) | 155 CSSVariableResolver::CSSVariableResolver(StyleVariableData* styleVariableData, A
tomicString& variable) |
156 : m_styleVariableData(styleVariableData) | 156 : m_styleVariableData(styleVariableData) |
157 { | 157 { |
158 m_variablesSeen.add(variable); | 158 m_variablesSeen.add(variable); |
159 } | 159 } |
160 | 160 |
161 } // namespace blink | 161 } // namespace blink |
OLD | NEW |