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

Side by Side Diff: pkg/polymer/lib/src/build/import_inliner.dart

Issue 589743002: warn if inlining the same css file more than once (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: generate messages.html, update pubspec/changelog for release Created 6 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 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 /// Transfomer that inlines polymer-element definitions from html imports. 5 /// Transfomer that inlines polymer-element definitions from html imports.
6 library polymer.src.build.import_inliner; 6 library polymer.src.build.import_inliner;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:convert'; 9 import 'dart:convert';
10 10
(...skipping 13 matching lines...) Expand all
24 import 'messages.dart'; 24 import 'messages.dart';
25 25
26 // TODO(sigmund): move to web_components package (dartbug.com/18037). 26 // TODO(sigmund): move to web_components package (dartbug.com/18037).
27 class _HtmlInliner extends PolymerTransformer { 27 class _HtmlInliner extends PolymerTransformer {
28 final TransformOptions options; 28 final TransformOptions options;
29 final Transform transform; 29 final Transform transform;
30 final BuildLogger logger; 30 final BuildLogger logger;
31 final AssetId docId; 31 final AssetId docId;
32 final seen = new Set<AssetId>(); 32 final seen = new Set<AssetId>();
33 final scriptIds = <AssetId>[]; 33 final scriptIds = <AssetId>[];
34 final inlinedStylesheetIds = new Set<AssetId>();
34 final extractedFiles = new Set<AssetId>(); 35 final extractedFiles = new Set<AssetId>();
35 bool experimentalBootstrap = false; 36 bool experimentalBootstrap = false;
36 final Element importsWrapper = new Element.html('<div hidden></div>'); 37 final Element importsWrapper = new Element.html('<div hidden></div>');
37 38
38 /// The number of extracted inline Dart scripts. Used as a counter to give 39 /// The number of extracted inline Dart scripts. Used as a counter to give
39 /// unique-ish filenames. 40 /// unique-ish filenames.
40 int inlineScriptCounter = 0; 41 int inlineScriptCounter = 0;
41 42
42 _HtmlInliner(TransformOptions options, Transform transform) 43 _HtmlInliner(TransformOptions options, Transform transform)
43 : options = options, 44 : options = options,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 tag.remove(); 129 tag.remove();
129 return null; 130 return null;
130 } 131 }
131 return _inlineImport(id, tag); 132 return _inlineImport(id, tag);
132 133
133 } else if (rel == 'stylesheet') { 134 } else if (rel == 'stylesheet') {
134 if (id == null) return null; 135 if (id == null) return null;
135 if (!options.shouldInlineStylesheet(id)) return null; 136 if (!options.shouldInlineStylesheet(id)) return null;
136 137
137 changed = true; 138 changed = true;
139 if (inlinedStylesheetIds.contains(id)
140 && !options.stylesheetInliningIsOverridden(id)) {
141 logger.warning(
142 CSS_FILE_INLINED_MULTIPLE_TIMES.create({'url': id.path}),
143 span: tag.sourceSpan);
144 }
145 inlinedStylesheetIds.add(id);
138 return _inlineStylesheet(id, tag); 146 return _inlineStylesheet(id, tag);
139 } 147 }
140 }).then((_) => changed); 148 }).then((_) => changed);
141 } 149 }
142 150
143 /// To preserve the order of scripts with respect to inlined 151 /// To preserve the order of scripts with respect to inlined
144 /// link rel=import, we move both of those into the body before we do any 152 /// link rel=import, we move both of those into the body before we do any
145 /// inlining. We do not start doing this until the first import is found 153 /// inlining. We do not start doing this until the first import is found
146 /// however, as some scripts do need to be ran in the head to work 154 /// however, as some scripts do need to be ran in the head to work
147 /// properly (platform.js for instance). 155 /// properly (platform.js for instance).
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 /// style tag except these ones. 552 /// style tag except these ones.
545 const IGNORED_LINKED_STYLE_ATTRS = 553 const IGNORED_LINKED_STYLE_ATTRS =
546 const ['charset', 'href', 'href-lang', 'rel', 'rev']; 554 const ['charset', 'href', 'href-lang', 'rel', 'rev'];
547 555
548 /// Global RegExp objects. 556 /// Global RegExp objects.
549 final _INVALID_LIB_CHARS_REGEX = new RegExp('[^a-z0-9_]'); 557 final _INVALID_LIB_CHARS_REGEX = new RegExp('[^a-z0-9_]');
550 final _NUM_REGEX = new RegExp('[0-9]'); 558 final _NUM_REGEX = new RegExp('[0-9]');
551 final _BINDING_REGEX = new RegExp(r'(({{.*}})|(\[\[.*\]\]))'); 559 final _BINDING_REGEX = new RegExp(r'(({{.*}})|(\[\[.*\]\]))');
552 560
553 _getSpan(SourceFile file, AstNode node) => file.span(node.offset, node.end); 561 _getSpan(SourceFile file, AstNode node) => file.span(node.offset, node.end);
OLDNEW
« no previous file with comments | « pkg/polymer/lib/src/build/generated/messages.html ('k') | pkg/polymer/lib/src/build/messages.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698