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

Side by Side Diff: pkg/polymer/lib/src/css_emitters.dart

Issue 23445009: Prune the old deploy code. This CL does a few changes: (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 library polymer.src.css_emitters; 5 library polymer.src.css_emitters;
6 6
7 import 'package:csslib/visitor.dart' show Visitor, CssPrinter, ElementSelector, 7 import 'package:csslib/visitor.dart' show Visitor, CssPrinter, ElementSelector,
8 UriTerm, Selector, HostDirective, SimpleSelectorSequence, StyleSheet; 8 UriTerm, Selector, HostDirective, SimpleSelectorSequence, StyleSheet;
9 9
10 import 'info.dart'; 10 import 'info.dart';
11 import 'paths.dart' show PathMapper;
12 import 'utils.dart'; 11 import 'utils.dart';
13 12
14 void rewriteCssUris(PathMapper pathMapper, String cssPath, bool rewriteUrls,
15 StyleSheet styleSheet) {
16 new _UriVisitor(pathMapper, cssPath, rewriteUrls).visitTree(styleSheet);
17 }
18
19 /** Compute each CSS URI resource relative from the generated CSS file. */
20 class _UriVisitor extends Visitor {
21 /**
22 * Relative path from the output css file to the location of the original
23 * css file that contained the URI to each resource.
24 */
25 final String _pathToOriginalCss;
26
27 factory _UriVisitor(PathMapper pathMapper, String cssPath, bool rewriteUrl) {
28 var cssDir = path.dirname(cssPath);
29 var outCssDir = rewriteUrl ? pathMapper.outputDirPath(cssPath)
30 : path.dirname(cssPath);
31 return new _UriVisitor._internal(path.relative(cssDir, from: outCssDir));
32 }
33
34 _UriVisitor._internal(this._pathToOriginalCss);
35
36 void visitUriTerm(UriTerm node) {
37 // Don't touch URIs that have any scheme (http, etc.).
38 var uri = Uri.parse(node.text);
39 if (uri.host != '') return;
40 if (uri.scheme != '' && uri.scheme != 'package') return;
41
42 node.text = pathToUrl(
43 path.normalize(path.join(_pathToOriginalCss, node.text)));
44 }
45 }
46
47 13
48 /** Emit the contents of the style tag outside of a component. */ 14 /** Emit the contents of the style tag outside of a component. */
49 String emitStyleSheet(StyleSheet ss, FileInfo file) => 15 String emitStyleSheet(StyleSheet ss, FileInfo file) =>
50 (new _CssEmitter(file.components.keys.toSet()) 16 (new _CssEmitter(file.components.keys.toSet())
51 ..visitTree(ss, pretty: true)).toString(); 17 ..visitTree(ss, pretty: true)).toString();
52 18
53 /** Emit a component's style tag content emulating scoped css. */ 19 /** Emit a component's style tag content emulating scoped css. */
54 String emitComponentStyleSheet(StyleSheet ss, String tagName) => 20 String emitComponentStyleSheet(StyleSheet ss, String tagName) =>
55 (new _ComponentCssEmitter(tagName)..visitTree(ss, pretty: true)).toString(); 21 (new _ComponentCssEmitter(tagName)..visitTree(ss, pretty: true)).toString();
56 22
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 void visitHostDirective(HostDirective node) { 112 void visitHostDirective(HostDirective node) {
147 _inHostDirective = true; 113 _inHostDirective = true;
148 emit('/* @host */'); 114 emit('/* @host */');
149 for (var ruleset in node.rulesets) { 115 for (var ruleset in node.rulesets) {
150 ruleset.visit(this); 116 ruleset.visit(this);
151 } 117 }
152 _inHostDirective = false; 118 _inHostDirective = false;
153 emit('/* end of @host */\n'); 119 emit('/* end of @host */\n');
154 } 120 }
155 } 121 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698