OLD | NEW |
| 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. |
1 | 4 |
2 class _HTMLIFrameElementJs extends _HTMLElementJs implements HTMLIFrameElement n
ative "*HTMLIFrameElement" { | 5 class _HTMLIFrameElementJs extends _HTMLElementJs implements HTMLIFrameElement n
ative "*HTMLIFrameElement" { |
3 | 6 |
4 String align; | 7 String align; |
5 | 8 |
6 final _DocumentJs contentDocument; | |
7 | |
8 final _DOMWindowJs contentWindow; | |
9 | |
10 String frameBorder; | 9 String frameBorder; |
11 | 10 |
12 String height; | 11 String height; |
13 | 12 |
14 String longDesc; | 13 String longDesc; |
15 | 14 |
16 String marginHeight; | 15 String marginHeight; |
17 | 16 |
18 String marginWidth; | 17 String marginWidth; |
19 | 18 |
20 String name; | 19 String name; |
21 | 20 |
22 String sandbox; | 21 String sandbox; |
23 | 22 |
24 String scrolling; | 23 String scrolling; |
25 | 24 |
26 String src; | 25 String src; |
27 | 26 |
28 String width; | 27 String width; |
29 | 28 |
30 _SVGDocumentJs getSVGDocument() native; | 29 _SVGDocumentJs getSVGDocument() native; |
| 30 |
| 31 |
| 32 Window get _contentWindow() native "return this.contentWindow;"; |
| 33 |
| 34 // Override contentWindow to return secure wrapper. |
| 35 Window get contentWindow() { |
| 36 return _DOMWindowCrossFrameImpl._createSafe(_contentWindow); |
| 37 } |
31 } | 38 } |
| 39 |
| 40 // TODO(vsm): Unify with Dartium version. |
| 41 class _DOMWindowCrossFrameImpl implements DOMType, DOMWindow { |
| 42 // Private window. |
| 43 _DOMWindowJs _window; |
| 44 |
| 45 // DOMType |
| 46 var dartObjectLocalStorage; |
| 47 String get typeName() => "DOMWindow"; |
| 48 |
| 49 // Fields. |
| 50 // TODO(vsm): Wrap these two. |
| 51 History get history() => _window.history; |
| 52 Location get location() => _window.location; |
| 53 |
| 54 bool get closed() => _window.closed; |
| 55 int get length() => _window.length; |
| 56 DOMWindow get opener() => _createDOMWindowCrossFrame(_window.opener); |
| 57 DOMWindow get parent() => _createDOMWindowCrossFrame(_window.parent); |
| 58 DOMWindow get top() => _createDOMWindowCrossFrame(_window.top); |
| 59 |
| 60 // Methods. |
| 61 void focus() { |
| 62 _window.focus(); |
| 63 } |
| 64 |
| 65 void blur() { |
| 66 _window.blur(); |
| 67 } |
| 68 |
| 69 void close() { |
| 70 _window.close(); |
| 71 } |
| 72 |
| 73 void postMessage(Dynamic message, |
| 74 String targetOrigin, |
| 75 [List messagePorts = null]) { |
| 76 if (messagePorts == null) { |
| 77 _window.postMessage(message, targetOrigin); |
| 78 } else { |
| 79 _window.postMessage(message, targetOrigin, messagePorts); |
| 80 } |
| 81 } |
| 82 |
| 83 // Implementation support. |
| 84 _DOMWindowCrossFrameImpl(this._window); |
| 85 |
| 86 static DOMWindow _createSafe(w) { |
| 87 // TODO(vsm): Check if it's the top-level window. Return unwrapped. |
| 88 |
| 89 // TODO(vsm): Cache or implement equality. |
| 90 return new _DOMWindowCrossFrameImpl(w); |
| 91 } |
| 92 } |
OLD | NEW |