| 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 4e98af251e4416ec0072eddebdb214bc94dea1db..ee2a1678f418b466f81e40297184446869271178 100644
|
| --- a/sdk/lib/html/dart2js/html_dart2js.dart
|
| +++ b/sdk/lib/html/dart2js/html_dart2js.dart
|
| @@ -28378,11 +28378,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;
|
|
|
| @@ -28390,6 +28399,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;
|
| @@ -28401,7 +28413,7 @@ class _EventStreamSubscription<T extends Event> extends StreamSubscription<T> {
|
| // Remove current event listener.
|
| _unlisten();
|
|
|
| - _onData = handleData;
|
| + _onData = _wrapZone(handleData);
|
| _tryResume();
|
| }
|
|
|
|
|