| 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 html; | 5 part of html; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Adapter for exposing DOM events as Dart streams. | 8 * Adapter for exposing DOM events as Dart streams. |
| 9 */ | 9 */ |
| 10 class _EventStream<T extends Event> extends Stream<T> { | 10 class _EventStream<T extends Event> extends Stream<T> { |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 bool get isPaused => _pauseCount > 0; | 276 bool get isPaused => _pauseCount > 0; |
| 277 | 277 |
| 278 void resume() { | 278 void resume() { |
| 279 if (_canceled || !isPaused) return; | 279 if (_canceled || !isPaused) return; |
| 280 --_pauseCount; | 280 --_pauseCount; |
| 281 _tryResume(); | 281 _tryResume(); |
| 282 } | 282 } |
| 283 | 283 |
| 284 void _tryResume() { | 284 void _tryResume() { |
| 285 if (_onData != null && !isPaused) { | 285 if (_onData != null && !isPaused) { |
| 286 _target.$dom_addEventListener(_eventType, _onData, _useCapture); | 286 _target._addEventListener(_eventType, _onData, _useCapture); |
| 287 } | 287 } |
| 288 } | 288 } |
| 289 | 289 |
| 290 void _unlisten() { | 290 void _unlisten() { |
| 291 if (_onData != null) { | 291 if (_onData != null) { |
| 292 _target.$dom_removeEventListener(_eventType, _onData, _useCapture); | 292 _target._removeEventListener(_eventType, _onData, _useCapture); |
| 293 } | 293 } |
| 294 } | 294 } |
| 295 | 295 |
| 296 Future asFuture([var futureValue]) { | 296 Future asFuture([var futureValue]) { |
| 297 // We just need a future that will never succeed or fail. | 297 // We just need a future that will never succeed or fail. |
| 298 Completer completer = new Completer(); | 298 Completer completer = new Completer(); |
| 299 return completer.future; | 299 return completer.future; |
| 300 } | 300 } |
| 301 } | 301 } |
| 302 | 302 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 | 397 |
| 398 ElementStream<T> _forElementList(ElementList e, | 398 ElementStream<T> _forElementList(ElementList e, |
| 399 {bool useCapture: false}) { | 399 {bool useCapture: false}) { |
| 400 return new _ElementListEventStreamImpl(e, _eventTypeGetter(e), useCapture); | 400 return new _ElementListEventStreamImpl(e, _eventTypeGetter(e), useCapture); |
| 401 } | 401 } |
| 402 | 402 |
| 403 String getEventType(EventTarget target) { | 403 String getEventType(EventTarget target) { |
| 404 return _eventTypeGetter(target); | 404 return _eventTypeGetter(target); |
| 405 } | 405 } |
| 406 } | 406 } |
| OLD | NEW |