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

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

Issue 162093002: fix imports link rel=stylesheet (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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
« no previous file with comments | « pkg/polymer/lib/src/instance.dart ('k') | pkg/polymer/pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 part of polymer; 5 part of polymer;
6 6
7 /** Annotation used to automatically register polymer elements. */ 7 /** Annotation used to automatically register polymer elements. */
8 class CustomTag { 8 class CustomTag {
9 final String tagName; 9 final String tagName;
10 const CustomTag(this.tagName); 10 const CustomTag(this.tagName);
(...skipping 15 matching lines...) Expand all
26 * invoke the initialization method on it (top-level functions annotated with 26 * invoke the initialization method on it (top-level functions annotated with
27 * [initMethod]). 27 * [initMethod]).
28 */ 28 */
29 Zone initPolymer() { 29 Zone initPolymer() {
30 // We use this pattern, and not the inline lazy initialization pattern, so we 30 // We use this pattern, and not the inline lazy initialization pattern, so we
31 // can help dart2js detect that _discoverInitializers can be tree-shaken for 31 // can help dart2js detect that _discoverInitializers can be tree-shaken for
32 // deployment (and hence all uses of dart:mirrors from this loading logic). 32 // deployment (and hence all uses of dart:mirrors from this loading logic).
33 // TODO(sigmund): fix polymer's transformers so they can replace initPolymer 33 // TODO(sigmund): fix polymer's transformers so they can replace initPolymer
34 // by initPolymerOptimized. 34 // by initPolymerOptimized.
35 if (_initializers == null) _initializers = _discoverInitializers(); 35 if (_initializers == null) _initializers = _discoverInitializers();
36 if (_useDirtyChecking) { 36
37 // In deployment mode, we rely on change notifiers instead of dirty checking.
38 if (!_deployMode) {
37 return dirtyCheckZone()..run(initPolymerOptimized); 39 return dirtyCheckZone()..run(initPolymerOptimized);
38 } 40 }
39 41
40 return initPolymerOptimized(); 42 return initPolymerOptimized();
41 } 43 }
42 44
43 /** 45 /**
44 * Same as [initPolymer], but runs the version that is optimized for deployment 46 * Same as [initPolymer], but runs the version that is optimized for deployment
45 * to the internet. The biggest difference is it omits the [Zone] that 47 * to the internet. The biggest difference is it omits the [Zone] that
46 * automatically invokes [Observable.dirtyCheck], and the list of initializers 48 * automatically invokes [Observable.dirtyCheck], and the list of initializers
(...skipping 20 matching lines...) Expand all
67 69
68 /** 70 /**
69 * Configures [initPolymer] making it optimized for deployment to the internet. 71 * Configures [initPolymer] making it optimized for deployment to the internet.
70 * With this setup the initializer list is supplied instead of being dynamically 72 * With this setup the initializer list is supplied instead of being dynamically
71 * searched for at runtime. Additionally, after this method is called, 73 * searched for at runtime. Additionally, after this method is called,
72 * [initPolymer] omits the [Zone] that automatically invokes 74 * [initPolymer] omits the [Zone] that automatically invokes
73 * [Observable.dirtyCheck]. 75 * [Observable.dirtyCheck].
74 */ 76 */
75 void configureForDeployment(List<Function> initializers) { 77 void configureForDeployment(List<Function> initializers) {
76 _initializers = initializers; 78 _initializers = initializers;
77 _useDirtyChecking = false; 79 _deployMode = true;
78 } 80 }
79 81
80 /** 82 /**
81 * List of initializers that by default will be executed when calling 83 * List of initializers that by default will be executed when calling
82 * initPolymer. If null, initPolymer will compute the list of initializers by 84 * initPolymer. If null, initPolymer will compute the list of initializers by
83 * crawling HTML imports, searchfing for script tags, and including an 85 * crawling HTML imports, searchfing for script tags, and including an
84 * initializer for each type tagged with a [CustomTag] annotation and for each 86 * initializer for each type tagged with a [CustomTag] annotation and for each
85 * top-level method annotated with [initMethod]. The value of this field is 87 * top-level method annotated with [initMethod]. The value of this field is
86 * assigned programatically by the code generated from the polymer deploy 88 * assigned programatically by the code generated from the polymer deploy
87 * scripts. 89 * scripts.
88 */ 90 */
89 List<Function> _initializers; 91 List<Function> _initializers;
90 92
91 bool _useDirtyChecking = true; 93 /** True if we're in deployment mode. */
94 bool _deployMode = false;
92 95
93 List<Function> _discoverInitializers() { 96 List<Function> _discoverInitializers() {
94 var initializers = []; 97 var initializers = [];
95 var librariesToLoad = _discoverScripts(document, window.location.href); 98 var librariesToLoad = _discoverScripts(document, window.location.href);
96 for (var lib in librariesToLoad) { 99 for (var lib in librariesToLoad) {
97 try { 100 try {
98 _loadLibrary(lib, initializers); 101 _loadLibrary(lib, initializers);
99 } catch (e, s) { 102 } catch (e, s) {
100 // Deliver errors async, so if a single library fails it doesn't prevent 103 // Deliver errors async, so if a single library fails it doesn't prevent
101 // other things from loading. 104 // other things from loading.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 print("warning: methods marked with @initMethod should take no " 238 print("warning: methods marked with @initMethod should take no "
236 "arguments, ${method.simpleName} expects some."); 239 "arguments, ${method.simpleName} expects some.");
237 return; 240 return;
238 } 241 }
239 initializers.add(() => obj.invoke(method.simpleName, const [])); 242 initializers.add(() => obj.invoke(method.simpleName, const []));
240 } 243 }
241 244
242 class _InitMethodAnnotation { 245 class _InitMethodAnnotation {
243 const _InitMethodAnnotation(); 246 const _InitMethodAnnotation();
244 } 247 }
OLDNEW
« no previous file with comments | « pkg/polymer/lib/src/instance.dart ('k') | pkg/polymer/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698