Chromium Code Reviews| 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..c532995de51acb6b6c7dc35b705e46a6479047d7 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", |
| NodeInserted: "NodeInserted", |
| NodeInspected: "NodeInspected", |
| NodeRemoved: "NodeRemoved", |
| @@ -1126,6 +1127,28 @@ WebInspector.DOMModel.cancelSearch = function() |
| } |
| WebInspector.DOMModel.prototype = { |
| + |
| + _fireMutationEvent: function() |
|
pfeldman
2015/05/05 14:13:07
_scheduleMutationEvent
sergeyv
2015/05/06 08:35:54
Done.
|
| + { |
| + 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._fireMutationEvent(); |
| }, |
| /** |
| @@ -1443,6 +1467,7 @@ WebInspector.DOMModel.prototype = { |
| parent._removeChild(node); |
| this._unbind(node); |
| this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeRemoved, {node: node, parent: parent}); |
| + this._fireMutationEvent(); |
| }, |
| /** |
| @@ -1459,6 +1484,7 @@ WebInspector.DOMModel.prototype = { |
| this._idToDOMNode[node.id] = node; |
| host._shadowRoots.unshift(node); |
| this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeInserted, node); |
| + this._fireMutationEvent(); |
| }, |
| /** |
| @@ -1476,6 +1502,7 @@ WebInspector.DOMModel.prototype = { |
| host._removeChild(root); |
| this._unbind(root); |
| this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeRemoved, {node: root, parent: host}); |
| + this._fireMutationEvent(); |
| }, |
| /** |
| @@ -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._fireMutationEvent(); |
| }, |
| /** |
| @@ -1510,6 +1538,7 @@ WebInspector.DOMModel.prototype = { |
| parent._removeChild(pseudoElement); |
| this._unbind(pseudoElement); |
| this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeRemoved, {node: pseudoElement, parent: parent}); |
| + this._fireMutationEvent(); |
| }, |
| /** |
| @@ -1523,6 +1552,7 @@ WebInspector.DOMModel.prototype = { |
| return; |
| insertionPoint._setDistributedNodePayloads(distributedNodes); |
| this.dispatchEventToListeners(WebInspector.DOMModel.Events.DistributedNodesChanged, insertionPoint); |
| + this._fireMutationEvent(); |
| }, |
| /** |