| 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 $CLASSNAME$EXTENDS$IMPLEMENTS native "Window,DOMWindow" { | 8 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS native "Window,DOMWindow" { |
| 9 $else | 9 $else |
| 10 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 10 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
| (...skipping 30 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 repaint | 51 * Returns a Future that completes just before the window is about to |
| 52 * 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 |
| 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 |
| 60 * animationFrame). |
| 61 * |
| 57 * Note: The code that runs when the future completes should call | 62 * Note: The code that runs when the future completes should call |
| 58 * [animationFrame] again for the animation to continue. | 63 * [animationFrame] again for the animation to continue. |
| 59 */ | 64 */ |
| 60 Future<num> get animationFrame { | 65 Future<num> get animationFrame { |
| 61 var completer = new Completer<num>(); | 66 var completer = new Completer<num>(); |
| 62 requestAnimationFrame((time) { | 67 requestAnimationFrame((time) { |
| 63 completer.complete(time); | 68 completer.complete(time); |
| 64 }); | 69 }); |
| 65 return completer.future; | 70 return completer.future; |
| 66 } | 71 } |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 return wrapped.returnValue; | 328 return wrapped.returnValue; |
| 324 }); | 329 }); |
| 325 | 330 |
| 326 return controller.stream; | 331 return controller.stream; |
| 327 } | 332 } |
| 328 | 333 |
| 329 String getEventType(EventTarget target) { | 334 String getEventType(EventTarget target) { |
| 330 return _eventType; | 335 return _eventType; |
| 331 } | 336 } |
| 332 } | 337 } |
| OLD | NEW |