| 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 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 Window _open2(url, name) native "return this.open(url, name);"; | 14 Window _open2(url, name) native "return this.open(url, name);"; |
| 15 | 15 |
| 16 Window _open3(url, name, options) native "return this.open(url, name, options)
;"; | 16 Window _open3(url, name, options) native "return this.open(url, name, options)
;"; |
| 17 | 17 |
| 18 Window open(String url, String name, [String options]) { | 18 Window open(String url, String name, [String options]) { |
| 19 if (options == null) { | 19 if (options == null) { |
| 20 return _DOMWindowCrossFrameImpl._createSafe(_open2(url, name)); | 20 return _DOMWindowCrossFrameImpl._createSafe(_open2(url, name)); |
| 21 } else { | 21 } else { |
| 22 return _DOMWindowCrossFrameImpl._createSafe(_open3(url, name, options)); | 22 return _DOMWindowCrossFrameImpl._createSafe(_open3(url, name, options)); |
| 23 } | 23 } |
| 24 } | 24 } |
| 25 | 25 |
| 26 // API level getter and setter for Location. | 26 // API level getter and setter for Location. |
| 27 // TODO: The cross domain safe wrapper can be inserted here or folded into | 27 // TODO: The cross domain safe wrapper can be inserted here or folded into |
| 28 // _LocationWrapper. | 28 // _LocationWrapper. |
| 29 Location get location => _get_location(); | 29 Location get location() => _get_location(); |
| 30 | 30 |
| 31 // TODO: consider forcing users to do: window.location.assign('string'). | 31 // TODO: consider forcing users to do: window.location.assign('string'). |
| 32 /** | 32 /** |
| 33 * Sets the window's location, which causes the browser to navigate to the new | 33 * Sets the window's location, which causes the browser to navigate to the new |
| 34 * location. [value] may be a Location object or a string. | 34 * location. [value] may be a Location object or a string. |
| 35 */ | 35 */ |
| 36 void set location(value) => _set_location(value); | 36 void set location(value) => _set_location(value); |
| 37 | 37 |
| 38 // Firefox work-around for Location. The Firefox location object cannot be | 38 // Firefox work-around for Location. The Firefox location object cannot be |
| 39 // made to behave like a Dart object so must be wrapped. | 39 // made to behave like a Dart object so must be wrapped. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 51 if (value is _LocationWrapper) { | 51 if (value is _LocationWrapper) { |
| 52 _location = value._ptr; | 52 _location = value._ptr; |
| 53 } else { | 53 } else { |
| 54 _location = value; | 54 _location = value; |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| 58 var _location_wrapper; // Cached wrapped Location object. | 58 var _location_wrapper; // Cached wrapped Location object. |
| 59 | 59 |
| 60 // Native getter and setter to access raw Location object. | 60 // Native getter and setter to access raw Location object. |
| 61 Location get _location native 'return this.location'; | 61 Location get _location() native 'return this.location'; |
| 62 void set _location(Location value) native 'this.location = value'; | 62 void set _location(Location value) native 'this.location = value'; |
| 63 // Prevent compiled from thinking 'location' property is available for a Dart | 63 // Prevent compiled from thinking 'location' property is available for a Dart |
| 64 // member. | 64 // member. |
| 65 _protect_location() native 'location'; | 65 _protect_location() native 'location'; |
| 66 | 66 |
| 67 static _isDartLocation(thing) { | 67 static _isDartLocation(thing) { |
| 68 // On Firefox the code that implements 'is Location' fails to find the patch | 68 // On Firefox the code that implements 'is Location' fails to find the patch |
| 69 // stub on Object.prototype and throws an exception. | 69 // stub on Object.prototype and throws an exception. |
| 70 try { | 70 try { |
| 71 return thing is Location; | 71 return thing is Location; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 this[vendors[i]+'CancelRequestAnimationFrame']; | 106 this[vendors[i]+'CancelRequestAnimationFrame']; |
| 107 } | 107 } |
| 108 if (this.requestAnimationFrame && this.cancelAnimationFrame) return; | 108 if (this.requestAnimationFrame && this.cancelAnimationFrame) return; |
| 109 this.requestAnimationFrame = function(callback) { | 109 this.requestAnimationFrame = function(callback) { |
| 110 return window.setTimeout(callback, 16 /* 16ms ~= 60fps */); | 110 return window.setTimeout(callback, 16 /* 16ms ~= 60fps */); |
| 111 }; | 111 }; |
| 112 this.cancelAnimationFrame = function(id) { clearTimeout(id); } | 112 this.cancelAnimationFrame = function(id) { clearTimeout(id); } |
| 113 '''; | 113 '''; |
| 114 | 114 |
| 115 | 115 |
| 116 _IDBFactoryImpl get indexedDB => _get_indexedDB(); | 116 _IDBFactoryImpl get indexedDB() => _get_indexedDB(); |
| 117 | 117 |
| 118 _IDBFactoryImpl _get_indexedDB() native | 118 _IDBFactoryImpl _get_indexedDB() native |
| 119 'return this.indexedDB || this.webkitIndexedDB || this.mozIndexedDB'; | 119 'return this.indexedDB || this.webkitIndexedDB || this.mozIndexedDB'; |
| 120 | 120 |
| 121 // TODO(kasperl): Document these. | 121 // TODO(kasperl): Document these. |
| 122 lookupPort(String name) { | 122 lookupPort(String name) { |
| 123 var port = JSON.parse(localStorage['dart-port:$name']); | 123 var port = JSON.parse(localStorage['dart-port:$name']); |
| 124 return _deserialize(port); | 124 return _deserialize(port); |
| 125 } | 125 } |
| 126 | 126 |
| 127 registerPort(String name, var port) { | 127 registerPort(String name, var port) { |
| 128 var serialized = _serialize(port); | 128 var serialized = _serialize(port); |
| 129 localStorage['dart-port:$name'] = JSON.stringify(serialized); | 129 localStorage['dart-port:$name'] = JSON.stringify(serialized); |
| 130 } | 130 } |
| 131 | 131 |
| 132 String createObjectUrl(object) native ''' | 132 String createObjectUrl(object) native ''' |
| 133 return (window.URL || window.webkitURL).createObjectURL(object) | 133 return (window.URL || window.webkitURL).createObjectURL(object) |
| 134 '''; | 134 '''; |
| 135 | 135 |
| 136 void revokeObjectUrl(String objectUrl) native ''' | 136 void revokeObjectUrl(String objectUrl) native ''' |
| 137 (window.URL || window.webkitURL).revokeObjectURL(objectUrl) | 137 (window.URL || window.webkitURL).revokeObjectURL(objectUrl) |
| 138 '''; | 138 '''; |
| 139 $!MEMBERS | 139 $!MEMBERS |
| 140 } | 140 } |
| OLD | NEW |