Chromium Code Reviews| 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 | |
| 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 void set location(Location value) => _set_location(value); | |
|
vsm
2012/06/13 04:34:02
This was probably broken before, but the setter sh
| |
| 20 | |
| 21 // Firefox work-around for Location. The Firefox location object cannot be | |
| 22 // made to behave like a Dart object so must be wrapped. | |
| 23 | |
| 24 Location _get_location() { | |
| 25 var result = _location; | |
| 26 if (_isDartLocation(result)) return result; // e.g. on Chrome. | |
| 27 if (null == _location_wrapper) { | |
| 28 _location_wrapper = new _LocationWrapper(result); | |
| 29 } | |
| 30 return _location_wrapper; | |
| 31 } | |
| 32 | |
| 33 void _set_location(Location value) { | |
| 34 if (value is _LocationWrapper) { | |
| 35 _location = value._ptr; | |
| 36 } else { | |
| 37 _location = value; | |
| 38 } | |
| 39 } | |
| 40 | |
| 41 var _location_wrapper; // Cached wrapped Location object. | |
| 42 | |
| 43 // Native getter and setter to access raw Location object. | |
| 44 Location get _location() native 'return this.location'; | |
| 45 void set _location(Location value) native 'this.location = value'; | |
| 46 // Prevent compiled from thinking 'location' property is available for a Dart | |
| 47 // member. | |
| 48 _protect_location() native 'location'; | |
|
vsm
2012/06/13 04:34:02
Is this used?
| |
| 49 | |
| 50 static _isDartLocation(thing) { | |
| 51 // On Firefox the code that implements 'is Location' fails to find the patch | |
| 52 // stub on Object.prototype and throws an exception. | |
| 53 try { | |
| 54 return thing is Location; | |
| 55 } catch (var e) { | |
| 56 return false; | |
| 57 } | |
| 58 } | |
| 59 | |
| 60 | |
| 14 void requestLayoutFrame(TimeoutHandler callback) { | 61 void requestLayoutFrame(TimeoutHandler callback) { |
| 15 _addMeasurementFrameCallback(callback); | 62 _addMeasurementFrameCallback(callback); |
| 16 } | 63 } |
| 17 | 64 |
| 18 /** @domName DOMWindow.requestAnimationFrame */ | 65 /** @domName DOMWindow.requestAnimationFrame */ |
| 19 int requestAnimationFrame(RequestAnimationFrameCallback callback) { | 66 int requestAnimationFrame(RequestAnimationFrameCallback callback) { |
| 20 _ensureRequestAnimationFrame(); | 67 _ensureRequestAnimationFrame(); |
| 21 return _requestAnimationFrame(callback); | 68 return _requestAnimationFrame(callback); |
| 22 } | 69 } |
| 23 | 70 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 49 '''; | 96 '''; |
| 50 | 97 |
| 51 | 98 |
| 52 _IDBFactoryImpl get indexedDB() => _get_indexedDB(); | 99 _IDBFactoryImpl get indexedDB() => _get_indexedDB(); |
| 53 | 100 |
| 54 _IDBFactoryImpl _get_indexedDB() native | 101 _IDBFactoryImpl _get_indexedDB() native |
| 55 'return this.indexedDB || this.webkitIndexedDB || this.mozIndexedDB'; | 102 'return this.indexedDB || this.webkitIndexedDB || this.mozIndexedDB'; |
| 56 | 103 |
| 57 $!MEMBERS | 104 $!MEMBERS |
| 58 } | 105 } |
| OLD | NEW |