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

Side by Side Diff: lib/src/info.dart

Issue 12474002: Support for parsing all CSS and producing one CSS file (Closed) Base URL: https://github.com/dart-lang/web-ui.git@master
Patch Set: merged Created 7 years, 9 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
OLDNEW
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 /** 5 /**
6 * Datatypes holding information extracted by the analyzer and used by later 6 * Datatypes holding information extracted by the analyzer and used by later
7 * phases of the compiler. 7 * phases of the compiler.
8 */ 8 */
9 library info; 9 library info;
10 10
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 } 140 }
141 141
142 /** 142 /**
143 * Transforms a [target] url seen in [src] (e.g. a Dart import, a .css href in 143 * Transforms a [target] url seen in [src] (e.g. a Dart import, a .css href in
144 * an HTML file, etc) into a corresponding url from the output file associated 144 * an HTML file, etc) into a corresponding url from the output file associated
145 * with [src]. This will keep 'package:', 'dart:', path-absolute, and absolute 145 * with [src]. This will keep 'package:', 'dart:', path-absolute, and absolute
146 * urls intact, but it will fix relative paths to walk from the output 146 * urls intact, but it will fix relative paths to walk from the output
147 * directory back to the input directory. An exception will be thrown if 147 * directory back to the input directory. An exception will be thrown if
148 * [target] is not under [_baseDir]. 148 * [target] is not under [_baseDir].
149 */ 149 */
150 String transformUrl(Path src, String target) { 150 Path transformUrlToPath(Path src, String target) {
Siggi Cherem (dart-lang) 2013/03/07 22:14:20 seems that you no longer need this part of the cha
terry 2013/03/08 20:11:24 Done.
151 if (new Uri.fromString(target).isAbsolute) return target; 151 if (new Uri.fromString(target).isAbsolute) return new Path(target);
152 var path = new Path(target); 152 var path = new Path(target);
153 if (path.isAbsolute) return target; 153 if (path.isAbsolute) return path;
154 var pathToTarget = src.directoryPath.join(path); 154 var pathToTarget = src.directoryPath.join(path);
155 var outputLibraryDir = outputDirPath(src); 155 var outputLibraryDir = outputDirPath(src);
156 return pathToTarget.relativeTo(outputLibraryDir).canonicalize().toString(); 156 return pathToTarget.relativeTo(outputLibraryDir).canonicalize();
157 } 157 }
158
159 String transformUrl(Path src, String target) =>
160 transformUrlToPath(src, target).toString();
158 } 161 }
159 162
160 /** 163 /**
161 * Returns a "mangled" name, with a prefix and [suffix] depending on the 164 * Returns a "mangled" name, with a prefix and [suffix] depending on the
162 * compiler's settings. [forceSuffix] causes [suffix] to be appended even if 165 * compiler's settings. [forceSuffix] causes [suffix] to be appended even if
163 * the compiler is not mangling names. 166 * the compiler is not mangling names.
164 */ 167 */
165 typedef String NameMangler(String name, String suffix, [bool forceSuffix]); 168 typedef String NameMangler(String name, String suffix, [bool forceSuffix]);
166 169
167 /** 170 /**
(...skipping 23 matching lines...) Expand all
191 194
192 /** 195 /**
193 * The inverse of [externalCode]. If this .dart file was imported via a script 196 * The inverse of [externalCode]. If this .dart file was imported via a script
194 * tag, this refers to the HTML file that imported it. 197 * tag, this refers to the HTML file that imported it.
195 */ 198 */
196 LibraryInfo htmlFile; 199 LibraryInfo htmlFile;
197 200
198 /** File where the top-level code was defined. */ 201 /** File where the top-level code was defined. */
199 Path get inputPath; 202 Path get inputPath;
200 203
201 /** Stylesheet with <style>...</style> */
202 StringBuffer cssSource = new StringBuffer();
203
204 /** Parsed cssSource. */ 204 /** Parsed cssSource. */
205 StyleSheet styleSheet; 205 List<StyleSheet> styleSheets = [];
206 206
207 /** 207 /**
208 * Name of the file that will hold any generated Dart code for this library 208 * Name of the file that will hold any generated Dart code for this library
209 * unit. 209 * unit.
210 */ 210 */
211 String _getOutputFilename(NameMangler mangle); 211 String _getOutputFilename(NameMangler mangle);
212 212
213 /** This is used in transforming Dart code to track modified files. */ 213 /** This is used in transforming Dart code to track modified files. */
214 bool modified = false; 214 bool modified = false;
215 215
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 * All custom element definitions defined in this file or imported via 269 * All custom element definitions defined in this file or imported via
270 *`<link rel='components'>` tag. Maps from the tag name to the component 270 *`<link rel='components'>` tag. Maps from the tag name to the component
271 * information. This map is sorted by the tag name. 271 * information. This map is sorted by the tag name.
272 */ 272 */
273 final Map<String, ComponentInfo> components = 273 final Map<String, ComponentInfo> components =
274 new SplayTreeMap<String, ComponentInfo>(); 274 new SplayTreeMap<String, ComponentInfo>();
275 275
276 /** Files imported with `<link rel="component">` */ 276 /** Files imported with `<link rel="component">` */
277 final List<Path> componentLinks = <Path>[]; 277 final List<Path> componentLinks = <Path>[];
278 278
279 /** Files imported with `<link rel="stylesheet">` */
280 final List<Path> styleSheetHref = <Path>[];
281
279 /** Root is associated with the body info. */ 282 /** Root is associated with the body info. */
280 ElementInfo bodyInfo; 283 ElementInfo bodyInfo;
281 284
282 FileInfo(this.path, [this.isEntryPoint = false]); 285 FileInfo(this.path, [this.isEntryPoint = false]);
283 286
284 /** 287 /**
285 * Query for an ElementInfo matching the provided [tag], starting from the 288 * Query for an ElementInfo matching the provided [tag], starting from the
286 * [bodyInfo]. 289 * [bodyInfo].
287 */ 290 */
288 ElementInfo query(String tag) => new _QueryInfo(tag).visit(bodyInfo); 291 ElementInfo query(String tag) => new _QueryInfo(tag).visit(bodyInfo);
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 } 710 }
708 711
709 visitChildren(ElementInfo info) { 712 visitChildren(ElementInfo info) {
710 for (var child in info.children) { 713 for (var child in info.children) {
711 var result = visit(child); 714 var result = visit(child);
712 if (result != null) return result; 715 if (result != null) return result;
713 } 716 }
714 return null; 717 return null;
715 } 718 }
716 } 719 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698