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

Side by Side Diff: tools/dom/src/native_DOMImplementation.dart

Issue 1873933002: Fix handling of cross-origin windows in dartium and better align general handling of different fram… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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:
View unified diff | Download patch
OLDNEW
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 part of html; 5 part of html;
6 6
7 class _Property { 7 class _Property {
8 _Property(this.name) 8 _Property(this.name)
9 : _hasValue = false, 9 : _hasValue = false,
10 writable = false, 10 writable = false,
(...skipping 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
1058 } 1058 }
1059 1059
1060 static void _register(Document document, String tag, Type customType, 1060 static void _register(Document document, String tag, Type customType,
1061 String extendsTagName) => 1061 String extendsTagName) =>
1062 _blink.Blink_Utils.register(document, tag, customType, extendsTagName); 1062 _blink.Blink_Utils.register(document, tag, customType, extendsTagName);
1063 1063
1064 static Element createElement(Document document, String tagName) => 1064 static Element createElement(Document document, String tagName) =>
1065 _blink.Blink_Utils.createElement(document, tagName); 1065 _blink.Blink_Utils.createElement(document, tagName);
1066 } 1066 }
1067 1067
1068 // TODO(jacobr): this seems busted. I believe we are actually
1069 // giving users real windows for opener, parent, top, etc.
1070 // Or worse, we are probaly returning a raw JSObject.
1071 class _DOMWindowCrossFrame extends DartHtmlDomObject implements WindowBase { 1068 class _DOMWindowCrossFrame extends DartHtmlDomObject implements WindowBase {
1072 _DOMWindowCrossFrame.internal(); 1069 _DOMWindowCrossFrame.internal();
1073 1070
1074 static _createSafe(win) => 1071 static _createSafe(win) =>
1075 _blink.Blink_Utils.setInstanceInterceptor(win, _DOMWindowCrossFrame); 1072 win is _DOMWindowCrossFrame ? win : _blink.Blink_Utils.setInstanceIntercepto r(win, _DOMWindowCrossFrame);
1076 1073
1077 // Fields. 1074 // Fields.
1078 HistoryBase get history => _blink.Blink_DOMWindowCrossFrame.get_history(this); 1075 HistoryBase get history {
1079 LocationBase get location => 1076 var history = _blink.BlinkWindow.instance.history_Getter_(this);
1080 _blink.Blink_DOMWindowCrossFrame.get_location(this); 1077 return history is _HistoryCrossFrame ? history : _blink.Blink_Utils.setInsta nceInterceptor(history, _HistoryCrossFrame);
1081 bool get closed => _blink.Blink_DOMWindowCrossFrame.get_closed(this); 1078 }
1082 WindowBase get opener => _blink.Blink_DOMWindowCrossFrame.get_opener(this); 1079
1083 WindowBase get parent => _blink.Blink_DOMWindowCrossFrame.get_parent(this); 1080 LocationBase get location {
1084 WindowBase get top => _blink.Blink_DOMWindowCrossFrame.get_top(this); 1081 var location = _blink.BlinkWindow.instance.location_Getter_(this);
1082 return location is _LocationCrossFrame ? location : _blink.Blink_Utils.setIn stanceInterceptor(location, _LocationCrossFrame);
1083 }
1084
1085 bool get closed => _blink.BlinkWindow.instance.closed_Getter_(this);
1086 WindowBase get opener => _convertNativeToDart_Window(_blink.BlinkWindow.instan ce.opener_Getter_(this));
1087 WindowBase get parent => _convertNativeToDart_Window(_blink.BlinkWindow.instan ce.parent_Getter_(this));
1088 WindowBase get top => _convertNativeToDart_Window(_blink.BlinkWindow.instance. top_Getter_(this));
1085 1089
1086 // Methods. 1090 // Methods.
1087 void close() => _blink.Blink_DOMWindowCrossFrame.close(this); 1091 void close() => _blink.BlinkWindow.instance.close_Callback_0_(this);
1088 void postMessage(/*SerializedScriptValue*/ message, String targetOrigin, 1092 void postMessage(Object message, String targetOrigin, [List<MessagePort> trans fer]) => _blink.BlinkWindow.instance.postMessage_Callback_3_(this, convertDartTo Native_SerializedScriptValue(message), targetOrigin, transfer);
1089 [List messagePorts]) =>
1090 _blink.Blink_DOMWindowCrossFrame.postMessage(
1091 this,
1092 convertDartToNative_SerializedScriptValue(message),
1093 targetOrigin,
1094 messagePorts);
1095 1093
1096 // Implementation support. 1094 // Implementation support.
1097 String get typeName => "Window"; 1095 String get typeName => "Window";
1098 1096
1099 // TODO(efortuna): Remove this method. dartbug.com/16814 1097 // TODO(efortuna): Remove this method. dartbug.com/16814
1100 Events get on => throw new UnsupportedError( 1098 Events get on => throw new UnsupportedError(
1101 'You can only attach EventListeners to your own window.'); 1099 'You can only attach EventListeners to your own window.');
1102 // TODO(efortuna): Remove this method. dartbug.com/16814 1100 // TODO(efortuna): Remove this method. dartbug.com/16814
1103 void _addEventListener( 1101 void _addEventListener(
1104 [String type, EventListener listener, bool useCapture]) => 1102 [String type, EventListener listener, bool useCapture]) =>
(...skipping 16 matching lines...) Expand all
1121 void removeEventListener(String type, EventListener listener, 1119 void removeEventListener(String type, EventListener listener,
1122 [bool useCapture]) => 1120 [bool useCapture]) =>
1123 throw new UnsupportedError( 1121 throw new UnsupportedError(
1124 'You can only attach EventListeners to your own window.'); 1122 'You can only attach EventListeners to your own window.');
1125 } 1123 }
1126 1124
1127 class _HistoryCrossFrame extends DartHtmlDomObject implements HistoryBase { 1125 class _HistoryCrossFrame extends DartHtmlDomObject implements HistoryBase {
1128 _HistoryCrossFrame.internal(); 1126 _HistoryCrossFrame.internal();
1129 1127
1130 // Methods. 1128 // Methods.
1131 void back() => _blink.Blink_HistoryCrossFrame.back(this); 1129 void back() => _blink.BlinkHistory.instance.back_Callback_0_(this);
1132 void forward() => _blink.Blink_HistoryCrossFrame.forward(this); 1130 void forward() => _blink.BlinkHistory.instance.forward_Callback_0_(this);
1133 void go(int distance) => _blink.Blink_HistoryCrossFrame.go(this, distance); 1131 void go([int delta]) {
1132 if (delta != null) {
1133 _blink.BlinkHistory.instance.go_Callback_1_(this, delta);
1134 return;
1135 }
1136 _blink.BlinkHistory.instance.go_Callback_0_(this);
1137 return;
1138 }
1134 1139
1135 // Implementation support. 1140 // Implementation support.
1136 String get typeName => "History"; 1141 String get typeName => "History";
1137 } 1142 }
1138 1143
1139 class _LocationCrossFrame extends DartHtmlDomObject implements LocationBase { 1144 class _LocationCrossFrame extends DartHtmlDomObject implements LocationBase {
1140 _LocationCrossFrame.internal(); 1145 _LocationCrossFrame.internal();
1141 1146
1142 // Fields. 1147 // Fields.
1143 set href(String h) => _blink.Blink_LocationCrossFrame.set_href(this, h); 1148 set href(String value) => _blink.BlinkLocation.instance.href_Setter_(this, val ue);
1144 1149
1145 // Implementation support. 1150 // Implementation support.
1146 String get typeName => "Location"; 1151 String get typeName => "Location";
1147 } 1152 }
1148 1153
1149 // TODO(vsm): Remove DOM isolate code once we have Dartium isolates 1154 // TODO(vsm): Remove DOM isolate code once we have Dartium isolates
1150 // as workers. This is only used to support 1155 // as workers. This is only used to support
1151 // printing and timers in background isolates. As workers they should 1156 // printing and timers in background isolates. As workers they should
1152 // be able to just do those things natively. 1157 // be able to just do those things natively.
1153 1158
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 get _scheduleImmediateClosure => (void callback()) { 1365 get _scheduleImmediateClosure => (void callback()) {
1361 _scheduleImmediateHelper._schedule(callback); 1366 _scheduleImmediateHelper._schedule(callback);
1362 }; 1367 };
1363 1368
1364 get _pureIsolateScheduleImmediateClosure => ((void callback()) => 1369 get _pureIsolateScheduleImmediateClosure => ((void callback()) =>
1365 throw new UnimplementedError("scheduleMicrotask in background isolates " 1370 throw new UnimplementedError("scheduleMicrotask in background isolates "
1366 "are not supported in the browser")); 1371 "are not supported in the browser"));
1367 1372
1368 // Class for unsupported native browser 'DOM' objects. 1373 // Class for unsupported native browser 'DOM' objects.
1369 class _UnsupportedBrowserObject extends DartHtmlDomObject {} 1374 class _UnsupportedBrowserObject extends DartHtmlDomObject {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698