Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(589)

Unified Diff: pkg/csslib/lib/src/css_printer.dart

Issue 23819036: Support for @mixin, @include and @extend (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: All changes ready to commit Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/csslib/lib/src/analyzer.dart ('k') | pkg/csslib/lib/src/messages.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/csslib/lib/src/css_printer.dart
diff --git a/pkg/csslib/lib/src/css_printer.dart b/pkg/csslib/lib/src/css_printer.dart
index b8000b70a7ea9c40fafdd677aec303d4b312e7fc..b532544ccc4e6155e1961fc559375882d18bb69a 100644
--- a/pkg/csslib/lib/src/css_printer.dart
+++ b/pkg/csslib/lib/src/css_printer.dart
@@ -187,6 +187,34 @@ class CssPrinter extends Visitor {
emit(';$_newLine');
}
+ void visitMixinRulesetDirective(MixinRulesetDirective node) {
+ emit('@mixin ${node.name} {');
+ for (var ruleset in node.rulesets) {
+ ruleset.visit(this);
+ }
+ emit('}');
+ }
+
+ void visitMixinDeclarationDirective(MixinDeclarationDirective node) {
+ emit('@mixin ${node.name} {\n');
+ visitDeclarationGroup(node.declarations);
+ emit('}');
+ }
+
+ /**
+ * Added optional newLine for handling @include at top-level vs/ inside of
+ * a declaration group.
+ */
+ void visitIncludeDirective(IncludeDirective node, [bool topLevel = true]) {
+ if (topLevel) emit(_newLine);
+ emit('@include ${node.name}');
+ emit(';');
+ }
+
+ void visitContentDirective(ContentDirective node) {
+ // TODO(terry): TBD
+ }
+
void visitRuleSet(RuleSet node) {
emit("$_newLine");
node._selectorGroup.visit(this);
@@ -232,6 +260,19 @@ class CssPrinter extends Visitor {
node._expression.visit(this);
}
+ void visitIncludeMixinAtDeclaration(IncludeMixinAtDeclaration node) {
+ // Don't emit a new line we're inside of a declaration group.
+ visitIncludeDirective(node.include, false);
+ }
+
+ void visitExtendDeclaration(ExtendDeclaration node) {
+ emit("@extend ");
+ for (var selector in node.selectors) {
+ selector.visit(this);
+ }
+ }
+
+
void visitSelectorGroup(SelectorGroup node) {
var selectors = node._selectors;
var selectorsLength = selectors.length;
@@ -251,31 +292,31 @@ class CssPrinter extends Visitor {
}
void visitNamespaceSelector(NamespaceSelector node) {
- emit("${node.namespace}|${node.nameAsSimpleSelector.name}");
+ emit(node.toString());
}
void visitElementSelector(ElementSelector node) {
- emit("${node.name}");
+ emit(node.toString());
}
void visitAttributeSelector(AttributeSelector node) {
- emit("[${node.name}${node.matchOperator()}${node.valueToString()}]");
+ emit(node.toString());
}
void visitIdSelector(IdSelector node) {
- emit("#${node.name}");
+ emit(node.toString());
}
void visitClassSelector(ClassSelector node) {
- emit(".${node.name}");
+ emit(node.toString());
}
void visitPseudoClassSelector(PseudoClassSelector node) {
- emit(":${node.name}");
+ emit(node.toString());
}
void visitPseudoElementSelector(PseudoElementSelector node) {
- emit("::${node.name}");
+ emit(node.toString());
}
void visitPseudoClassFunctionSelector(PseudoClassFunctionSelector node) {
« no previous file with comments | « pkg/csslib/lib/src/analyzer.dart ('k') | pkg/csslib/lib/src/messages.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698