| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 part of html; | |
| 6 | |
| 7 // On Firefox 11, the object obtained from 'window.location' is very strange. | |
| 8 // It can't be monkey-patched and seems immune to putting methods on | |
| 9 // Object.prototype. We are forced to wrap the object. | |
| 10 | |
| 11 class _LocationWrapper implements Location { | |
| 12 | |
| 13 final _ptr; // Opaque reference to real location. | |
| 14 | |
| 15 _LocationWrapper(this._ptr); | |
| 16 | |
| 17 // TODO(sra): Replace all the _set and _get calls with 'JS' forms. | |
| 18 | |
| 19 // final List<String> ancestorOrigins; | |
| 20 List<String> get ancestorOrigins => _get(_ptr, 'ancestorOrigins'); | |
| 21 | |
| 22 // String hash; | |
| 23 String get hash => _get(_ptr, 'hash'); | |
| 24 void set hash(String value) { | |
| 25 _set(_ptr, 'hash', value); | |
| 26 } | |
| 27 | |
| 28 // String host; | |
| 29 String get host => _get(_ptr, 'host'); | |
| 30 void set host(String value) { | |
| 31 _set(_ptr, 'host', value); | |
| 32 } | |
| 33 | |
| 34 // String hostname; | |
| 35 String get hostname => _get(_ptr, 'hostname'); | |
| 36 void set hostname(String value) { | |
| 37 _set(_ptr, 'hostname', value); | |
| 38 } | |
| 39 | |
| 40 // String href; | |
| 41 String get href => _get(_ptr, 'href'); | |
| 42 void set href(String value) { | |
| 43 _set(_ptr, 'href', value); | |
| 44 } | |
| 45 | |
| 46 // final String origin; | |
| 47 String get origin { | |
| 48 if (JS('bool', '("origin" in #)', _ptr)) { | |
| 49 return JS('String', '#.origin', _ptr); | |
| 50 } | |
| 51 return '${this.protocol}//${this.host}'; | |
| 52 } | |
| 53 | |
| 54 // String pathname; | |
| 55 String get pathname => _get(_ptr, 'pathname'); | |
| 56 void set pathname(String value) { | |
| 57 _set(_ptr, 'pathname', value); | |
| 58 } | |
| 59 | |
| 60 // String port; | |
| 61 String get port => _get(_ptr, 'port'); | |
| 62 void set port(String value) { | |
| 63 _set(_ptr, 'port', value); | |
| 64 } | |
| 65 | |
| 66 // String protocol; | |
| 67 String get protocol => _get(_ptr, 'protocol'); | |
| 68 void set protocol(String value) { | |
| 69 _set(_ptr, 'protocol', value); | |
| 70 } | |
| 71 | |
| 72 // String search; | |
| 73 String get search => _get(_ptr, 'search'); | |
| 74 void set search(String value) { | |
| 75 _set(_ptr, 'search', value); | |
| 76 } | |
| 77 | |
| 78 void assign(String url) => JS('void', '#.assign(#)', _ptr, url); | |
| 79 | |
| 80 void reload() => JS('void', '#.reload()', _ptr); | |
| 81 | |
| 82 void replace(String url) => JS('void', '#.replace(#)', _ptr, url); | |
| 83 | |
| 84 String toString() => JS('String', '#.toString()', _ptr); | |
| 85 | |
| 86 | |
| 87 static _get(p, m) => JS('var', '#[#]', p, m); | |
| 88 static _set(p, m, v) => JS('void', '#[#] = #', p, m, v); | |
| 89 } | |
| OLD | NEW |