OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of csslib.parser; | 5 part of csslib.parser; |
6 | 6 |
7 /** | 7 /** |
8 * CSS polyfill emits CSS to be understood by older parsers that which do not | 8 * CSS polyfill emits CSS to be understood by older parsers that which do not |
9 * understand (var, calc, etc.). | 9 * understand (var, calc, etc.). |
10 */ | 10 */ |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 if (def.badUsage) { | 137 if (def.badUsage) { |
138 // Remove any expressions pointing to a bad var definition. | 138 // Remove any expressions pointing to a bad var definition. |
139 expressions.removeAt(index); | 139 expressions.removeAt(index); |
140 return; | 140 return; |
141 } | 141 } |
142 _resolveVarUsage(currentExpressions, index, | 142 _resolveVarUsage(currentExpressions, index, |
143 _findTerminalVarDefinition(_knownVarDefs, def)); | 143 _findTerminalVarDefinition(_knownVarDefs, def)); |
144 } else if (node.defaultValues.any((e) => e is VarUsage)) { | 144 } else if (node.defaultValues.any((e) => e is VarUsage)) { |
145 // Don't have a VarDefinition need to use default values resolve all | 145 // Don't have a VarDefinition need to use default values resolve all |
146 // default values. | 146 // default values. |
147 var terminalDefaults = []; | 147 var terminalDefaults = <Expression>[]; |
148 for (var defaultValue in node.defaultValues) { | 148 for (var defaultValue in node.defaultValues) { |
149 terminalDefaults.addAll(resolveUsageTerminal(defaultValue)); | 149 terminalDefaults.addAll(resolveUsageTerminal(defaultValue)); |
150 } | 150 } |
151 expressions.replaceRange(index, index + 1, terminalDefaults); | 151 expressions.replaceRange(index, index + 1, terminalDefaults); |
152 } else if (node.defaultValues.isNotEmpty){ | 152 } else if (node.defaultValues.isNotEmpty){ |
153 // No VarDefinition but default value is a terminal expression; use it. | 153 // No VarDefinition but default value is a terminal expression; use it. |
154 expressions.replaceRange(index, index + 1, node.defaultValues); | 154 expressions.replaceRange(index, index + 1, node.defaultValues); |
155 } else { | 155 } else { |
156 if (currVarDefinition != null) { | 156 if (currVarDefinition != null) { |
157 currVarDefinition.badUsage = true; | 157 currVarDefinition.badUsage = true; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 } | 192 } |
193 | 193 |
194 // We're at a terminal just return the VarDefinition expression. | 194 // We're at a terminal just return the VarDefinition expression. |
195 if (result.isEmpty && varDef != null) { | 195 if (result.isEmpty && varDef != null) { |
196 result = (varDef.expression as Expressions).expressions; | 196 result = (varDef.expression as Expressions).expressions; |
197 } | 197 } |
198 | 198 |
199 return result; | 199 return result; |
200 } | 200 } |
201 | 201 |
202 _resolveVarUsage(List<Expressions> expressions, int index, | 202 _resolveVarUsage(List<Expression> expressions, int index, |
203 VarDefinition def) { | 203 VarDefinition def) { |
204 var defExpressions = (def.expression as Expressions).expressions; | 204 var defExpressions = (def.expression as Expressions).expressions; |
205 expressions.replaceRange(index, index + 1, defExpressions); | 205 expressions.replaceRange(index, index + 1, defExpressions); |
206 } | 206 } |
207 } | 207 } |
208 | 208 |
209 /** Remove all var definitions. */ | 209 /** Remove all var definitions. */ |
210 class _RemoveVarDefinitions extends Visitor { | 210 class _RemoveVarDefinitions extends Visitor { |
211 void visitTree(StyleSheet tree) { | 211 void visitTree(StyleSheet tree) { |
212 visitStyleSheet(tree); | 212 visitStyleSheet(tree); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 } | 249 } |
250 } else { | 250 } else { |
251 // Return real CSS property. | 251 // Return real CSS property. |
252 return varDef; | 252 return varDef; |
253 } | 253 } |
254 } | 254 } |
255 | 255 |
256 // Didn't point to a var definition that existed. | 256 // Didn't point to a var definition that existed. |
257 return varDef; | 257 return varDef; |
258 } | 258 } |
OLD | NEW |