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

Side by Side Diff: tools/dom/templates/html/dart2js/impl_Window.darttemplate

Issue 12212200: "Reverting 18531" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | « tools/dom/src/Timer.dart ('k') | tools/dom/templates/html/dartium/impl_Window.darttemplate » ('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) 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 part of $LIBRARYNAME; 5 part of $LIBRARYNAME;
6 6
7 $if DART2JS
8 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS native "@*DOMWindow" { 7 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS native "@*DOMWindow" {
9 $else
10 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
11 $endif
12 8
13 /**
14 * Executes a [callback] after the immediate execution stack has completed.
15 *
16 * This differs from using Timer.run(callback)
17 * because Timer will run in about 4-15 milliseconds, depending on browser,
18 * depending on load. [setImmediate], in contrast, makes browser-specific
19 * changes in behavior to attempt to run immediately after the current
20 * frame unwinds, causing the future to complete after all processing has
21 * completed for the current event, but before any subsequent events.
22 */
23 void setImmediate(TimeoutHandler callback) {
24 _addMicrotaskCallback(callback);
25 }
26 /**
27 * Lookup a port by its [name]. Return null if no port is
28 * registered under [name].
29 */
30 SendPortSync lookupPort(String name) {
31 var port =
32 json.parse(document.documentElement.attributes['dart-port:$name']);
33 return _deserialize(port);
34 }
35
36 /**
37 * Register a [port] on this window under the given [name]. This
38 * port may be retrieved by any isolate (or JavaScript script)
39 * running in this window.
40 */
41 void registerPort(String name, var port) {
42 var serialized = _serialize(port);
43 document.documentElement.attributes['dart-port:$name'] =
44 json.stringify(serialized);
45 }
46
47 /**
48 * Returns a Future that completes just before the window is about to repaint
49 * so the user can draw an animation frame
50 *
51 * If you need to later cancel this animation, use [requestAnimationFrame]
52 * instead.
53 *
54 * Note: The code that runs when the future completes should call
55 * [animationFrame] again for the animation to continue.
56 */
57 Future<num> get animationFrame {
58 var completer = new Completer<int>();
59 requestAnimationFrame(completer.complete);
60 return completer.future;
61 }
62
63 $if DART2JS
64 Document get document => JS('Document', '#.document', this); 9 Document get document => JS('Document', '#.document', this);
65 10
66 WindowBase _open2(url, name) => JS('Window', '#.open(#,#)', this, url, name); 11 WindowBase _open2(url, name) => JS('Window', '#.open(#,#)', this, url, name);
67 12
68 WindowBase _open3(url, name, options) => 13 WindowBase _open3(url, name, options) =>
69 JS('Window', '#.open(#,#,#)', this, url, name, options); 14 JS('Window', '#.open(#,#,#)', this, url, name, options);
70 15
71 WindowBase open(String url, String name, [String options]) { 16 WindowBase open(String url, String name, [String options]) {
72 if (options == null) { 17 if (options == null) {
73 return _DOMWindowCrossFrame._createSafe(_open2(url, name)); 18 return _DOMWindowCrossFrame._createSafe(_open2(url, name));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // On Firefox the code that implements 'is Location' fails to find the patch 64 // On Firefox the code that implements 'is Location' fails to find the patch
120 // stub on Object.prototype and throws an exception. 65 // stub on Object.prototype and throws an exception.
121 try { 66 try {
122 return thing is Location; 67 return thing is Location;
123 } catch (e) { 68 } catch (e) {
124 return false; 69 return false;
125 } 70 }
126 } 71 }
127 72
128 /** 73 /**
129 * Called to draw an animation frame and then request the window to repaint 74 * Executes a [callback] after the immediate execution stack has completed.
130 * after [callback] has finished (creating the animation).
131 * 75 *
132 * Use this method only if you need to later call [cancelAnimationFrame]. If 76 * This will cause the callback to be executed after all processing has
133 * not, the preferred Dart idiom is to set animation frames by calling 77 * completed for the current event, but before any subsequent events.
134 * [animationFrame], which returns a Future.
135 *
136 * Returns a non-zero valued integer to represent the request id for this
137 * request. This value only needs to be saved if you intend to call
138 * [cancelAnimationFrame] so you can specify the particular animation to
139 * cancel.
140 *
141 * Note: The supplied [callback] needs to call [requestAnimationFrame] again
142 * for the animation to continue.
143 */ 78 */
79 void setImmediate(TimeoutHandler callback) {
80 _addMicrotaskCallback(callback);
81 }
82
144 @DomName('DOMWindow.requestAnimationFrame') 83 @DomName('DOMWindow.requestAnimationFrame')
145 int requestAnimationFrame(RequestAnimationFrameCallback callback) { 84 int requestAnimationFrame(RequestAnimationFrameCallback callback) {
146 _ensureRequestAnimationFrame(); 85 _ensureRequestAnimationFrame();
147 return _requestAnimationFrame(callback); 86 return _requestAnimationFrame(callback);
148 } 87 }
149 88
150 void cancelAnimationFrame(id) { 89 void cancelAnimationFrame(id) {
151 _ensureRequestAnimationFrame(); 90 _ensureRequestAnimationFrame();
152 _cancelAnimationFrame(id); 91 _cancelAnimationFrame(id);
153 } 92 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 */ 131 */
193 @SupportedBrowser(SupportedBrowser.CHROME, '23.0') 132 @SupportedBrowser(SupportedBrowser.CHROME, '23.0')
194 @SupportedBrowser(SupportedBrowser.FIREFOX, '15.0') 133 @SupportedBrowser(SupportedBrowser.FIREFOX, '15.0')
195 @SupportedBrowser(SupportedBrowser.IE, '10.0') 134 @SupportedBrowser(SupportedBrowser.IE, '10.0')
196 @Experimental 135 @Experimental
197 IdbFactory get indexedDB => 136 IdbFactory get indexedDB =>
198 JS('IdbFactory', 137 JS('IdbFactory',
199 '#.indexedDB || #.webkitIndexedDB || #.mozIndexedDB', 138 '#.indexedDB || #.webkitIndexedDB || #.mozIndexedDB',
200 this, this, this); 139 this, this, this);
201 140
141 /**
142 * Lookup a port by its [name]. Return null if no port is
143 * registered under [name].
144 */
145 SendPortSync lookupPort(String name) {
146 var port = json.parse(document.documentElement.attributes['dart-port:$name'] );
147 return _deserialize(port);
148 }
149
150 /**
151 * Register a [port] on this window under the given [name]. This
152 * port may be retrieved by any isolate (or JavaScript script)
153 * running in this window.
154 */
155 void registerPort(String name, var port) {
156 var serialized = _serialize(port);
157 document.documentElement.attributes['dart-port:$name'] = json.stringify(seri alized);
158 }
159
202 @DomName('Window.console') 160 @DomName('Window.console')
203 Console get console => Console.safeConsole; 161 Console get console => Console.safeConsole;
204 162
205 /// Checks if _setImmediate is supported. 163 /// Checks if _setImmediate is supported.
206 static bool get _supportsSetImmediate => 164 static bool get _supportsSetImmediate =>
207 JS('bool', '!!(window.setImmediate)'); 165 JS('bool', '!!(window.setImmediate)');
208 166
209 // Set immediate implementation for IE 167 // Set immediate implementation for IE
210 void _setImmediate(void callback()) { 168 void _setImmediate(void callback()) {
211 JS('void', '#.setImmediate(#)', this, convertDartClosureToJS(callback, 0)); 169 JS('void', '#.setImmediate(#)', this, convertDartClosureToJS(callback, 0));
212 } 170 }
213 $else
214 /// Checks if _setImmediate is supported.
215 static bool get _supportsSetImmediate => false;
216
217 /// Dartium stub for IE's setImmediate.
218 void _setImmediate(void callback()) {
219 throw new UnsupportedError('setImmediate is not supported');
220 }
221 $endif
222 171
223 $!MEMBERS 172 $!MEMBERS
224 } 173 }
OLDNEW
« no previous file with comments | « tools/dom/src/Timer.dart ('k') | tools/dom/templates/html/dartium/impl_Window.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698