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

Side by Side Diff: lib/dom/templates/html/frog/impl_Window.darttemplate

Issue 10534130: Wrap Location object on Firefox. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 months 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 | « lib/dom/templates/html/frog/html_frog.darttemplate ('k') | lib/html/frog/html_frog.dart » ('j') | 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 class $CLASSNAME$EXTENDS$IMPLEMENTS native "@*DOMWindow" { 5 class $CLASSNAME$EXTENDS$IMPLEMENTS native "@*DOMWindow" {
6 6
7 _DocumentImpl get document() native "return this.document;"; 7 _DocumentImpl get document() native "return this.document;";
8 8
9 Window get _top() native "return this.top;"; 9 Window get _top() native "return this.top;";
10 10
11 // Override top to return secure wrapper. 11 // Override top to return secure wrapper.
12 Window get top() => _DOMWindowCrossFrameImpl._createSafe(_top); 12 Window get top() => _DOMWindowCrossFrameImpl._createSafe(_top);
13 13
14
15 // API level getter and setter for Location.
16 // TODO: The cross domain safe wrapper can be inserted here or folded into
17 // _LocationWrapper.
18 Location get location() => _get_location();
19
20 // TODO: consider forcing users to do: window.location.assign('string').
21 /**
22 * Sets the window's location, which causes the browser to navigate to the new
23 * location. [value] may be a Location object or a string.
24 */
25 void set location(value) => _set_location(value);
26
27 // Firefox work-around for Location. The Firefox location object cannot be
28 // made to behave like a Dart object so must be wrapped.
29
30 Location _get_location() {
31 var result = _location;
32 if (_isDartLocation(result)) return result; // e.g. on Chrome.
33 if (null == _location_wrapper) {
34 _location_wrapper = new _LocationWrapper(result);
35 }
36 return _location_wrapper;
37 }
38
39 void _set_location(value) {
40 if (value is _LocationWrapper) {
41 _location = value._ptr;
42 } else {
43 _location = value;
44 }
45 }
46
47 var _location_wrapper; // Cached wrapped Location object.
48
49 // Native getter and setter to access raw Location object.
50 Location get _location() native 'return this.location';
51 void set _location(Location value) native 'this.location = value';
52 // Prevent compiled from thinking 'location' property is available for a Dart
53 // member.
54 _protect_location() native 'location';
55
56 static _isDartLocation(thing) {
57 // On Firefox the code that implements 'is Location' fails to find the patch
58 // stub on Object.prototype and throws an exception.
59 try {
60 return thing is Location;
61 } catch (var e) {
62 return false;
63 }
64 }
65
66
14 void requestLayoutFrame(TimeoutHandler callback) { 67 void requestLayoutFrame(TimeoutHandler callback) {
15 _addMeasurementFrameCallback(callback); 68 _addMeasurementFrameCallback(callback);
16 } 69 }
17 70
18 /** @domName DOMWindow.requestAnimationFrame */ 71 /** @domName DOMWindow.requestAnimationFrame */
19 int requestAnimationFrame(RequestAnimationFrameCallback callback) { 72 int requestAnimationFrame(RequestAnimationFrameCallback callback) {
20 _ensureRequestAnimationFrame(); 73 _ensureRequestAnimationFrame();
21 return _requestAnimationFrame(callback); 74 return _requestAnimationFrame(callback);
22 } 75 }
23 76
(...skipping 25 matching lines...) Expand all
49 '''; 102 ''';
50 103
51 104
52 _IDBFactoryImpl get indexedDB() => _get_indexedDB(); 105 _IDBFactoryImpl get indexedDB() => _get_indexedDB();
53 106
54 _IDBFactoryImpl _get_indexedDB() native 107 _IDBFactoryImpl _get_indexedDB() native
55 'return this.indexedDB || this.webkitIndexedDB || this.mozIndexedDB'; 108 'return this.indexedDB || this.webkitIndexedDB || this.mozIndexedDB';
56 109
57 $!MEMBERS 110 $!MEMBERS
58 } 111 }
OLDNEW
« no previous file with comments | « lib/dom/templates/html/frog/html_frog.darttemplate ('k') | lib/html/frog/html_frog.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698