Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Unified Diff: lib/html/frog/html_frog.dart

Side-by-side diff isn't available for this file because of its large size.
Issue 10378040: Generate and use cross frame wrappers for types in other frames/windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Factored out template Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
Download patch
Index: lib/html/frog/html_frog.dart
diff --git a/lib/html/frog/html_frog.dart b/lib/html/frog/html_frog.dart
index 6cf802fd42b3c0f55e5773d1556f4dbde23edfe0..719ec906cab3af5ad8bdc38badc8c38b67f045c1 100644
--- a/lib/html/frog/html_frog.dart
+++ b/lib/html/frog/html_frog.dart
@@ -24,6 +24,144 @@ _DocumentImpl get _document() native "return document;";
class _HTMLElementImpl extends _ElementImpl native "*HTMLElement" {
}
+class _HistoryCrossFrameImpl implements History {
+
+ void back() {
+ _ptr.back();
+ return;
+ }
+
+ void forward() {
+ _ptr.forward();
+ return;
+ }
+
+ void go(int distance) {
+ _ptr.go(distance);
+ return;
+ }
+
+ // Implementation.
+ _HistoryImpl _ptr;
+
+ _HistoryCrossFrameImpl._(this._ptr);
+
+ static _createSafe(ptr) {
+ if (ptr === window.history) {
+ return window.history;
+ } else {
+ // TODO(vsm): Should we cache to try to get reference equality?
+ return new _HistoryCrossFrameImpl._(ptr);
+ }
+ }
+
+ operator ==(other) {
+ return (other is _HistoryCrossFrameImpl) &&
+ (this._ptr === other._ptr);
+ }
+}
+
+class _LocationCrossFrameImpl implements Location {
+
+ void set href(String value) { _ptr.href = value; }
+
+ // Implementation.
+ _LocationImpl _ptr;
+
+ _LocationCrossFrameImpl._(this._ptr);
+
+ static _createSafe(ptr) {
+ if (ptr === window.location) {
+ return window.location;
+ } else {
+ // TODO(vsm): Should we cache to try to get reference equality?
+ return new _LocationCrossFrameImpl._(ptr);
+ }
+ }
+
+ operator ==(other) {
+ return (other is _LocationCrossFrameImpl) &&
+ (this._ptr === other._ptr);
+ }
+}
+
+class _WindowCrossFrameImpl implements Window {
+
+ bool get closed() => _ptr.closed;
+
+ Window get frames() => _ptr.frames;
+
+ History get history() => _ptr.history;
+
+ int get length() => _ptr.length;
+
+ Location get location() => _ptr.location;
+
+ void set location(Location value) { _ptr.location = value; }
+
+ Window get opener() => _ptr.opener;
+
+ Window get parent() => _ptr.parent;
+
+ Window get self() => _ptr.self;
+
+ Window get top() => _ptr.top;
+
+ void blur() {
+ _ptr.blur();
+ return;
+ }
+
+ void close() {
+ _ptr.close();
+ return;
+ }
+
+ void focus() {
+ _ptr.focus();
+ return;
+ }
+
+ void postMessage(/*SerializedScriptValue*/ message, String targetOrigin, [List messagePorts = null]) {
+ if (messagePorts === null) {
+ _ptr.postMessage(message, targetOrigin, messagePorts);
sra1 2012/05/10 00:12:06 Why are the branches the same? The main point of g
+ return;
+ } else {
+ _ptr.postMessage(message, targetOrigin, messagePorts);
+ return;
+ }
+ }
+
+ void webkitPostMessage(/*SerializedScriptValue*/ message, String targetOrigin, [List transferList = null]) {
+ if (transferList === null) {
+ _ptr.webkitPostMessage(message, targetOrigin, transferList);
+ return;
+ } else {
+ _ptr.webkitPostMessage(message, targetOrigin, transferList);
+ return;
+ }
+ }
+
+ // Implementation.
+ _WindowImpl _ptr;
+
+ _WindowCrossFrameImpl._(this._ptr);
+
+ static _createSafe(ptr) {
+ if (ptr === window) {
+ return window;
+ } else {
+ // TODO(vsm): Should we cache to try to get reference equality?
+ return new _WindowCrossFrameImpl._(ptr);
+ }
+ }
+
+ operator ==(other) {
+ return (other is _WindowCrossFrameImpl) &&
+ (this._ptr === other._ptr);
+ }
+}
+
class _AbstractWorkerImpl extends _EventTargetImpl implements AbstractWorker native "*AbstractWorker" {
_AbstractWorkerEventsImpl get on() =>
@@ -4730,8 +4868,11 @@ class _DocumentImpl extends _NodeImpl
String cookie;
- _WindowImpl get window() native "return this.defaultView;";
+ _WindowImpl get _window() native "return this.defaultView;";
+ Window get window() {
+ return _WindowCrossFrameImpl._createSafe(_window);
+ }
final _ElementImpl documentElement;
final String domain;
@@ -7214,10 +7355,11 @@ class _FormElementImpl extends _ElementImpl implements FormElement native "*HTML
class _FrameElementImpl extends _ElementImpl implements FrameElement native "*HTMLFrameElement" {
- final _DocumentImpl contentDocument;
-
- final _WindowImpl contentWindow;
+ _WindowImpl get _contentWindow() native "return this.contentWindow;";
+ Window get contentWindow() {
+ return _WindowCrossFrameImpl._createSafe(_contentWindow);
+ }
String frameBorder;
final int height;
@@ -7753,10 +7895,11 @@ class _IFrameElementImpl extends _ElementImpl implements IFrameElement native "*
String align;
- final _DocumentImpl contentDocument;
-
- final _WindowImpl contentWindow;
+ _WindowImpl get _contentWindow() native "return this.contentWindow;";
+ Window get contentWindow() {
+ return _WindowCrossFrameImpl._createSafe(_contentWindow);
+ }
String frameBorder;
String height;
@@ -8872,8 +9015,11 @@ class _MessageEventImpl extends _EventImpl implements MessageEvent native "*Mess
final List ports;
- final _WindowImpl source;
+ _WindowImpl get _source() native "return this.source;";
+ Window get source() {
+ return _WindowCrossFrameImpl._createSafe(_source);
+ }
void initMessageEvent(String typeArg, bool canBubbleArg, bool cancelableArg, Object dataArg, String originArg, String lastEventIdArg, _WindowImpl sourceArg, List messagePorts) native;
void webkitInitMessageEvent(String typeArg, bool canBubbleArg, bool cancelableArg, Object dataArg, String originArg, String lastEventIdArg, _WindowImpl sourceArg, List transferables) native;
@@ -9739,8 +9885,6 @@ class _ObjectElementImpl extends _ElementImpl implements ObjectElement native "*
String codeType;
- final _DocumentImpl contentDocument;
-
String data;
bool declare;
@@ -14872,8 +15016,11 @@ class _UIEventImpl extends _EventImpl implements UIEvent native "*UIEvent" {
final int pageY;
- final _WindowImpl view;
+ _WindowImpl get _view() native "return this.view;";
+ Window get view() {
+ return _WindowCrossFrameImpl._createSafe(_view);
+ }
final int which;
void initUIEvent(String type, bool canBubble, bool cancelable, _WindowImpl view, int detail) native;
@@ -16474,12 +16621,16 @@ class _WindowImpl extends _EventTargetImpl implements Window native "@*DOMWindow
final _EventImpl event;
- final _ElementImpl frameElement;
-
- final _WindowImpl frames;
+ _WindowImpl get _frames() native "return this.frames;";
- final _HistoryImpl history;
+ Window get frames() {
+ return _WindowCrossFrameImpl._createSafe(_frames);
+ }
+ _HistoryImpl get _history() native "return this.history;";
+ History get history() {
+ return _history;
+ }
final int innerHeight;
final int innerWidth;
@@ -16488,7 +16639,12 @@ class _WindowImpl extends _EventTargetImpl implements Window native "@*DOMWindow
final _StorageImpl localStorage;
- _LocationImpl location;
+ _LocationImpl get _location() native "return this.location;";
+
+ Location get location() {
+ return _location;
+ }
+ void set location(_LocationImpl value) native "this.location = value;";
final _BarInfoImpl locationbar;
@@ -16500,8 +16656,11 @@ class _WindowImpl extends _EventTargetImpl implements Window native "@*DOMWindow
final bool offscreenBuffering;
- final _WindowImpl opener;
+ _WindowImpl get _opener() native "return this.opener;";
+ Window get opener() {
+ return _WindowCrossFrameImpl._createSafe(_opener);
+ }
final int outerHeight;
final int outerWidth;
@@ -16510,8 +16669,11 @@ class _WindowImpl extends _EventTargetImpl implements Window native "@*DOMWindow
final int pageYOffset;
- final _WindowImpl parent;
+ _WindowImpl get _parent() native "return this.parent;";
+ Window get parent() {
+ return _WindowCrossFrameImpl._createSafe(_parent);
+ }
final _PerformanceImpl performance;
final _BarInfoImpl personalbar;
@@ -16532,8 +16694,11 @@ class _WindowImpl extends _EventTargetImpl implements Window native "@*DOMWindow
final _BarInfoImpl scrollbars;
- final _WindowImpl self;
+ _WindowImpl get _self() native "return this.self;";
+ Window get self() {
+ return _WindowCrossFrameImpl._createSafe(_self);
+ }
final _StorageImpl sessionStorage;
String status;
@@ -16544,16 +16709,17 @@ class _WindowImpl extends _EventTargetImpl implements Window native "@*DOMWindow
final _BarInfoImpl toolbar;
- final _WindowImpl top;
+ _WindowImpl get _top() native "return this.top;";
+ Window get top() {
+ return _WindowCrossFrameImpl._createSafe(_top);
+ }
final _IDBFactoryImpl webkitIndexedDB;
final _NotificationCenterImpl webkitNotifications;
final _StorageInfoImpl webkitStorageInfo;
- final _WindowImpl window;
-
void $dom_addEventListener(String type, EventListener listener, [bool useCapture = null]) native "addEventListener";
void alert(String message) native;
@@ -16592,7 +16758,9 @@ class _WindowImpl extends _EventTargetImpl implements Window native "@*DOMWindow
void moveTo(num x, num y) native;
- _WindowImpl open(String url, String name, [String options = null]) native;
+ _WindowImpl _open(String url, String name, [String options = null]) native "open";
+
+ Window open(String url, String name, [String options = null]) => _WindowCrossFrameImpl._createSafe(_open(url, name, options));
_DatabaseImpl openDatabase(String name, String version, String displayName, int estimatedSize, [DatabaseCallback creationCallback = null]) native;
@@ -23973,9 +24141,6 @@ interface FormElement extends Element {
/// @domName HTMLFrameElement
interface FrameElement extends Element {
- /** @domName HTMLFrameElement.contentDocument */
- final Document contentDocument;
-
/** @domName HTMLFrameElement.contentWindow */
final Window contentWindow;
@@ -24729,9 +24894,6 @@ interface IFrameElement extends Element {
/** @domName HTMLIFrameElement.align */
String align;
- /** @domName HTMLIFrameElement.contentDocument */
- final Document contentDocument;
-
/** @domName HTMLIFrameElement.contentWindow */
final Window contentWindow;
@@ -26889,9 +27051,6 @@ interface ObjectElement extends Element {
/** @domName HTMLObjectElement.codeType */
String codeType;
- /** @domName HTMLObjectElement.contentDocument */
- final Document contentDocument;
-
/** @domName HTMLObjectElement.data */
String data;
@@ -34575,9 +34734,6 @@ interface Window extends EventTarget {
/** @domName DOMWindow.event */
final Event event;
- /** @domName DOMWindow.frameElement */
- final Element frameElement;
-
/** @domName DOMWindow.frames */
final Window frames;
@@ -34692,9 +34848,6 @@ interface Window extends EventTarget {
/** @domName DOMWindow.webkitStorageInfo */
final StorageInfo webkitStorageInfo;
- /** @domName DOMWindow.window */
- final Window window;
-
/** @domName DOMWindow.addEventListener */
void $dom_addEventListener(String type, EventListener listener, [bool useCapture]);

Powered by Google App Engine
This is Rietveld 408576698