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 """ |
| 33 return this.contentWindow; |
| 34 """; |
| 35 |
| 36 // Override contentWindow to return secure wrapper. |
| 37 Window get contentWindow() { |
| 38 return _DOMWindowCrossFrameJs._createSafe(_contentWindow); |
| 39 } |
31 } | 40 } |
| 41 |
| 42 // TODO(vsm): Unify with Dartium version. |
| 43 class _DOMWindowCrossFrameJs implements DOMType, DOMWindow { |
| 44 // Private window. |
| 45 _DOMWindowJs _window; |
| 46 |
| 47 // DOMType |
| 48 var dartObjectLocalStorage; |
| 49 String get typeName() => "DOMWindow"; |
| 50 |
| 51 // Fields. |
| 52 // TODO(vsm): Wrap these two. |
| 53 History get history() => _window.history; |
| 54 Location get location() => _window.location; |
| 55 |
| 56 bool get closed() => _window.closed; |
| 57 int get length() => _window.length; |
| 58 DOMWindow get opener() => _createDOMWindowCrossFrame(_window.opener); |
| 59 DOMWindow get parent() => _createDOMWindowCrossFrame(_window.parent); |
| 60 DOMWindow get top() => _createDOMWindowCrossFrame(_window.top); |
| 61 |
| 62 // TODO(vsm): Why is this needed? How do I get a |
| 63 // NoSuchMethodException. |
| 64 var get document() { throw new Exception(); } |
| 65 |
| 66 // Methods. |
| 67 void focus() { |
| 68 _window.focus(); |
| 69 } |
| 70 |
| 71 void blur() { |
| 72 _window.blur(); |
| 73 } |
| 74 |
| 75 void close() { |
| 76 _window.close(); |
| 77 } |
| 78 |
| 79 void postMessage(Dynamic message, String targetOrigin, [List messagePorts = nu
ll]) { |
| 80 if (messagePorts == null) { |
| 81 _window.postMessage(message, targetOrigin); |
| 82 } else { |
| 83 _window.postMessage(message, targetOrigin, messagePorts); |
| 84 } |
| 85 } |
| 86 |
| 87 // Implementation support. |
| 88 _DOMWindowCrossFrameJs(this._window); |
| 89 |
| 90 static DOMWindow _createSafe(w) { |
| 91 // TODO(vsm): Check if it's the top-level window. Return unwrapped. |
| 92 |
| 93 // TODO(vsm): Cache or implement equality. |
| 94 return new _DOMWindowCrossFrameJs(w); |
| 95 } |
| 96 } |
OLD | NEW |