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/parser/CSSVariableParser.h" | 5 #include "core/css/parser/CSSVariableParser.h" |
6 | 6 |
7 #include "core/css/CSSCustomPropertyDeclaration.h" | 7 #include "core/css/CSSCustomPropertyDeclaration.h" |
8 #include "core/css/CSSVariableReferenceValue.h" | 8 #include "core/css/CSSVariableReferenceValue.h" |
9 #include "core/css/parser/CSSParserTokenRange.h" | 9 #include "core/css/parser/CSSParserTokenRange.h" |
10 | 10 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 return nullptr; | 135 return nullptr; |
136 | 136 |
137 bool hasReferences; | 137 bool hasReferences; |
138 bool hasAtApplyRule; | 138 bool hasAtApplyRule; |
139 CSSValueID type = classifyVariableRange(range, hasReferences, hasAtApplyRule); | 139 CSSValueID type = classifyVariableRange(range, hasReferences, hasAtApplyRule); |
140 | 140 |
141 if (type == CSSValueInvalid) | 141 if (type == CSSValueInvalid) |
142 return nullptr; | 142 return nullptr; |
143 if (type == CSSValueInternalVariableValue) { | 143 if (type == CSSValueInternalVariableValue) { |
144 return CSSCustomPropertyDeclaration::create( | 144 return CSSCustomPropertyDeclaration::create( |
145 variableName, CSSVariableData::create(range, isAnimationTainted, | 145 variableName, |
146 hasReferences || hasAtApplyRule)); | 146 CSSVariableData::create(range, isAnimationTainted, |
| 147 hasReferences || hasAtApplyRule)); |
147 } | 148 } |
148 return CSSCustomPropertyDeclaration::create(variableName, type); | 149 return CSSCustomPropertyDeclaration::create(variableName, type); |
149 } | 150 } |
150 | 151 |
151 CSSVariableReferenceValue* CSSVariableParser::parseRegisteredPropertyValue( | 152 CSSVariableReferenceValue* CSSVariableParser::parseRegisteredPropertyValue( |
152 CSSParserTokenRange range, | 153 CSSParserTokenRange range, |
153 bool requireVarReference, | 154 bool requireVarReference, |
154 bool isAnimationTainted) { | 155 bool isAnimationTainted) { |
155 if (range.atEnd()) | 156 if (range.atEnd()) |
156 return nullptr; | 157 return nullptr; |
157 | 158 |
158 bool hasReferences; | 159 bool hasReferences; |
159 bool hasAtApplyRule; | 160 bool hasAtApplyRule; |
160 CSSValueID type = classifyVariableRange(range, hasReferences, hasAtApplyRule); | 161 CSSValueID type = classifyVariableRange(range, hasReferences, hasAtApplyRule); |
161 | 162 |
162 if (type != CSSValueInternalVariableValue) | 163 if (type != CSSValueInternalVariableValue) |
163 return nullptr; // Invalid or a css-wide keyword | 164 return nullptr; // Invalid or a css-wide keyword |
164 if (requireVarReference && !hasReferences) | 165 if (requireVarReference && !hasReferences) |
165 return nullptr; | 166 return nullptr; |
166 // TODO(timloh): Should this be hasReferences || hasAtApplyRule? | 167 // TODO(timloh): Should this be hasReferences || hasAtApplyRule? |
167 return CSSVariableReferenceValue::create( | 168 return CSSVariableReferenceValue::create( |
168 CSSVariableData::create(range, isAnimationTainted, hasReferences)); | 169 CSSVariableData::create(range, isAnimationTainted, hasReferences)); |
169 } | 170 } |
170 | 171 |
171 } // namespace blink | 172 } // namespace blink |
OLD | NEW |