| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 | 5 |
| 6 // On Firefox 11, the object obtained from 'window.location' is very strange. | 6 // On Firefox 11, the object obtained from 'window.location' is very strange. |
| 7 // It can't be monkey-patched and seems immune to putting methods on | 7 // It can't be monkey-patched and seems immune to putting methods on |
| 8 // Object.prototype. We are forced to wrap the object. | 8 // Object.prototype. We are forced to wrap the object. |
| 9 | 9 |
| 10 class _LocationWrapper implements Location { | 10 class _LocationWrapper implements Location { |
| 11 | 11 |
| 12 final _ptr; // Opaque reference to real location. | 12 final _ptr; // Opaque reference to real location. |
| 13 | 13 |
| 14 _LocationWrapper(this._ptr); | 14 _LocationWrapper(this._ptr); |
| 15 | 15 |
| 16 // TODO(sra): Replace all the _set and _get calls with 'JS' forms. | 16 // TODO(sra): Replace all the _set and _get calls with 'JS' forms. |
| 17 | 17 |
| 18 // final List<String> ancestorOrigins; | 18 // final List<String> ancestorOrigins; |
| 19 List<String> get ancestorOrigins() => _get(_ptr, 'ancestorOrigins'); | 19 List<String> get ancestorOrigins => _get(_ptr, 'ancestorOrigins'); |
| 20 | 20 |
| 21 // String hash; | 21 // String hash; |
| 22 String get hash() => _get(_ptr, 'hash'); | 22 String get hash => _get(_ptr, 'hash'); |
| 23 void set hash(String value) => _set(_ptr, 'hash', value); | 23 void set hash(String value) => _set(_ptr, 'hash', value); |
| 24 | 24 |
| 25 // String host; | 25 // String host; |
| 26 String get host() => _get(_ptr, 'host'); | 26 String get host => _get(_ptr, 'host'); |
| 27 void set host(String value) => _set(_ptr, 'host', value); | 27 void set host(String value) => _set(_ptr, 'host', value); |
| 28 | 28 |
| 29 // String hostname; | 29 // String hostname; |
| 30 String get hostname() => _get(_ptr, 'hostname'); | 30 String get hostname => _get(_ptr, 'hostname'); |
| 31 void set hostname(String value) => _set(_ptr, 'hostname', value); | 31 void set hostname(String value) => _set(_ptr, 'hostname', value); |
| 32 | 32 |
| 33 // String href; | 33 // String href; |
| 34 String get href() => _get(_ptr, 'href'); | 34 String get href => _get(_ptr, 'href'); |
| 35 void set href(String value) => _set(_ptr, 'href', value); | 35 void set href(String value) => _set(_ptr, 'href', value); |
| 36 | 36 |
| 37 // final String origin; | 37 // final String origin; |
| 38 String get origin() => _get(_ptr, 'origin'); | 38 String get origin => _get(_ptr, 'origin'); |
| 39 | 39 |
| 40 // String pathname; | 40 // String pathname; |
| 41 String get pathname() => _get(_ptr, 'pathname'); | 41 String get pathname => _get(_ptr, 'pathname'); |
| 42 void set pathname(String value) => _set(_ptr, 'pathname', value); | 42 void set pathname(String value) => _set(_ptr, 'pathname', value); |
| 43 | 43 |
| 44 // String port; | 44 // String port; |
| 45 String get port() => _get(_ptr, 'port'); | 45 String get port => _get(_ptr, 'port'); |
| 46 void set port(String value) => _set(_ptr, 'port', value); | 46 void set port(String value) => _set(_ptr, 'port', value); |
| 47 | 47 |
| 48 // String protocol; | 48 // String protocol; |
| 49 String get protocol() => _get(_ptr, 'protocol'); | 49 String get protocol => _get(_ptr, 'protocol'); |
| 50 void set protocol(String value) => _set(_ptr, 'protocol', value); | 50 void set protocol(String value) => _set(_ptr, 'protocol', value); |
| 51 | 51 |
| 52 // String search; | 52 // String search; |
| 53 String get search() => _get(_ptr, 'search'); | 53 String get search => _get(_ptr, 'search'); |
| 54 void set search(String value) => _set(_ptr, 'search', value); | 54 void set search(String value) => _set(_ptr, 'search', value); |
| 55 | 55 |
| 56 | 56 |
| 57 void assign(String url) => _assign(_ptr, url); | 57 void assign(String url) => _assign(_ptr, url); |
| 58 | 58 |
| 59 void reload() => _reload(_ptr); | 59 void reload() => _reload(_ptr); |
| 60 | 60 |
| 61 void replace(String url) => _replace(_ptr, url); | 61 void replace(String url) => _replace(_ptr, url); |
| 62 | 62 |
| 63 String toString() => _toString(_ptr); | 63 String toString() => _toString(_ptr); |
| 64 | 64 |
| 65 | 65 |
| 66 static _get(p, m) native 'return p[m];'; | 66 static _get(p, m) native 'return p[m];'; |
| 67 static _set(p, m, v) native 'p[m] = v;'; | 67 static _set(p, m, v) native 'p[m] = v;'; |
| 68 | 68 |
| 69 static _assign(p, url) native 'p.assign(url);'; | 69 static _assign(p, url) native 'p.assign(url);'; |
| 70 static _reload(p) native 'p.reload()'; | 70 static _reload(p) native 'p.reload()'; |
| 71 static _replace(p, url) native 'p.replace(url);'; | 71 static _replace(p, url) native 'p.replace(url);'; |
| 72 static _toString(p) native 'return p.toString();'; | 72 static _toString(p) native 'return p.toString();'; |
| 73 } | 73 } |
| OLD | NEW |