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

Unified Diff: sdk/lib/html/dartium/html_dartium.dart

Side-by-side diff isn't available for this file because of its large size.
Issue 23054006: for discussion: support for zones in DOM events (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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
« no previous file with comments | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | tests/html/events_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/dartium/html_dartium.dart
diff --git a/sdk/lib/html/dartium/html_dartium.dart b/sdk/lib/html/dartium/html_dartium.dart
index 8b25d5ab640e880fb09b432283c29e0cb0dc7366..f94bdec2d5c279b9aa8a8fe60fd5f6302a902fb8 100644
--- a/sdk/lib/html/dartium/html_dartium.dart
+++ b/sdk/lib/html/dartium/html_dartium.dart
@@ -30464,11 +30464,20 @@ class _EventStreamSubscription<T extends Event> extends StreamSubscription<T> {
var _onData;
final bool _useCapture;
- _EventStreamSubscription(this._target, this._eventType, this._onData,
- this._useCapture) {
+ _EventStreamSubscription(this._target, this._eventType, onData,
+ this._useCapture) : _onData = _wrapZone(onData) {
_tryResume();
}
+ static _wrapZone(callback) {
+ // For performance reasons, avoid wrapping if we are in the default zone.
+ final zone = currentZoneExperimental;
+ if (zone.isDefault) return callback;
+
+ zone.expectCallback();
+ return (e) => zone.executePeriodicCallbackGuarded(() => callback(e));
+ }
+
void cancel() {
if (_canceled) return;
@@ -30476,6 +30485,9 @@ class _EventStreamSubscription<T extends Event> extends StreamSubscription<T> {
// Clear out the target to indicate this is complete.
_target = null;
_onData = null;
+
+ final zone = currentZoneExperimental;
+ if (!zone.isDefault) zone.cancelCallbackExpectation();
}
bool get _canceled => _target == null;
@@ -30487,7 +30499,7 @@ class _EventStreamSubscription<T extends Event> extends StreamSubscription<T> {
// Remove current event listener.
_unlisten();
- _onData = handleData;
+ _onData = _wrapZone(handleData);
_tryResume();
}
« no previous file with comments | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | tests/html/events_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698