| OLD | NEW |
| 1 <script> | 1 <script> |
| 2 function DOMAgent(delegate) { | 2 function DOMAgent(delegate) { |
| 3 this.enabled = false; | 3 this.enabled = false; |
| 4 this.delegate_ = delegate; | 4 this.delegate_ = delegate; |
| 5 this.nextNodeId_ = 1; | 5 this.nextNodeId_ = 1; |
| 6 this.nodeToId_ = new Map(); | 6 this.nodeToId_ = new Map(); |
| 7 this.idToNode_ = new Map(); | 7 this.idToNode_ = new Map(); |
| 8 } | 8 } |
| 9 | 9 |
| 10 DOMAgent.prototype.getIdForNode_ = function(node) { | 10 DOMAgent.prototype.getIdForNode_ = function(node) { |
| 11 if (this.nodeToId_.has(node)) | 11 if (this.nodeToId_.has(node)) |
| 12 return this.nodeToId_.get(node); | 12 return this.nodeToId_.get(node); |
| 13 var id = this.nextNodeId_++; | 13 var id = this.nextNodeId_++; |
| 14 this.nodeToId_.set(node, id); | 14 this.nodeToId_.set(node, id); |
| 15 this.idToNode_.set(id, node); | 15 this.idToNode_.set(id, node); |
| 16 return id; | 16 return id; |
| 17 }; | 17 }; |
| 18 | 18 |
| 19 DOMAgent.prototype.getNodeForId = function(nodeId) { |
| 20 return this.idToNode_.get(nodeId); |
| 21 }; |
| 22 |
| 19 DOMAgent.prototype.serializeChildren_ = function(node) { | 23 DOMAgent.prototype.serializeChildren_ = function(node) { |
| 20 var children = []; | 24 var children = []; |
| 21 for (var child = node.firstChild; child; child = child.nextSibling) { | 25 for (var child = node.firstChild; child; child = child.nextSibling) { |
| 22 var record = this.serializeNode_(child); | 26 var record = this.serializeNode_(child); |
| 23 if (record) | 27 if (record) |
| 24 children.push(record); | 28 children.push(record); |
| 25 } | 29 } |
| 26 return children; | 30 return children; |
| 27 }; | 31 }; |
| 28 | 32 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 previousNodeId: previousNodeId, | 160 previousNodeId: previousNodeId, |
| 157 node: this.serializeNode_(node), | 161 node: this.serializeNode_(node), |
| 158 }); | 162 }); |
| 159 }.bind(this)); | 163 }.bind(this)); |
| 160 } | 164 } |
| 161 } | 165 } |
| 162 }; | 166 }; |
| 163 | 167 |
| 164 this.exports = DOMAgent; | 168 this.exports = DOMAgent; |
| 165 </script> | 169 </script> |
| OLD | NEW |