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

Unified Diff: pkg/web_components/lib/platform.concat.js

Issue 612533004: Revert "update platform.js to get memory leak fixes" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: update version Created 6 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 | « pkg/web_components/lib/platform.js ('k') | pkg/web_components/lib/platform.concat.js.map » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/web_components/lib/platform.concat.js
diff --git a/pkg/web_components/lib/platform.concat.js b/pkg/web_components/lib/platform.concat.js
index c78254b965db32c4aeb1b5d63c2925d52f559cb2..dccbcc9246c1c8a4aaf3786ca2ea16b3a480bba5 100644
--- a/pkg/web_components/lib/platform.concat.js
+++ b/pkg/web_components/lib/platform.concat.js
@@ -2317,13 +2317,7 @@ window.ShadowDOMPolyfill = {};
var globalMutationObservers = [];
var isScheduled = false;
- function scheduleCallback(observer) {
- if (observer.scheduled_)
- return;
-
- observer.scheduled_ = true;
- globalMutationObservers.push(observer);
-
+ function scheduleCallback() {
if (isScheduled)
return;
setEndOfMicrotask(notifyObservers);
@@ -2343,7 +2337,6 @@ window.ShadowDOMPolyfill = {};
for (var i = 0; i < notifyList.length; i++) {
var mo = notifyList[i];
- mo.scheduled_ = false;
var queue = mo.takeRecords();
removeTransientObserversFor(mo);
if (queue.length) {
@@ -2459,6 +2452,8 @@ window.ShadowDOMPolyfill = {};
}
}
+ var anyObserversEnqueued = false;
+
// 4.
for (var uid in interestedObservers) {
var observer = interestedObservers[uid];
@@ -2491,9 +2486,15 @@ window.ShadowDOMPolyfill = {};
record.oldValue = associatedStrings[uid];
// 8.
- scheduleCallback(observer);
+ if (!observer.records_.length) {
+ globalMutationObservers.push(observer);
+ anyObserversEnqueued = true;
+ }
observer.records_.push(record);
}
+
+ if (anyObserversEnqueued)
+ scheduleCallback();
}
var slice = Array.prototype.slice;
@@ -2556,7 +2557,6 @@ window.ShadowDOMPolyfill = {};
this.nodes_ = [];
this.records_ = [];
this.uid_ = ++uidCounter;
- this.scheduled_ = false;
}
MutationObserver.prototype = {
@@ -2642,10 +2642,6 @@ window.ShadowDOMPolyfill = {};
if (node === this.target)
return;
- // Make sure we remove transient observers at the end of microtask, even
- // if we didn't get any change records.
- scheduleCallback(this.observer);
-
this.transientObservedNodes.push(node);
var registrations = registrationsTable.get(node);
if (!registrations)
@@ -11377,7 +11373,10 @@ function watchShadow(node) {
}
function watchRoot(root) {
- observe(root);
+ if (!root.__watched) {
+ observe(root);
+ root.__watched = true;
+ }
}
function handler(mutations) {
@@ -11422,32 +11421,18 @@ function handler(mutations) {
logFlags.dom && console.groupEnd();
};
-function takeRecords(node) {
- // If the optional node is not supplied, assume we mean the whole document.
- if (node === undefined) node = document;
-
- // Find the root of the tree, which will be an Document or ShadowRoot.
- while (node.parentNode) {
- node = node.parentNode;
- }
+var observer = new MutationObserver(handler);
- var observer = node.__observer;
- if (observer) {
- handler(observer.takeRecords());
- takeMutations();
- }
+function takeRecords() {
+ // TODO(sjmiles): ask Raf why we have to call handler ourselves
+ handler(observer.takeRecords());
+ takeMutations();
}
var forEach = Array.prototype.forEach.call.bind(Array.prototype.forEach);
function observe(inRoot) {
- if (inRoot.__observer) return;
-
- // For each ShadowRoot, we create a new MutationObserver, so the root can be
- // garbage collected once all references to the `inRoot` node are gone.
- var observer = new MutationObserver(handler);
observer.observe(inRoot, {childList: true, subtree: true});
- inRoot.__observer = observer;
}
function observeDocument(doc) {
« no previous file with comments | « pkg/web_components/lib/platform.js ('k') | pkg/web_components/lib/platform.concat.js.map » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698