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

Unified Diff: tools/dom/templates/html/dartium/html_dartium.darttemplate

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:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/templates/html/dartium/html_dartium.darttemplate
diff --git a/tools/dom/templates/html/dartium/html_dartium.darttemplate b/tools/dom/templates/html/dartium/html_dartium.darttemplate
index b15dab237afe597501927d563a74b151841e4748..da243101c720fddc74e2ea0293c7ae0b370a006c 100644
--- a/tools/dom/templates/html/dartium/html_dartium.darttemplate
+++ b/tools/dom/templates/html/dartium/html_dartium.darttemplate
@@ -394,6 +394,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
@@ -420,6 +426,7 @@ wrap_jso(jsObject) {
if (func != null) {
dartClass_instance = func();
dartClass_instance.blink_jsObject = jsObject;
+ jsObject['dartClass_instance'] = dartClass_instance;
}
}
return dartClass_instance;
@@ -435,6 +442,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
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698