Chromium Code Reviews| 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 200 bool get isPaused => _pauseCount > 0; | 200 bool get isPaused => _pauseCount > 0; |
| 201 | 201 |
| 202 void resume() { | 202 void resume() { |
| 203 if (_canceled || !isPaused) return; | 203 if (_canceled || !isPaused) return; |
| 204 --_pauseCount; | 204 --_pauseCount; |
| 205 _tryResume(); | 205 _tryResume(); |
| 206 } | 206 } |
| 207 | 207 |
| 208 void _tryResume() { | 208 void _tryResume() { |
| 209 if (_onData != null && !isPaused) { | 209 if (_onData != null && !isPaused) { |
| 210 _target.$dom_addEventListener(_eventType, _onData, _useCapture); | 210 _target._addEventListener(_eventType, _onData, _useCapture); |
|
blois
2013/08/22 20:42:23
As much as I'd like this one made private, it seem
Emily Fortuna
2013/08/22 22:10:10
Done.
| |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 | 213 |
| 214 void _unlisten() { | 214 void _unlisten() { |
| 215 if (_onData != null) { | 215 if (_onData != null) { |
| 216 _target.$dom_removeEventListener(_eventType, _onData, _useCapture); | 216 _target._removeEventListener(_eventType, _onData, _useCapture); |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 | 219 |
| 220 Future asFuture([var futureValue]) { | 220 Future asFuture([var futureValue]) { |
| 221 // We just need a future that will never succeed or fail. | 221 // We just need a future that will never succeed or fail. |
| 222 Completer completer = new Completer(); | 222 Completer completer = new Completer(); |
| 223 return completer.future; | 223 return completer.future; |
| 224 } | 224 } |
| 225 } | 225 } |
| 226 | 226 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 | 321 |
| 322 ElementStream<T> _forElementList(ElementList e, | 322 ElementStream<T> _forElementList(ElementList e, |
| 323 {bool useCapture: false}) { | 323 {bool useCapture: false}) { |
| 324 return new _ElementListEventStreamImpl(e, _eventTypeGetter(e), useCapture); | 324 return new _ElementListEventStreamImpl(e, _eventTypeGetter(e), useCapture); |
| 325 } | 325 } |
| 326 | 326 |
| 327 String getEventType(EventTarget target) { | 327 String getEventType(EventTarget target) { |
| 328 return _eventTypeGetter(target); | 328 return _eventTypeGetter(target); |
| 329 } | 329 } |
| 330 } | 330 } |
| OLD | NEW |