OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
6 | 6 |
7 @DocsEditable() | 7 @DocsEditable() |
8 $if DART2JS | 8 $if DART2JS |
9 $(ANNOTATIONS)@Native("Window,DOMWindow") | 9 $(ANNOTATIONS)@Native("Window,DOMWindow") |
10 $(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS { | 10 $(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS { |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 } | 332 } |
333 $endif | 333 $endif |
334 | 334 |
335 class _BeforeUnloadEventStreamProvider implements | 335 class _BeforeUnloadEventStreamProvider implements |
336 EventStreamProvider<BeforeUnloadEvent> { | 336 EventStreamProvider<BeforeUnloadEvent> { |
337 final String _eventType; | 337 final String _eventType; |
338 | 338 |
339 const _BeforeUnloadEventStreamProvider(this._eventType); | 339 const _BeforeUnloadEventStreamProvider(this._eventType); |
340 | 340 |
341 Stream<BeforeUnloadEvent> forTarget(EventTarget e, {bool useCapture: false}) { | 341 Stream<BeforeUnloadEvent> forTarget(EventTarget e, {bool useCapture: false}) { |
342 var stream = new _EventStream(e, _eventType, useCapture); | |
343 $if DART2JS | 342 $if DART2JS |
| 343 // Specify the generic type for EventStream only in dart2js to avoid |
| 344 // checked mode errors in dartium. |
| 345 var stream = new _EventStream<BeforeUnloadEvent>(e, _eventType, useCapture); |
344 var controller = new StreamController<BeforeUnloadEvent>(sync: true); | 346 var controller = new StreamController<BeforeUnloadEvent>(sync: true); |
345 | 347 |
346 stream.listen((event) { | 348 stream.listen((event) { |
347 var wrapped = new _BeforeUnloadEvent(event); | 349 var wrapped = new _BeforeUnloadEvent(event); |
348 controller.add(wrapped); | 350 controller.add(wrapped); |
349 }); | 351 }); |
350 | 352 |
351 return controller.stream; | 353 return controller.stream; |
352 $else | 354 $else |
| 355 var stream = new _EventStream(e, _eventType, useCapture); |
353 return stream; | 356 return stream; |
354 $endif | 357 $endif |
355 } | 358 } |
356 | 359 |
357 String getEventType(EventTarget target) { | 360 String getEventType(EventTarget target) { |
358 return _eventType; | 361 return _eventType; |
359 } | 362 } |
360 | 363 |
361 ElementStream<BeforeUnloadEvent> forElement(Element e, {bool useCapture: false
}) { | 364 ElementStream<BeforeUnloadEvent> forElement(Element e, {bool useCapture: false
}) { |
| 365 $if DART2JS |
| 366 // Specify the generic type for _ElementEventStreamImpl only in dart2js to |
| 367 // avoid checked mode errors in dartium. |
| 368 return new _ElementEventStreamImpl<BeforeUnloadEvent>(e, _eventType, useCapt
ure); |
| 369 $else |
362 return new _ElementEventStreamImpl(e, _eventType, useCapture); | 370 return new _ElementEventStreamImpl(e, _eventType, useCapture); |
| 371 $endif |
363 } | 372 } |
364 | 373 |
365 ElementStream<BeforeUnloadEvent> _forElementList(ElementList e, | 374 ElementStream<BeforeUnloadEvent> _forElementList(ElementList e, |
366 {bool useCapture: false}) { | 375 {bool useCapture: false}) { |
| 376 $if DART2JS |
| 377 // Specify the generic type for _ElementEventStreamImpl only in dart2js to |
| 378 // avoid checked mode errors in dartium. |
| 379 return new _ElementListEventStreamImpl<BeforeUnloadEvent>(e, _eventType, use
Capture); |
| 380 $else |
367 return new _ElementListEventStreamImpl(e, _eventType, useCapture); | 381 return new _ElementListEventStreamImpl(e, _eventType, useCapture); |
| 382 $endif |
368 } | 383 } |
369 } | 384 } |
OLD | NEW |