| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 // TODO(vsm): Unify with Dartium version. | |
| 6 class _DOMWindowCrossFrameImpl implements DOMType, DOMWindow { | |
| 7 // Private window. | |
| 8 _DOMWindowJs _window; | |
| 9 | |
| 10 // DOMType | |
| 11 var dartObjectLocalStorage; | |
| 12 String get typeName => "DOMWindow"; | |
| 13 | |
| 14 // Fields. | |
| 15 // TODO(vsm): Implement history and location getters. | |
| 16 | |
| 17 bool get closed => _window.closed; | |
| 18 int get length => _window.length; | |
| 19 DOMWindow get opener => _createSafe(_window.opener); | |
| 20 DOMWindow get parent => _createSafe(_window.parent); | |
| 21 DOMWindow get top => _createSafe(_window.top); | |
| 22 | |
| 23 // Methods. | |
| 24 void focus() => _window.focus(); | |
| 25 | |
| 26 void blur() => _window.blur(); | |
| 27 | |
| 28 void close() => _window.close(); | |
| 29 | |
| 30 void postMessage(Dynamic message, | |
| 31 String targetOrigin, | |
| 32 [List messagePorts = null]) { | |
| 33 if (messagePorts == null) { | |
| 34 _postMessage2(_window, message, targetOrigin); | |
| 35 } else { | |
| 36 _postMessage3(_window, message, targetOrigin, messagePorts); | |
| 37 } | |
| 38 } | |
| 39 | |
| 40 // TODO(vsm): This is a hack to workaround dartbug.com/3175. We | |
| 41 // need a more robust convention to invoke JS methods on the | |
| 42 // underlying window. | |
| 43 static void _postMessage2(win, message, targetOrigin) native """ | |
| 44 win.postMessage(message, targetOrigin); | |
| 45 """; | |
| 46 | |
| 47 static void _postMessage3(win, message, targetOrigin, messagePorts) native """ | |
| 48 win.postMessage(message, targetOrigin, messagePorts); | |
| 49 """; | |
| 50 | |
| 51 // Implementation support. | |
| 52 _DOMWindowCrossFrameImpl(this._window); | |
| 53 | |
| 54 static DOMWindow _createSafe(w) { | |
| 55 if (w === window) { | |
| 56 return w; | |
| 57 } else { | |
| 58 // TODO(vsm): Cache or implement equality. | |
| 59 return new _DOMWindowCrossFrameImpl(w); | |
| 60 } | |
| 61 } | |
| 62 } | |
| OLD | NEW |