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

Unified Diff: dart/tools/dom/templates/html/impl/impl_Window.darttemplate

Issue 56933002: Version 0.8.10.1 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/tools/dom/templates/html/impl/impl_HTMLDocument.darttemplate ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tools/dom/templates/html/impl/impl_Window.darttemplate
===================================================================
--- dart/tools/dom/templates/html/impl/impl_Window.darttemplate (revision 29785)
+++ dart/tools/dom/templates/html/impl/impl_Window.darttemplate (working copy)
@@ -271,13 +271,18 @@
static bool get supportsPointConversions => _DomPoint.supported;
$!MEMBERS
+ /**
+ * Static factory designed to expose `beforeunload` events to event
+ * handlers that are not necessarily instances of [Window].
+ *
+ * See [EventStreamProvider] for usage information.
+ */
@DomName('Window.beforeunloadEvent')
- @DocsEditable()
static const EventStreamProvider<BeforeUnloadEvent> beforeUnloadEvent =
const _BeforeUnloadEventStreamProvider('beforeunload');
+ /// Stream of `beforeunload` events handled by this [Window].
@DomName('Window.onbeforeunload')
- @DocsEditable()
Stream<Event> get onBeforeUnload => beforeUnloadEvent.forTarget(this);
void moveTo(Point p) {
@@ -292,6 +297,7 @@
$endif
}
+$if DART2JS
class _BeforeUnloadEvent extends _WrappedEvent implements BeforeUnloadEvent {
String _returnValue;
@@ -301,15 +307,14 @@
void set returnValue(String value) {
_returnValue = value;
-$if DART2JS
// FF and IE use the value as the return value, Chrome will return this from
// the event callback function.
if (JS('bool', '("returnValue" in #)', wrapped)) {
JS('void', '#.returnValue = #', wrapped, value);
}
-$endif
}
}
+$endif
class _BeforeUnloadEventStreamProvider implements
EventStreamProvider<BeforeUnloadEvent> {
@@ -318,8 +323,10 @@
const _BeforeUnloadEventStreamProvider(this._eventType);
Stream<BeforeUnloadEvent> forTarget(EventTarget e, {bool useCapture: false}) {
+ var stream = new _EventStream(e, _eventType, useCapture);
+$if DART2JS
var controller = new StreamController(sync: true);
- var stream = new _EventStream(e, _eventType, useCapture);
+
stream.listen((event) {
var wrapped = new _BeforeUnloadEvent(event);
controller.add(wrapped);
@@ -327,6 +334,9 @@
});
return controller.stream;
+$else
+ return stream;
+$endif
}
String getEventType(EventTarget target) {
« no previous file with comments | « dart/tools/dom/templates/html/impl/impl_HTMLDocument.darttemplate ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698