| 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 $if DART2JS | 7 $if DART2JS |
| 8 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS native "Wind
ow,DOMWindow" { | 8 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS native "Window,DOMWindow" { |
| 9 $else | 9 $else |
| 10 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 10 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
| 11 $endif | 11 $endif |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * Executes a [callback] after the immediate execution stack has completed. | 14 * Executes a [callback] after the immediate execution stack has completed. |
| 15 * | 15 * |
| 16 * This differs from using Timer.run(callback) | 16 * This differs from using Timer.run(callback) |
| 17 * because Timer will run in about 4-15 milliseconds, depending on browser, | 17 * because Timer will run in about 4-15 milliseconds, depending on browser, |
| 18 * depending on load. [setImmediate], in contrast, makes browser-specific | 18 * depending on load. [setImmediate], in contrast, makes browser-specific |
| 19 * changes in behavior to attempt to run immediately after the current | 19 * changes in behavior to attempt to run immediately after the current |
| 20 * frame unwinds, causing the future to complete after all processing has | 20 * frame unwinds, causing the future to complete after all processing has |
| (...skipping 20 matching lines...) Expand all Loading... |
| 41 * port may be retrieved by any isolate (or JavaScript script) | 41 * port may be retrieved by any isolate (or JavaScript script) |
| 42 * running in this window. | 42 * running in this window. |
| 43 */ | 43 */ |
| 44 void registerPort(String name, var port) { | 44 void registerPort(String name, var port) { |
| 45 var serialized = _serialize(port); | 45 var serialized = _serialize(port); |
| 46 document.documentElement.attributes['dart-port:$name'] = | 46 document.documentElement.attributes['dart-port:$name'] = |
| 47 json.stringify(serialized); | 47 json.stringify(serialized); |
| 48 } | 48 } |
| 49 | 49 |
| 50 /** | 50 /** |
| 51 * Returns a Future that completes just before the window is about to | 51 * Returns a Future that completes just before the window is about to |
| 52 * repaint so the user can draw an animation frame. | 52 * repaint so the user can draw an animation frame. |
| 53 * | 53 * |
| 54 * If you need to later cancel this animation, use [requestAnimationFrame] | 54 * If you need to later cancel this animation, use [requestAnimationFrame] |
| 55 * instead. | 55 * instead. |
| 56 * | 56 * |
| 57 * The [Future] completes to a timestamp that represents a floating | 57 * The [Future] completes to a timestamp that represents a floating |
| 58 * point value of the number of milliseconds that have elapsed since the page | 58 * point value of the number of milliseconds that have elapsed since the page |
| 59 * started to load (which is also the timestamp at this call to | 59 * started to load (which is also the timestamp at this call to |
| 60 * animationFrame). | 60 * animationFrame). |
| 61 * | 61 * |
| 62 * Note: The code that runs when the future completes should call | 62 * Note: The code that runs when the future completes should call |
| 63 * [animationFrame] again for the animation to continue. | 63 * [animationFrame] again for the animation to continue. |
| 64 */ | 64 */ |
| 65 Future<num> get animationFrame { | 65 Future<num> get animationFrame { |
| 66 var completer = new Completer<num>(); | 66 var completer = new Completer<num>(); |
| 67 requestAnimationFrame((time) { | 67 requestAnimationFrame((time) { |
| 68 completer.complete(time); | 68 completer.complete(time); |
| 69 }); | 69 }); |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 return wrapped.returnValue; | 328 return wrapped.returnValue; |
| 329 }); | 329 }); |
| 330 | 330 |
| 331 return controller.stream; | 331 return controller.stream; |
| 332 } | 332 } |
| 333 | 333 |
| 334 String getEventType(EventTarget target) { | 334 String getEventType(EventTarget target) { |
| 335 return _eventType; | 335 return _eventType; |
| 336 } | 336 } |
| 337 } | 337 } |
| OLD | NEW |