| 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 // TODO(vsm): Unify with Dartium version. | 5 // TODO(vsm): Unify with Dartium version. |
| 6 class _DOMWindowCrossFrameImpl implements Window { | 6 class _DOMWindowCrossFrameImpl implements Window { |
| 7 // Private window. Note, this is a window in another frame, so it | 7 // Private window. Note, this is a window in another frame, so it |
| 8 // cannot be typed as "Window" as its prototype is not patched | 8 // cannot be typed as "Window" as its prototype is not patched |
| 9 // properly. Its fields and methods can only be accessed via JavaScript. | 9 // properly. Its fields and methods can only be accessed via JavaScript. |
| 10 var _window; | 10 var _window; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 JS('void', '#.postMessage(#,#)', _window, message, targetOrigin); | 39 JS('void', '#.postMessage(#,#)', _window, message, targetOrigin); |
| 40 } else { | 40 } else { |
| 41 JS('void', '#.postMessage(#,#,#)', _window, message, targetOrigin, message
Ports); | 41 JS('void', '#.postMessage(#,#,#)', _window, message, targetOrigin, message
Ports); |
| 42 } | 42 } |
| 43 } | 43 } |
| 44 | 44 |
| 45 // Implementation support. | 45 // Implementation support. |
| 46 _DOMWindowCrossFrameImpl(this._window); | 46 _DOMWindowCrossFrameImpl(this._window); |
| 47 | 47 |
| 48 static Window _createSafe(w) { | 48 static Window _createSafe(w) { |
| 49 if (w === window) { | 49 if (identical(w, window)) { |
| 50 return w; | 50 return w; |
| 51 } else { | 51 } else { |
| 52 // TODO(vsm): Cache or implement equality. | 52 // TODO(vsm): Cache or implement equality. |
| 53 return new _DOMWindowCrossFrameImpl(w); | 53 return new _DOMWindowCrossFrameImpl(w); |
| 54 } | 54 } |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| 58 class _LocationCrossFrameImpl implements Location { | 58 class _LocationCrossFrameImpl implements Location { |
| 59 // Private location. Note, this is a location object in another frame, so it | 59 // Private location. Note, this is a location object in another frame, so it |
| 60 // cannot be typed as "Location" as its prototype is not patched | 60 // cannot be typed as "Location" as its prototype is not patched |
| 61 // properly. Its fields and methods can only be accessed via JavaScript. | 61 // properly. Its fields and methods can only be accessed via JavaScript. |
| 62 var _location; | 62 var _location; |
| 63 | 63 |
| 64 void set href(String val) => _setHref(_location, val); | 64 void set href(String val) => _setHref(_location, val); |
| 65 static void _setHref(location, val) { | 65 static void _setHref(location, val) { |
| 66 JS('void', '#.href = #', location, val); | 66 JS('void', '#.href = #', location, val); |
| 67 } | 67 } |
| 68 | 68 |
| 69 // Implementation support. | 69 // Implementation support. |
| 70 _LocationCrossFrameImpl(this._location); | 70 _LocationCrossFrameImpl(this._location); |
| 71 | 71 |
| 72 static Location _createSafe(location) { | 72 static Location _createSafe(location) { |
| 73 if (location === window.location) { | 73 if (identical(location, window.location)) { |
| 74 return location; | 74 return location; |
| 75 } else { | 75 } else { |
| 76 // TODO(vsm): Cache or implement equality. | 76 // TODO(vsm): Cache or implement equality. |
| 77 return new _LocationCrossFrameImpl(location); | 77 return new _LocationCrossFrameImpl(location); |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 class _HistoryCrossFrameImpl implements History { | 82 class _HistoryCrossFrameImpl implements History { |
| 83 // Private history. Note, this is a history object in another frame, so it | 83 // Private history. Note, this is a history object in another frame, so it |
| 84 // cannot be typed as "History" as its prototype is not patched | 84 // cannot be typed as "History" as its prototype is not patched |
| 85 // properly. Its fields and methods can only be accessed via JavaScript. | 85 // properly. Its fields and methods can only be accessed via JavaScript. |
| 86 var _history; | 86 var _history; |
| 87 | 87 |
| 88 void back() => JS('void', '#.back()', _history); | 88 void back() => JS('void', '#.back()', _history); |
| 89 | 89 |
| 90 void forward() => JS('void', '#.forward()', _history); | 90 void forward() => JS('void', '#.forward()', _history); |
| 91 | 91 |
| 92 void go(int distance) => JS('void', '#.go(#)', _history, distance); | 92 void go(int distance) => JS('void', '#.go(#)', _history, distance); |
| 93 | 93 |
| 94 // Implementation support. | 94 // Implementation support. |
| 95 _HistoryCrossFrameImpl(this._history); | 95 _HistoryCrossFrameImpl(this._history); |
| 96 | 96 |
| 97 static History _createSafe(h) { | 97 static History _createSafe(h) { |
| 98 if (h === window.history) { | 98 if (identical(h, window.history)) { |
| 99 return h; | 99 return h; |
| 100 } else { | 100 } else { |
| 101 // TODO(vsm): Cache or implement equality. | 101 // TODO(vsm): Cache or implement equality. |
| 102 return new _HistoryCrossFrameImpl(h); | 102 return new _HistoryCrossFrameImpl(h); |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 } | 105 } |
| OLD | NEW |