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

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

Issue 1883513004: Revert "Revert "Fix handling of cross-origin windows in dartium and better align general handling o… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fix bug 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 if (identical(win, window)) {
1073 // The current Window object is the only window object that should not
1074 // use _DOMWindowCrossFrame.
1075 return window;
1076 }
1077 return win is _DOMWindowCrossFrame ? win : _blink.Blink_Utils.setInstanceInt erceptor(win, _DOMWindowCrossFrame);
1078 }
1076 1079
1077 // Fields. 1080 // Fields.
1078 HistoryBase get history => _blink.Blink_DOMWindowCrossFrame.get_history(this); 1081 HistoryBase get history {
1079 LocationBase get location => 1082 var history = _blink.BlinkWindow.instance.history_Getter_(this);
1080 _blink.Blink_DOMWindowCrossFrame.get_location(this); 1083 return history is _HistoryCrossFrame ? history : _blink.Blink_Utils.setInsta nceInterceptor(history, _HistoryCrossFrame);
1081 bool get closed => _blink.Blink_DOMWindowCrossFrame.get_closed(this); 1084 }
1082 WindowBase get opener => _blink.Blink_DOMWindowCrossFrame.get_opener(this); 1085
1083 WindowBase get parent => _blink.Blink_DOMWindowCrossFrame.get_parent(this); 1086 LocationBase get location {
1084 WindowBase get top => _blink.Blink_DOMWindowCrossFrame.get_top(this); 1087 var location = _blink.BlinkWindow.instance.location_Getter_(this);
1088 return location is _LocationCrossFrame ? location : _blink.Blink_Utils.setIn stanceInterceptor(location, _LocationCrossFrame);
1089 }
1090
1091 bool get closed => _blink.BlinkWindow.instance.closed_Getter_(this);
1092 WindowBase get opener => _convertNativeToDart_Window(_blink.BlinkWindow.instan ce.opener_Getter_(this));
1093 WindowBase get parent => _convertNativeToDart_Window(_blink.BlinkWindow.instan ce.parent_Getter_(this));
1094 WindowBase get top => _convertNativeToDart_Window(_blink.BlinkWindow.instance. top_Getter_(this));
1085 1095
1086 // Methods. 1096 // Methods.
1087 void close() => _blink.Blink_DOMWindowCrossFrame.close(this); 1097 void close() => _blink.BlinkWindow.instance.close_Callback_0_(this);
1088 void postMessage(/*SerializedScriptValue*/ message, String targetOrigin, 1098 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 1099
1096 // Implementation support. 1100 // Implementation support.
1097 String get typeName => "Window"; 1101 String get typeName => "Window";
1098 1102
1099 // TODO(efortuna): Remove this method. dartbug.com/16814 1103 // TODO(efortuna): Remove this method. dartbug.com/16814
1100 Events get on => throw new UnsupportedError( 1104 Events get on => throw new UnsupportedError(
1101 'You can only attach EventListeners to your own window.'); 1105 'You can only attach EventListeners to your own window.');
1102 // TODO(efortuna): Remove this method. dartbug.com/16814 1106 // TODO(efortuna): Remove this method. dartbug.com/16814
1103 void _addEventListener( 1107 void _addEventListener(
1104 [String type, EventListener listener, bool useCapture]) => 1108 [String type, EventListener listener, bool useCapture]) =>
(...skipping 16 matching lines...) Expand all
1121 void removeEventListener(String type, EventListener listener, 1125 void removeEventListener(String type, EventListener listener,
1122 [bool useCapture]) => 1126 [bool useCapture]) =>
1123 throw new UnsupportedError( 1127 throw new UnsupportedError(
1124 'You can only attach EventListeners to your own window.'); 1128 'You can only attach EventListeners to your own window.');
1125 } 1129 }
1126 1130
1127 class _HistoryCrossFrame extends DartHtmlDomObject implements HistoryBase { 1131 class _HistoryCrossFrame extends DartHtmlDomObject implements HistoryBase {
1128 _HistoryCrossFrame.internal(); 1132 _HistoryCrossFrame.internal();
1129 1133
1130 // Methods. 1134 // Methods.
1131 void back() => _blink.Blink_HistoryCrossFrame.back(this); 1135 void back() => _blink.BlinkHistory.instance.back_Callback_0_(this);
1132 void forward() => _blink.Blink_HistoryCrossFrame.forward(this); 1136 void forward() => _blink.BlinkHistory.instance.forward_Callback_0_(this);
1133 void go(int distance) => _blink.Blink_HistoryCrossFrame.go(this, distance); 1137 void go([int delta]) {
1138 if (delta != null) {
1139 _blink.BlinkHistory.instance.go_Callback_1_(this, delta);
1140 return;
1141 }
1142 _blink.BlinkHistory.instance.go_Callback_0_(this);
1143 return;
1144 }
1134 1145
1135 // Implementation support. 1146 // Implementation support.
1136 String get typeName => "History"; 1147 String get typeName => "History";
1137 } 1148 }
1138 1149
1139 class _LocationCrossFrame extends DartHtmlDomObject implements LocationBase { 1150 class _LocationCrossFrame extends DartHtmlDomObject implements LocationBase {
1140 _LocationCrossFrame.internal(); 1151 _LocationCrossFrame.internal();
1141 1152
1142 // Fields. 1153 // Fields.
1143 set href(String h) => _blink.Blink_LocationCrossFrame.set_href(this, h); 1154 set href(String value) => _blink.BlinkLocation.instance.href_Setter_(this, val ue);
1144 1155
1145 // Implementation support. 1156 // Implementation support.
1146 String get typeName => "Location"; 1157 String get typeName => "Location";
1147 } 1158 }
1148 1159
1149 // TODO(vsm): Remove DOM isolate code once we have Dartium isolates 1160 // TODO(vsm): Remove DOM isolate code once we have Dartium isolates
1150 // as workers. This is only used to support 1161 // as workers. This is only used to support
1151 // printing and timers in background isolates. As workers they should 1162 // printing and timers in background isolates. As workers they should
1152 // be able to just do those things natively. 1163 // be able to just do those things natively.
1153 1164
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 get _scheduleImmediateClosure => (void callback()) { 1371 get _scheduleImmediateClosure => (void callback()) {
1361 _scheduleImmediateHelper._schedule(callback); 1372 _scheduleImmediateHelper._schedule(callback);
1362 }; 1373 };
1363 1374
1364 get _pureIsolateScheduleImmediateClosure => ((void callback()) => 1375 get _pureIsolateScheduleImmediateClosure => ((void callback()) =>
1365 throw new UnimplementedError("scheduleMicrotask in background isolates " 1376 throw new UnimplementedError("scheduleMicrotask in background isolates "
1366 "are not supported in the browser")); 1377 "are not supported in the browser"));
1367 1378
1368 // Class for unsupported native browser 'DOM' objects. 1379 // Class for unsupported native browser 'DOM' objects.
1369 class _UnsupportedBrowserObject extends DartHtmlDomObject {} 1380 class _UnsupportedBrowserObject extends DartHtmlDomObject {}
OLDNEW
« no previous file with comments | « tools/dom/scripts/systemnative.py ('k') | tools/dom/templates/html/dartium/html_dartium.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698