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

Unified Diff: pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart

Issue 2980853002: Registration-based approach to cross frame support. (Closed)
Patch Set: Update dart:html Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart
diff --git a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart
index fdaffe8312549fa9a602d278f2355638f2df4e7e..e45ae7be059fe8e28c285a59ce37b66f1d2d2b9d 100644
--- a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart
+++ b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart
@@ -439,14 +439,13 @@ void _installPropertiesForObject(jsProto) {
}
}
-/// Copy symbols from the prototype of the source to destination.
-/// These are the only properties safe to copy onto an existing public
-/// JavaScript class.
-registerExtension(jsType, dartExtType) => JS(
+final _extensionMap = JS('', 'new Map()');
+
+_applyExtension(jsType, dartExtType) => JS(
'',
'''(() => {
// TODO(vsm): Not all registered js types are real.
- if (!jsType) return;
+ if (!$jsType) return;
let jsProto = $jsType.prototype;
@@ -471,6 +470,22 @@ registerExtension(jsType, dartExtType) => JS(
updateSig($_setterSig);
})()''');
+/// Apply all registered extensions to a window. This is intended for
+/// different frames, where registrations need to be reapplied.
+applyAllExtensions(global) {
+ JS('', '#.forEach((dartExtType, name) => #(#[name], dartExtType))',
+ _extensionMap, _applyExtension, global);
+}
+
+/// Copy symbols from the prototype of the source to destination.
+/// These are the only properties safe to copy onto an existing public
+/// JavaScript class.
+registerExtension(name, dartExtType) {
+ JS('', '#.set(#, #)', _extensionMap, name, dartExtType);
+ var jsType = JS('', '#[#]', global_, name);
+ _applyExtension(jsType, dartExtType);
+}
+
///
/// Mark a concrete type as implementing extension methods.
/// For example: `class MyIter implements Iterable`.

Powered by Google App Engine
This is Rietveld 408576698