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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/tools/dom/templates/html/impl/impl_HTMLDocument.darttemplate ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS native "Wind ow,DOMWindow" { 9 $(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS native "Wind ow,DOMWindow" {
10 $else 10 $else
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 return new Point(result.x, result.y); 264 return new Point(result.x, result.y);
265 } 265 }
266 266
267 /** 267 /**
268 * Checks whether [convertPointFromNodeToPage] and 268 * Checks whether [convertPointFromNodeToPage] and
269 * [convertPointFromPageToNode] are supported on the current platform. 269 * [convertPointFromPageToNode] are supported on the current platform.
270 */ 270 */
271 static bool get supportsPointConversions => _DomPoint.supported; 271 static bool get supportsPointConversions => _DomPoint.supported;
272 $!MEMBERS 272 $!MEMBERS
273 273
274 /**
275 * Static factory designed to expose `beforeunload` events to event
276 * handlers that are not necessarily instances of [Window].
277 *
278 * See [EventStreamProvider] for usage information.
279 */
274 @DomName('Window.beforeunloadEvent') 280 @DomName('Window.beforeunloadEvent')
275 @DocsEditable()
276 static const EventStreamProvider<BeforeUnloadEvent> beforeUnloadEvent = 281 static const EventStreamProvider<BeforeUnloadEvent> beforeUnloadEvent =
277 const _BeforeUnloadEventStreamProvider('beforeunload'); 282 const _BeforeUnloadEventStreamProvider('beforeunload');
278 283
284 /// Stream of `beforeunload` events handled by this [Window].
279 @DomName('Window.onbeforeunload') 285 @DomName('Window.onbeforeunload')
280 @DocsEditable()
281 Stream<Event> get onBeforeUnload => beforeUnloadEvent.forTarget(this); 286 Stream<Event> get onBeforeUnload => beforeUnloadEvent.forTarget(this);
282 287
283 void moveTo(Point p) { 288 void moveTo(Point p) {
284 _moveTo(p.x, p.y); 289 _moveTo(p.x, p.y);
285 } 290 }
286 291
287 $if DART2JS 292 $if DART2JS
288 int get scrollX => JS('bool', '("scrollX" in #)', this) ? JS('int', 293 int get scrollX => JS('bool', '("scrollX" in #)', this) ? JS('int',
289 '#.scrollX', this) : document.documentElement.scrollLeft; 294 '#.scrollX', this) : document.documentElement.scrollLeft;
290 int get scrollY => JS('bool', '("scrollY" in #)', this) ? JS('int', 295 int get scrollY => JS('bool', '("scrollY" in #)', this) ? JS('int',
291 '#.scrollY', this) : document.documentElement.scrollTop; 296 '#.scrollY', this) : document.documentElement.scrollTop;
292 $endif 297 $endif
293 } 298 }
294 299
300 $if DART2JS
295 class _BeforeUnloadEvent extends _WrappedEvent implements BeforeUnloadEvent { 301 class _BeforeUnloadEvent extends _WrappedEvent implements BeforeUnloadEvent {
296 String _returnValue; 302 String _returnValue;
297 303
298 _BeforeUnloadEvent(Event base): super(base); 304 _BeforeUnloadEvent(Event base): super(base);
299 305
300 String get returnValue => _returnValue; 306 String get returnValue => _returnValue;
301 307
302 void set returnValue(String value) { 308 void set returnValue(String value) {
303 _returnValue = value; 309 _returnValue = value;
304 $if DART2JS
305 // FF and IE use the value as the return value, Chrome will return this from 310 // FF and IE use the value as the return value, Chrome will return this from
306 // the event callback function. 311 // the event callback function.
307 if (JS('bool', '("returnValue" in #)', wrapped)) { 312 if (JS('bool', '("returnValue" in #)', wrapped)) {
308 JS('void', '#.returnValue = #', wrapped, value); 313 JS('void', '#.returnValue = #', wrapped, value);
309 } 314 }
310 $endif
311 } 315 }
312 } 316 }
317 $endif
313 318
314 class _BeforeUnloadEventStreamProvider implements 319 class _BeforeUnloadEventStreamProvider implements
315 EventStreamProvider<BeforeUnloadEvent> { 320 EventStreamProvider<BeforeUnloadEvent> {
316 final String _eventType; 321 final String _eventType;
317 322
318 const _BeforeUnloadEventStreamProvider(this._eventType); 323 const _BeforeUnloadEventStreamProvider(this._eventType);
319 324
320 Stream<BeforeUnloadEvent> forTarget(EventTarget e, {bool useCapture: false}) { 325 Stream<BeforeUnloadEvent> forTarget(EventTarget e, {bool useCapture: false}) {
326 var stream = new _EventStream(e, _eventType, useCapture);
327 $if DART2JS
321 var controller = new StreamController(sync: true); 328 var controller = new StreamController(sync: true);
322 var stream = new _EventStream(e, _eventType, useCapture); 329
323 stream.listen((event) { 330 stream.listen((event) {
324 var wrapped = new _BeforeUnloadEvent(event); 331 var wrapped = new _BeforeUnloadEvent(event);
325 controller.add(wrapped); 332 controller.add(wrapped);
326 return wrapped.returnValue; 333 return wrapped.returnValue;
327 }); 334 });
328 335
329 return controller.stream; 336 return controller.stream;
337 $else
338 return stream;
339 $endif
330 } 340 }
331 341
332 String getEventType(EventTarget target) { 342 String getEventType(EventTarget target) {
333 return _eventType; 343 return _eventType;
334 } 344 }
335 } 345 }
OLDNEW
« 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