| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library csslib.visitor; | 5 library csslib.visitor; |
| 6 | 6 |
| 7 import 'package:source_maps/span.dart' show Span; | 7 import 'package:source_maps/span.dart' show Span; |
| 8 import 'parser.dart'; | 8 import 'parser.dart'; |
| 9 | 9 |
| 10 part 'src/css_printer.dart'; | 10 part 'src/css_printer.dart'; |
| 11 part 'src/tree.dart'; | 11 part 'src/tree.dart'; |
| 12 part 'src/tree_base.dart'; | 12 part 'src/tree_base.dart'; |
| 13 part 'src/tree_printer.dart'; | 13 part 'src/tree_printer.dart'; |
| 14 | 14 |
| 15 abstract class VisitorBase { | 15 abstract class VisitorBase { |
| 16 void visitCssComment(CssComment node); | 16 void visitCssComment(CssComment node); |
| 17 void visitCommentDefinition(CommentDefinition node); | 17 void visitCommentDefinition(CommentDefinition node); |
| 18 void visitStyleSheet(StyleSheet node); | 18 void visitStyleSheet(StyleSheet node); |
| 19 void visitNoOp(NoOp node); |
| 19 void visitTopLevelProduction(TopLevelProduction node); | 20 void visitTopLevelProduction(TopLevelProduction node); |
| 20 void visitDirective(Directive node); | 21 void visitDirective(Directive node); |
| 21 void visitMediaExpression(MediaExpression node); | 22 void visitMediaExpression(MediaExpression node); |
| 22 void visitMediaQuery(MediaQuery node); | 23 void visitMediaQuery(MediaQuery node); |
| 23 void visitMediaDirective(MediaDirective node); | 24 void visitMediaDirective(MediaDirective node); |
| 24 void visitHostDirective(HostDirective node); | 25 void visitHostDirective(HostDirective node); |
| 25 void visitPageDirective(PageDirective node); | 26 void visitPageDirective(PageDirective node); |
| 26 void visitCharsetDirective(CharsetDirective node); | 27 void visitCharsetDirective(CharsetDirective node); |
| 27 void visitImportDirective(ImportDirective node); | 28 void visitImportDirective(ImportDirective node); |
| 28 void visitKeyFrameDirective(KeyFrameDirective node); | 29 void visitKeyFrameDirective(KeyFrameDirective node); |
| 29 void visitKeyFrameBlock(KeyFrameBlock node); | 30 void visitKeyFrameBlock(KeyFrameBlock node); |
| 30 void visitFontFaceDirective(FontFaceDirective node); | 31 void visitFontFaceDirective(FontFaceDirective node); |
| 31 void visitStyletDirective(StyletDirective node); | 32 void visitStyletDirective(StyletDirective node); |
| 32 void visitNamespaceDirective(NamespaceDirective node); | 33 void visitNamespaceDirective(NamespaceDirective node); |
| 33 void visitVarDefinitionDirective(VarDefinitionDirective node); | 34 void visitVarDefinitionDirective(VarDefinitionDirective node); |
| 35 void visitMixinDefinition(MixinDefinition node); |
| 36 void visitMixinRulesetDirective(MixinRulesetDirective node); |
| 37 void visitMixinDeclarationDirective(MixinDeclarationDirective node); |
| 38 void visitIncludeDirective(IncludeDirective node); |
| 39 void visitContentDirective(ContentDirective node); |
| 34 | 40 |
| 35 void visitRuleSet(RuleSet node); | 41 void visitRuleSet(RuleSet node); |
| 36 void visitDeclarationGroup(DeclarationGroup node); | 42 void visitDeclarationGroup(DeclarationGroup node); |
| 37 void visitMarginGroup(DeclarationGroup node); | 43 void visitMarginGroup(DeclarationGroup node); |
| 38 void visitDeclaration(Declaration node); | 44 void visitDeclaration(Declaration node); |
| 39 void visitVarDefinition(VarDefinition node); | 45 void visitVarDefinition(VarDefinition node); |
| 46 void visitIncludeMixinAtDeclaration(IncludeMixinAtDeclaration node); |
| 40 void visitSelectorGroup(SelectorGroup node); | 47 void visitSelectorGroup(SelectorGroup node); |
| 41 void visitSelector(Selector node); | 48 void visitSelector(Selector node); |
| 42 void visitSimpleSelectorSequence(SimpleSelectorSequence node); | 49 void visitSimpleSelectorSequence(SimpleSelectorSequence node); |
| 43 void visitSimpleSelector(SimpleSelector node); | 50 void visitSimpleSelector(SimpleSelector node); |
| 44 void visitElementSelector(ElementSelector node); | 51 void visitElementSelector(ElementSelector node); |
| 45 void visitNamespaceSelector(NamespaceSelector node); | 52 void visitNamespaceSelector(NamespaceSelector node); |
| 46 void visitAttributeSelector(AttributeSelector node); | 53 void visitAttributeSelector(AttributeSelector node); |
| 47 void visitIdSelector(IdSelector node); | 54 void visitIdSelector(IdSelector node); |
| 48 void visitClassSelector(ClassSelector node); | 55 void visitClassSelector(ClassSelector node); |
| 49 void visitPseudoClassSelector(PseudoClassSelector node); | 56 void visitPseudoClassSelector(PseudoClassSelector node); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 list[index].visit(this); | 118 list[index].visit(this); |
| 112 } | 119 } |
| 113 } | 120 } |
| 114 | 121 |
| 115 void visitTree(StyleSheet tree) => visitStyleSheet(tree); | 122 void visitTree(StyleSheet tree) => visitStyleSheet(tree); |
| 116 | 123 |
| 117 void visitStyleSheet(StyleSheet ss) { | 124 void visitStyleSheet(StyleSheet ss) { |
| 118 _visitNodeList(ss.topLevels); | 125 _visitNodeList(ss.topLevels); |
| 119 } | 126 } |
| 120 | 127 |
| 128 void visitNoOp(NoOp node) { } |
| 129 |
| 121 void visitTopLevelProduction(TopLevelProduction node) { } | 130 void visitTopLevelProduction(TopLevelProduction node) { } |
| 122 | 131 |
| 123 void visitDirective(Directive node) { } | 132 void visitDirective(Directive node) { } |
| 124 | 133 |
| 125 void visitCssComment(CssComment node) { } | 134 void visitCssComment(CssComment node) { } |
| 126 | 135 |
| 127 void visitCommentDefinition(CommentDefinition node) { } | 136 void visitCommentDefinition(CommentDefinition node) { } |
| 128 | 137 |
| 129 void visitMediaExpression(MediaExpression node) { | 138 void visitMediaExpression(MediaExpression node) { |
| 130 visitExpressions(node.exprs); | 139 visitExpressions(node.exprs); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 void visitStyletDirective(StyletDirective node) { | 195 void visitStyletDirective(StyletDirective node) { |
| 187 _visitNodeList(node._rulesets); | 196 _visitNodeList(node._rulesets); |
| 188 } | 197 } |
| 189 | 198 |
| 190 void visitNamespaceDirective(NamespaceDirective node) { } | 199 void visitNamespaceDirective(NamespaceDirective node) { } |
| 191 | 200 |
| 192 void visitVarDefinitionDirective(VarDefinitionDirective node) { | 201 void visitVarDefinitionDirective(VarDefinitionDirective node) { |
| 193 visitVarDefinition(node.def); | 202 visitVarDefinition(node.def); |
| 194 } | 203 } |
| 195 | 204 |
| 205 void visitMixinRulesetDirective(MixinRulesetDirective node) { |
| 206 _visitNodeList(node.rulesets); |
| 207 } |
| 208 |
| 209 void visitMixinDefinition(MixinDefinition node) { } |
| 210 |
| 211 void visitMixinDeclarationDirective(MixinDeclarationDirective node) { |
| 212 visitDeclarationGroup(node.declarations); |
| 213 } |
| 214 |
| 215 void visitIncludeDirective(IncludeDirective node) { } |
| 216 |
| 217 void visitContentDirective(ContentDirective node) { |
| 218 // TODO(terry): TBD |
| 219 } |
| 220 |
| 196 void visitRuleSet(RuleSet node) { | 221 void visitRuleSet(RuleSet node) { |
| 197 visitSelectorGroup(node._selectorGroup); | 222 visitSelectorGroup(node._selectorGroup); |
| 198 visitDeclarationGroup(node._declarationGroup); | 223 visitDeclarationGroup(node._declarationGroup); |
| 199 } | 224 } |
| 200 | 225 |
| 201 void visitDeclarationGroup(DeclarationGroup node) { | 226 void visitDeclarationGroup(DeclarationGroup node) { |
| 202 _visitNodeList(node._declarations); | 227 _visitNodeList(node._declarations); |
| 203 } | 228 } |
| 204 | 229 |
| 205 void visitMarginGroup(MarginGroup node) => visitDeclarationGroup(node); | 230 void visitMarginGroup(MarginGroup node) => visitDeclarationGroup(node); |
| 206 | 231 |
| 207 void visitDeclaration(Declaration node) { | 232 void visitDeclaration(Declaration node) { |
| 208 visitIdentifier(node._property); | 233 visitIdentifier(node._property); |
| 209 if (node._expression != null) node._expression.visit(this); | 234 if (node._expression != null) node._expression.visit(this); |
| 210 } | 235 } |
| 211 | 236 |
| 212 void visitVarDefinition(VarDefinition node) { | 237 void visitVarDefinition(VarDefinition node) { |
| 213 visitIdentifier(node._property); | 238 visitIdentifier(node._property); |
| 214 if (node._expression != null) node._expression.visit(this); | 239 if (node._expression != null) node._expression.visit(this); |
| 215 } | 240 } |
| 216 | 241 |
| 242 void visitIncludeMixinAtDeclaration(IncludeMixinAtDeclaration node) { |
| 243 visitIncludeDirective(node.include); |
| 244 } |
| 245 |
| 217 void visitSelectorGroup(SelectorGroup node) { | 246 void visitSelectorGroup(SelectorGroup node) { |
| 218 _visitNodeList(node.selectors); | 247 _visitNodeList(node.selectors); |
| 219 } | 248 } |
| 220 | 249 |
| 221 void visitSelector(Selector node) { | 250 void visitSelector(Selector node) { |
| 222 _visitNodeList(node._simpleSelectorSequences); | 251 _visitNodeList(node._simpleSelectorSequences); |
| 223 } | 252 } |
| 224 | 253 |
| 225 void visitSimpleSelectorSequence(SimpleSelectorSequence node) { | 254 void visitSimpleSelectorSequence(SimpleSelectorSequence node) { |
| 226 var selector = node._selector; | 255 var selector = node._selector; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 void visitPaddingExpression(PaddingExpression node) { | 465 void visitPaddingExpression(PaddingExpression node) { |
| 437 // TODO(terry): TBD | 466 // TODO(terry): TBD |
| 438 throw UnimplementedError; | 467 throw UnimplementedError; |
| 439 } | 468 } |
| 440 | 469 |
| 441 void visitWidthExpression(WidthExpression node) { | 470 void visitWidthExpression(WidthExpression node) { |
| 442 // TODO(terry): TBD | 471 // TODO(terry): TBD |
| 443 throw UnimplementedError; | 472 throw UnimplementedError; |
| 444 } | 473 } |
| 445 } | 474 } |
| OLD | NEW |