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

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: mixin w/o parameters Created 7 years, 3 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
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..d2c8111803add6e1e96d597bcf7868ffa86f9579 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 newline for top-level @include.
nweiz 2013/09/18 22:40:54 Unnecessary spaces before the comment.
terry 2013/10/09 03:40:33 Done.
+ emit('@include ${node.name}');
+ if (topLevel) emit(';');
nweiz 2013/09/18 22:40:54 Why wouldn't non-top-level @includes have a semico
terry 2013/10/09 03:40:33 removed test.On 2013/09/18 22:40:54, nweiz wrote:
+ }
+
+ void visitContentDirective(ContentDirective node) {
nweiz 2013/09/18 22:40:54 If you don't support content directives yet, just
terry 2013/10/09 03:40:33 Place holder have errors for content directive in
+ // TODO(terry): TBD
+ }
+
void visitRuleSet(RuleSet node) {
emit("$_newLine");
node._selectorGroup.visit(this);
@@ -232,6 +260,11 @@ 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 visitSelectorGroup(SelectorGroup node) {
var selectors = node._selectors;
var selectorsLength = selectors.length;

Powered by Google App Engine
This is Rietveld 408576698