OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart.dom.html; | 5 part of dart.dom.html; |
6 | 6 |
7 ZoneUnaryCallback/*<R, T>*/ _registerZone/*<R, T>*/(Zone zone, | 7 // TODO(jacobr): remove these typedefs when dart:async supports generic types. |
8 ZoneUnaryCallback/*<R, T>*/ callback) { | 8 typedef R _wrapZoneCallback<A, R>(A a); |
9 // For performance reasons avoid registering if we are in the root zone. | 9 typedef R _wrapZoneBinaryCallback<A, B, R>(A a, B b); |
10 if (identical(zone, Zone.ROOT)) return callback; | 10 |
| 11 _wrapZoneCallback/*<A, R>*/ _wrapZone/*<A, R>*/(_wrapZoneCallback/*<A, R>*/ call
back) { |
| 12 // For performance reasons avoid wrapping if we are in the root zone. |
| 13 if (Zone.current == Zone.ROOT) return callback; |
11 if (callback == null) return null; | 14 if (callback == null) return null; |
12 return zone.registerUnaryCallback(callback); | 15 // TODO(jacobr): we cast to _wrapZoneCallback/*<A, R>*/ to hack around missing |
| 16 // generic method support in zones. |
| 17 // ignore: STRONG_MODE_DOWN_CAST_COMPOSITE |
| 18 _wrapZoneCallback/*<A, R>*/ wrapped = |
| 19 Zone.current.bindUnaryCallback(callback, runGuarded: true); |
| 20 return wrapped; |
13 } | 21 } |
14 | 22 |
15 ZoneUnaryCallback/*<R, T>*/ _wrapZone/*<R, T>*/(ZoneUnaryCallback/*<R, T>*/ call
back) { | 23 _wrapZoneBinaryCallback/*<A, B, R>*/ _wrapBinaryZone/*<A, B, R>*/(_wrapZoneBinar
yCallback/*<A, B, R>*/ callback) { |
16 // For performance reasons avoid wrapping if we are in the root zone. | 24 if (Zone.current == Zone.ROOT) return callback; |
17 if (identical(Zone.current, Zone.ROOT)) return callback; | |
18 if (callback == null) return null; | 25 if (callback == null) return null; |
19 return Zone.current.bindUnaryCallback(callback, runGuarded: true); | 26 // We cast to _wrapZoneBinaryCallback/*<A, B, R>*/ to hack around missing |
20 } | 27 // generic method support in zones. |
21 | 28 // ignore: STRONG_MODE_DOWN_CAST_COMPOSITE |
22 ZoneBinaryCallback/*<R, A, B>*/ _wrapBinaryZone/*<R, A, B>*/( | 29 _wrapZoneBinaryCallback/*<A, B, R>*/ wrapped = |
23 ZoneBinaryCallback/*<R, A, B>*/ callback) { | 30 Zone.current.bindBinaryCallback(callback, runGuarded: true); |
24 if (identical(Zone.current, Zone.ROOT)) return callback; | 31 return wrapped; |
25 if (callback == null) return null; | |
26 return Zone.current.bindBinaryCallback(callback, runGuarded: true); | |
27 } | 32 } |
28 | 33 |
29 /** | 34 /** |
30 * Alias for [querySelector]. Note this function is deprecated because its | 35 * Alias for [querySelector]. Note this function is deprecated because its |
31 * semantics will be changing in the future. | 36 * semantics will be changing in the future. |
32 */ | 37 */ |
33 @deprecated | 38 @deprecated |
34 @Experimental() | 39 @Experimental() |
35 Element query(String relativeSelectors) => document.query(relativeSelectors); | 40 Element query(String relativeSelectors) => document.query(relativeSelectors); |
36 /** | 41 /** |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 ElementList<Element> querySelectorAll(String selectors) => document.querySelecto
rAll(selectors); | 84 ElementList<Element> querySelectorAll(String selectors) => document.querySelecto
rAll(selectors); |
80 | 85 |
81 /// A utility for changing the Dart wrapper type for elements. | 86 /// A utility for changing the Dart wrapper type for elements. |
82 abstract class ElementUpgrader { | 87 abstract class ElementUpgrader { |
83 /// Upgrade the specified element to be of the Dart type this was created for. | 88 /// Upgrade the specified element to be of the Dart type this was created for. |
84 /// | 89 /// |
85 /// After upgrading the element passed in is invalid and the returned value | 90 /// After upgrading the element passed in is invalid and the returned value |
86 /// should be used instead. | 91 /// should be used instead. |
87 Element upgrade(Element element); | 92 Element upgrade(Element element); |
88 } | 93 } |
OLD | NEW |