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 * Lookup a port by its [name]. Return null if no port is | |
16 * registered under [name]. | |
17 */ | |
18 SendPortSync lookupPort(String name) { | |
19 var portStr = document.documentElement.attributes['dart-port:$name']; | |
20 if (portStr == null) { | |
21 return null; | |
22 } | |
23 var port = JSON.decode(portStr); | |
24 return _deserialize(port); | |
25 } | |
26 | |
27 /** | |
28 * Register a [port] on this window under the given [name]. This | |
29 * port may be retrieved by any isolate (or JavaScript script) | |
30 * running in this window. | |
31 */ | |
32 void registerPort(String name, var port) { | |
33 var serialized = _serialize(port); | |
34 document.documentElement.attributes['dart-port:$name'] = | |
35 JSON.encode(serialized); | |
36 } | |
37 | |
38 /** | |
39 * Deregister a [port] on this window under the given [name]. This | |
40 * port may be retrieved by any isolate (or JavaScript script) | |
41 * running in this window. | |
42 */ | |
43 void deregisterPort(String name) { | |
44 document.documentElement.attributes.remove('dart-port:$name'); | |
45 } | |
46 | |
47 /** | |
48 * Returns a Future that completes just before the window is about to | 15 * Returns a Future that completes just before the window is about to |
49 * repaint so the user can draw an animation frame. | 16 * repaint so the user can draw an animation frame. |
50 * | 17 * |
51 * If you need to later cancel this animation, use [requestAnimationFrame] | 18 * If you need to later cancel this animation, use [requestAnimationFrame] |
52 * instead. | 19 * instead. |
53 * | 20 * |
54 * The [Future] completes to a timestamp that represents a floating | 21 * The [Future] completes to a timestamp that represents a floating |
55 * point value of the number of milliseconds that have elapsed since the page | 22 * point value of the number of milliseconds that have elapsed since the page |
56 * started to load (which is also the timestamp at this call to | 23 * started to load (which is also the timestamp at this call to |
57 * animationFrame). | 24 * animationFrame). |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 return controller.stream; | 303 return controller.stream; |
337 $else | 304 $else |
338 return stream; | 305 return stream; |
339 $endif | 306 $endif |
340 } | 307 } |
341 | 308 |
342 String getEventType(EventTarget target) { | 309 String getEventType(EventTarget target) { |
343 return _eventType; | 310 return _eventType; |
344 } | 311 } |
345 } | 312 } |
OLD | NEW |