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

Unified Diff: sdk/lib/html/dartium/html_dartium.dart

Issue 1376083002: Cache all wrap_jso results so we preserve identity (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « no previous file | tools/dom/templates/html/dartium/html_dartium.darttemplate » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/dartium/html_dartium.dart
diff --git a/sdk/lib/html/dartium/html_dartium.dart b/sdk/lib/html/dartium/html_dartium.dart
index 95c43f64b33d9239ec51225fad5095bae41037c2..0f6b5ac5d935ae4aa10a4e0e3d5d67da431b5ee3 100644
--- a/sdk/lib/html/dartium/html_dartium.dart
+++ b/sdk/lib/html/dartium/html_dartium.dart
@@ -1149,6 +1149,12 @@ wrap_jso(jsObject) {
// JS Interop converted the object to a Dart class e.g., Uint8ClampedList.
return jsObject;
}
+
+ // To preserve identity, if we already have a wrapper for this, return it.
+ var existing = jsObject['dartClass_instance'];
+ if (existing != null) {
+ return existing;
+ }
// Try the most general type conversions on it.
// TODO(alanknight): We may be able to do better. This maintains identity,
// which is useful, but expensive. And if we nest something that only
@@ -1165,7 +1171,6 @@ wrap_jso(jsObject) {
if (__interop_checks) {
debug_or_assert("constructor != null && jsTypeName.length > 0", constructor != null && jsTypeName.length > 0);
}
-
var dartClass_instance;
if (jsObject.hasProperty('dart_class')) {
// Got a dart_class (it's a custom element) use it it's already set up.
@@ -1175,6 +1180,7 @@ wrap_jso(jsObject) {
if (func != null) {
dartClass_instance = func();
dartClass_instance.blink_jsObject = jsObject;
+ jsObject['dartClass_instance'] = dartClass_instance;
}
}
return dartClass_instance;
@@ -1190,6 +1196,7 @@ wrap_jso(jsObject) {
return null;
}
+
/**
* Create Dart class that maps to the JS Type that is the JS type being
* extended using JS interop createCallback (we need the base type of the
@@ -37168,10 +37175,10 @@ class Url extends NativeFieldWrapperClass2 implements UrlUtils {
if ((blob_OR_source_OR_stream is Blob || blob_OR_source_OR_stream == null)) {
return _blink.BlinkURL.instance.createObjectURL_Callback_1_(unwrap_jso(blob_OR_source_OR_stream));
}
- if ((blob_OR_source_OR_stream is MediaStream)) {
+ if ((blob_OR_source_OR_stream is MediaSource)) {
return _blink.BlinkURL.instance.createObjectURL_Callback_1_(unwrap_jso(blob_OR_source_OR_stream));
}
- if ((blob_OR_source_OR_stream is MediaSource)) {
+ if ((blob_OR_source_OR_stream is MediaStream)) {
return _blink.BlinkURL.instance.createObjectURL_Callback_1_(unwrap_jso(blob_OR_source_OR_stream));
}
throw new ArgumentError("Incorrect number or type of arguments");
« no previous file with comments | « no previous file | tools/dom/templates/html/dartium/html_dartium.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698