Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(484)

Unified Diff: sdk/lib/html/dart2js/html_dart2js.dart

Issue 12040059: Converting tests over to using event streams. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
Download patch
Index: sdk/lib/html/dart2js/html_dart2js.dart
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index 5f23f73f4410c3403af038d492cb1d0f74ac6257..e6bda27e866e88d3bb8236b5840415902b857433 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -1141,7 +1141,7 @@ class CanvasGradient native "*CanvasGradient" {
* var ctx = canvas.context2d;
* var img = new ImageElement();
* // Image src needs to be loaded before pattern is applied.
- * img.on.load.add((event) {
+ * img.onLoad.listen((event) {
* // When the image is loaded, create a pattern
* // from the ImageElement.
* CanvasPattern pattern = ctx.createPattern(img, 'repeat');
@@ -30002,9 +30002,8 @@ class KeyboardEventController {
// The distance to shift from upper case alphabet Roman letters to lower case.
final int _ROMAN_ALPHABET_OFFSET = "a".charCodes[0] - "A".charCodes[0];
- // Instance members referring to the internal event handlers because closures
- // are not hashable.
- var _keyUp, _keyDown, _keyPress;
+ StreamSubscription _keyUpSubscription, _keyDownSubscription,
+ _keyPressSubscription;
/**
* An enumeration of key identifiers currently part of the W3C draft for DOM3
@@ -30060,9 +30059,6 @@ class KeyboardEventController {
_callbacks = [];
_type = type;
_target = target;
- _keyDown = processKeyDown;
- _keyUp = processKeyUp;
- _keyPress = processKeyPress;
}
/**
@@ -30071,9 +30067,14 @@ class KeyboardEventController {
*/
void _initializeAllEventListeners() {
_keyDownList = [];
- _target.on.keyDown.add(_keyDown, true);
- _target.on.keyPress.add(_keyPress, true);
- _target.on.keyUp.add(_keyUp, true);
+ if (_keyDownSubscription == null) {
+ _keyDownSubscription = Element.keyDownEvent.forTarget(
+ _target, useCapture: true).listen(processKeyDown);
+ _keyPressSubscription = Element.keyPressEvent.forTarget(
+ _target, useCapture: true).listen(processKeyUp);
+ _keyUpSubscription = Element.keyUpEvent.forTarget(
+ _target, useCapture: true).listen(processKeyPress);
+ }
}
/** Add a callback that wishes to be notified when a KeyEvent occurs. */
@@ -30107,9 +30108,12 @@ class KeyboardEventController {
}
if (_callbacks.length == 0) {
// If we have no listeners, don't bother keeping track of keypresses.
- _target.on.keyDown.remove(_keyDown);
- _target.on.keyPress.remove(_keyPress);
- _target.on.keyUp.remove(_keyUp);
+ _keyDownSubscription.cancel();
+ _keyDownSubscription = null;
+ _keyPressSubscription.cancel();
+ _keyPressSubscription = null;
+ _keyUpSubscription.cancel();
+ _keyUpSubscription = null;
}
}
@@ -31206,7 +31210,7 @@ class _HttpRequestUtils {
request.withCredentials = withCredentials;
- request.on.readyStateChange.add((e) {
+ request.onReadyStateChange.listen((e) {
if (request.readyState == HttpRequest.DONE) {
onComplete(request);
}
@@ -32365,26 +32369,6 @@ class _TypedArrayFactoryProvider {
// copies the list.
static ensureNative(List list) => list; // TODO: make sure.
}
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-
-// TODO(rnystrom): add a way to supress public classes from DartDoc output.
-// TODO(jacobr): we can remove this class now that we are using the $dom_
-// convention for deprecated methods rather than truly private methods.
-/**
- * This class is intended for testing purposes only.
- */
-class Testing {
- static void addEventListener(EventTarget target, String type, EventListener listener, bool useCapture) {
- target.$dom_addEventListener(type, listener, useCapture);
- }
- static void removeEventListener(EventTarget target, String type, EventListener listener, bool useCapture) {
- target.$dom_removeEventListener(type, listener, useCapture);
- }
-
-}
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

Powered by Google App Engine
This is Rietveld 408576698