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

Side by Side Diff: sky/framework/inspector/dom-agent.sky

Issue 662523003: Add a very minimal CSSAgent (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch
OLDNEW
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
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>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698