Index: Source/devtools/front_end/sdk/DOMModel.js |
diff --git a/Source/devtools/front_end/sdk/DOMModel.js b/Source/devtools/front_end/sdk/DOMModel.js |
index 614cad6fcc441a940fd7fd94d44e0cc4beb89236..711d1368ccb70b808d9874b37a0ca32662a19adf 100644 |
--- a/Source/devtools/front_end/sdk/DOMModel.js |
+++ b/Source/devtools/front_end/sdk/DOMModel.js |
@@ -1076,6 +1076,7 @@ WebInspector.DOMModel.Events = { |
AttrModified: "AttrModified", |
AttrRemoved: "AttrRemoved", |
CharacterDataModified: "CharacterDataModified", |
+ DOMMutated: "DOMMutated", |
lushnikov
2015/05/26 16:10:45
can we call this DOMMutatedThrottled to differenti
|
NodeInserted: "NodeInserted", |
NodeInspected: "NodeInspected", |
NodeRemoved: "NodeRemoved", |
@@ -1126,6 +1127,28 @@ WebInspector.DOMModel.cancelSearch = function() |
} |
WebInspector.DOMModel.prototype = { |
+ |
+ _scheduleMutationEvent: function() |
+ { |
+ if (!this.hasEventListeners(WebInspector.DOMModel.Events.DOMMutated)) |
+ return; |
+ |
+ this._lastMutationId = (this._lastMutationId || 0) + 1; |
+ Promise.resolve().then(callObserve.bind(this, this._lastMutationId)); |
+ |
+ /** |
+ * @this {WebInspector.DOMModel} |
+ * @param {number} mutationId |
+ */ |
+ function callObserve(mutationId) |
+ { |
+ if (!this.hasEventListeners(WebInspector.DOMModel.Events.DOMMutated) || this._lastMutationId !== mutationId) |
+ return; |
+ |
+ this.dispatchEventToListeners(WebInspector.DOMModel.Events.DOMMutated); |
+ } |
+ }, |
+ |
/** |
* @param {function(!WebInspector.DOMDocument)=} callback |
*/ |
@@ -1430,6 +1453,7 @@ WebInspector.DOMModel.prototype = { |
var node = parent._insertChild(prev, payload); |
this._idToDOMNode[node.id] = node; |
this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeInserted, node); |
+ this._scheduleMutationEvent(); |
}, |
/** |
@@ -1443,6 +1467,7 @@ WebInspector.DOMModel.prototype = { |
parent._removeChild(node); |
this._unbind(node); |
this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeRemoved, {node: node, parent: parent}); |
+ this._scheduleMutationEvent(); |
}, |
/** |
@@ -1459,6 +1484,7 @@ WebInspector.DOMModel.prototype = { |
this._idToDOMNode[node.id] = node; |
host._shadowRoots.unshift(node); |
this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeInserted, node); |
+ this._scheduleMutationEvent(); |
}, |
/** |
@@ -1476,6 +1502,7 @@ WebInspector.DOMModel.prototype = { |
host._removeChild(root); |
this._unbind(root); |
this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeRemoved, {node: root, parent: host}); |
+ this._scheduleMutationEvent(); |
}, |
/** |
@@ -1493,6 +1520,7 @@ WebInspector.DOMModel.prototype = { |
console.assert(!parent._pseudoElements.get(node.pseudoType())); |
parent._pseudoElements.set(node.pseudoType(), node); |
this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeInserted, node); |
+ this._scheduleMutationEvent(); |
}, |
/** |
@@ -1510,6 +1538,7 @@ WebInspector.DOMModel.prototype = { |
parent._removeChild(pseudoElement); |
this._unbind(pseudoElement); |
this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeRemoved, {node: pseudoElement, parent: parent}); |
+ this._scheduleMutationEvent(); |
}, |
/** |
@@ -1523,6 +1552,7 @@ WebInspector.DOMModel.prototype = { |
return; |
insertionPoint._setDistributedNodePayloads(distributedNodes); |
this.dispatchEventToListeners(WebInspector.DOMModel.Events.DistributedNodesChanged, insertionPoint); |
+ this._scheduleMutationEvent(); |
}, |
/** |