| OLD | NEW |
| 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 @DocsEditable | 7 @DocsEditable |
| 8 $if DART2JS | 8 $if DART2JS |
| 9 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS native "Wind
ow,DOMWindow" { | 9 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS native "Wind
ow,DOMWindow" { |
| 10 $else | 10 $else |
| 11 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 11 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
| 12 $endif | 12 $endif |
| 13 | 13 |
| 14 /** | 14 /** |
| 15 * Executes a [callback] after the immediate execution stack has completed. |
| 16 * |
| 17 * This differs from using Timer.run(callback) |
| 18 * because Timer will run in about 4-15 milliseconds, depending on browser, |
| 19 * depending on load. [setImmediate], in contrast, makes browser-specific |
| 20 * changes in behavior to attempt to run immediately after the current |
| 21 * frame unwinds, causing the future to complete after all processing has |
| 22 * completed for the current event, but before any subsequent events. |
| 23 */ |
| 24 void setImmediate(TimeoutHandler callback) { |
| 25 _addMicrotaskCallback(callback); |
| 26 } |
| 27 /** |
| 15 * Lookup a port by its [name]. Return null if no port is | 28 * Lookup a port by its [name]. Return null if no port is |
| 16 * registered under [name]. | 29 * registered under [name]. |
| 17 */ | 30 */ |
| 18 SendPortSync lookupPort(String name) { | 31 SendPortSync lookupPort(String name) { |
| 19 var portStr = document.documentElement.attributes['dart-port:$name']; | 32 var portStr = document.documentElement.attributes['dart-port:$name']; |
| 20 if (portStr == null) { | 33 if (portStr == null) { |
| 21 return null; | 34 return null; |
| 22 } | 35 } |
| 23 var port = JSON.decode(portStr); | 36 var port = JSON.decode(portStr); |
| 24 return _deserialize(port); | 37 return _deserialize(port); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 @SupportedBrowser(SupportedBrowser.FIREFOX, '15.0') | 214 @SupportedBrowser(SupportedBrowser.FIREFOX, '15.0') |
| 202 @SupportedBrowser(SupportedBrowser.IE, '10.0') | 215 @SupportedBrowser(SupportedBrowser.IE, '10.0') |
| 203 @Experimental() | 216 @Experimental() |
| 204 IdbFactory get indexedDB => | 217 IdbFactory get indexedDB => |
| 205 JS('IdbFactory|Null', // If not supported, returns `null`. | 218 JS('IdbFactory|Null', // If not supported, returns `null`. |
| 206 '#.indexedDB || #.webkitIndexedDB || #.mozIndexedDB', | 219 '#.indexedDB || #.webkitIndexedDB || #.mozIndexedDB', |
| 207 this, this, this); | 220 this, this, this); |
| 208 | 221 |
| 209 @DomName('Window.console') | 222 @DomName('Window.console') |
| 210 Console get console => Console._safeConsole; | 223 Console get console => Console._safeConsole; |
| 224 |
| 225 /// Checks if _setImmediate is supported. |
| 226 static bool get _supportsSetImmediate => |
| 227 JS('bool', '!!(window.setImmediate)'); |
| 228 |
| 229 // Set immediate implementation for IE |
| 230 void _setImmediate(void callback()) { |
| 231 JS('void', '#.setImmediate(#)', this, convertDartClosureToJS(callback, 0)); |
| 232 } |
| 233 $else |
| 234 /// Checks if _setImmediate is supported. |
| 235 static bool get _supportsSetImmediate => false; |
| 236 |
| 237 /// Dartium stub for IE's setImmediate. |
| 238 void _setImmediate(void callback()) { |
| 239 throw new UnsupportedError('setImmediate is not supported'); |
| 240 } |
| 241 |
| 242 /** |
| 243 * Called to draw an animation frame and then request the window to repaint |
| 244 * after [callback] has finished (creating the animation). |
| 245 * |
| 246 * Use this method only if you need to later call [cancelAnimationFrame]. If |
| 247 * not, the preferred Dart idiom is to set animation frames by calling |
| 248 * [animationFrame], which returns a Future. |
| 249 * |
| 250 * Returns a non-zero valued integer to represent the request id for this |
| 251 * request. This value only needs to be saved if you intend to call |
| 252 * [cancelAnimationFrame] so you can specify the particular animation to |
| 253 * cancel. |
| 254 * |
| 255 * Note: The supplied [callback] needs to call [requestAnimationFrame] again |
| 256 * for the animation to continue. |
| 257 */ |
| 258 @DomName('Window.requestAnimationFrame') |
| 259 int requestAnimationFrame(RequestAnimationFrameCallback callback) { |
| 260 return _requestAnimationFrame(_wrapZone(callback)); |
| 261 } |
| 211 $endif | 262 $endif |
| 212 | 263 |
| 213 /** | 264 /** |
| 214 * Access a sandboxed file system of the specified `size`. If `persistent` is | 265 * Access a sandboxed file system of the specified `size`. If `persistent` is |
| 215 * true, the application will request permission from the user to create | 266 * true, the application will request permission from the user to create |
| 216 * lasting storage. This storage cannot be freed without the user's | 267 * lasting storage. This storage cannot be freed without the user's |
| 217 * permission. Returns a [Future] whose value stores a reference to the | 268 * permission. Returns a [Future] whose value stores a reference to the |
| 218 * sandboxed file system for use. Because the file system is sandboxed, | 269 * sandboxed file system for use. Because the file system is sandboxed, |
| 219 * applications cannot access file systems created in other web pages. | 270 * applications cannot access file systems created in other web pages. |
| 220 */ | 271 */ |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 return wrapped.returnValue; | 370 return wrapped.returnValue; |
| 320 }); | 371 }); |
| 321 | 372 |
| 322 return controller.stream; | 373 return controller.stream; |
| 323 } | 374 } |
| 324 | 375 |
| 325 String getEventType(EventTarget target) { | 376 String getEventType(EventTarget target) { |
| 326 return _eventType; | 377 return _eventType; |
| 327 } | 378 } |
| 328 } | 379 } |
| OLD | NEW |