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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/DOMModel.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 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 /* 1 /*
2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved.
3 * Copyright (C) 2009 Joseph Pecoraro 3 * Copyright (C) 2009 Joseph Pecoraro
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 14 matching lines...) Expand all
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32 /** 32 /**
33 * @unrestricted 33 * @unrestricted
34 */ 34 */
35 WebInspector.DOMNode = class extends WebInspector.SDKObject { 35 SDK.DOMNode = class extends SDK.SDKObject {
36 /** 36 /**
37 * @param {!WebInspector.DOMModel} domModel 37 * @param {!SDK.DOMModel} domModel
38 */ 38 */
39 constructor(domModel) { 39 constructor(domModel) {
40 super(domModel.target()); 40 super(domModel.target());
41 this._domModel = domModel; 41 this._domModel = domModel;
42 } 42 }
43 43
44 /** 44 /**
45 * @param {!WebInspector.DOMModel} domModel 45 * @param {!SDK.DOMModel} domModel
46 * @param {?WebInspector.DOMDocument} doc 46 * @param {?SDK.DOMDocument} doc
47 * @param {boolean} isInShadowTree 47 * @param {boolean} isInShadowTree
48 * @param {!Protocol.DOM.Node} payload 48 * @param {!Protocol.DOM.Node} payload
49 * @return {!WebInspector.DOMNode} 49 * @return {!SDK.DOMNode}
50 */ 50 */
51 static create(domModel, doc, isInShadowTree, payload) { 51 static create(domModel, doc, isInShadowTree, payload) {
52 var node = new WebInspector.DOMNode(domModel); 52 var node = new SDK.DOMNode(domModel);
53 node._init(doc, isInShadowTree, payload); 53 node._init(doc, isInShadowTree, payload);
54 return node; 54 return node;
55 } 55 }
56 56
57 /** 57 /**
58 * @param {?WebInspector.DOMDocument} doc 58 * @param {?SDK.DOMDocument} doc
59 * @param {boolean} isInShadowTree 59 * @param {boolean} isInShadowTree
60 * @param {!Protocol.DOM.Node} payload 60 * @param {!Protocol.DOM.Node} payload
61 */ 61 */
62 _init(doc, isInShadowTree, payload) { 62 _init(doc, isInShadowTree, payload) {
63 this._agent = this._domModel._agent; 63 this._agent = this._domModel._agent;
64 this.ownerDocument = doc; 64 this.ownerDocument = doc;
65 this._isInShadowTree = isInShadowTree; 65 this._isInShadowTree = isInShadowTree;
66 66
67 this.id = payload.nodeId; 67 this.id = payload.nodeId;
68 this._backendNodeId = payload.backendNodeId; 68 this._backendNodeId = payload.backendNodeId;
(...skipping 23 matching lines...) Expand all
92 92
93 this.nextSibling = null; 93 this.nextSibling = null;
94 this.previousSibling = null; 94 this.previousSibling = null;
95 this.firstChild = null; 95 this.firstChild = null;
96 this.lastChild = null; 96 this.lastChild = null;
97 this.parentNode = null; 97 this.parentNode = null;
98 98
99 if (payload.shadowRoots) { 99 if (payload.shadowRoots) {
100 for (var i = 0; i < payload.shadowRoots.length; ++i) { 100 for (var i = 0; i < payload.shadowRoots.length; ++i) {
101 var root = payload.shadowRoots[i]; 101 var root = payload.shadowRoots[i];
102 var node = WebInspector.DOMNode.create(this._domModel, this.ownerDocumen t, true, root); 102 var node = SDK.DOMNode.create(this._domModel, this.ownerDocument, true, root);
103 this._shadowRoots.push(node); 103 this._shadowRoots.push(node);
104 node.parentNode = this; 104 node.parentNode = this;
105 } 105 }
106 } 106 }
107 107
108 if (payload.templateContent) { 108 if (payload.templateContent) {
109 this._templateContent = 109 this._templateContent =
110 WebInspector.DOMNode.create(this._domModel, this.ownerDocument, true, payload.templateContent); 110 SDK.DOMNode.create(this._domModel, this.ownerDocument, true, payload.t emplateContent);
111 this._templateContent.parentNode = this; 111 this._templateContent.parentNode = this;
112 } 112 }
113 113
114 if (payload.importedDocument) { 114 if (payload.importedDocument) {
115 this._importedDocument = 115 this._importedDocument =
116 WebInspector.DOMNode.create(this._domModel, this.ownerDocument, true, payload.importedDocument); 116 SDK.DOMNode.create(this._domModel, this.ownerDocument, true, payload.i mportedDocument);
117 this._importedDocument.parentNode = this; 117 this._importedDocument.parentNode = this;
118 } 118 }
119 119
120 if (payload.distributedNodes) 120 if (payload.distributedNodes)
121 this._setDistributedNodePayloads(payload.distributedNodes); 121 this._setDistributedNodePayloads(payload.distributedNodes);
122 122
123 if (payload.children) 123 if (payload.children)
124 this._setChildrenPayload(payload.children); 124 this._setChildrenPayload(payload.children);
125 125
126 this._setPseudoElements(payload.pseudoElements); 126 this._setPseudoElements(payload.pseudoElements);
127 127
128 if (payload.contentDocument) { 128 if (payload.contentDocument) {
129 this._contentDocument = new WebInspector.DOMDocument(this._domModel, paylo ad.contentDocument); 129 this._contentDocument = new SDK.DOMDocument(this._domModel, payload.conten tDocument);
130 this._children = [this._contentDocument]; 130 this._children = [this._contentDocument];
131 this._renumber(); 131 this._renumber();
132 } 132 }
133 133
134 if (this._nodeType === Node.ELEMENT_NODE) { 134 if (this._nodeType === Node.ELEMENT_NODE) {
135 // HTML and BODY from internal iframes should not overwrite top-level ones . 135 // HTML and BODY from internal iframes should not overwrite top-level ones .
136 if (this.ownerDocument && !this.ownerDocument.documentElement && this._nod eName === 'HTML') 136 if (this.ownerDocument && !this.ownerDocument.documentElement && this._nod eName === 'HTML')
137 this.ownerDocument.documentElement = this; 137 this.ownerDocument.documentElement = this;
138 if (this.ownerDocument && !this.ownerDocument.body && this._nodeName === ' BODY') 138 if (this.ownerDocument && !this.ownerDocument.body && this._nodeName === ' BODY')
139 this.ownerDocument.body = this; 139 this.ownerDocument.body = this;
140 } else if (this._nodeType === Node.DOCUMENT_TYPE_NODE) { 140 } else if (this._nodeType === Node.DOCUMENT_TYPE_NODE) {
141 this.publicId = payload.publicId; 141 this.publicId = payload.publicId;
142 this.systemId = payload.systemId; 142 this.systemId = payload.systemId;
143 this.internalSubset = payload.internalSubset; 143 this.internalSubset = payload.internalSubset;
144 } else if (this._nodeType === Node.ATTRIBUTE_NODE) { 144 } else if (this._nodeType === Node.ATTRIBUTE_NODE) {
145 this.name = payload.name; 145 this.name = payload.name;
146 this.value = payload.value; 146 this.value = payload.value;
147 } 147 }
148 } 148 }
149 149
150 /** 150 /**
151 * @return {!WebInspector.DOMModel} 151 * @return {!SDK.DOMModel}
152 */ 152 */
153 domModel() { 153 domModel() {
154 return this._domModel; 154 return this._domModel;
155 } 155 }
156 156
157 /** 157 /**
158 * @return {number} 158 * @return {number}
159 */ 159 */
160 backendNodeId() { 160 backendNodeId() {
161 return this._backendNodeId; 161 return this._backendNodeId;
162 } 162 }
163 163
164 /** 164 /**
165 * @return {?Array.<!WebInspector.DOMNode>} 165 * @return {?Array.<!SDK.DOMNode>}
166 */ 166 */
167 children() { 167 children() {
168 return this._children ? this._children.slice() : null; 168 return this._children ? this._children.slice() : null;
169 } 169 }
170 170
171 /** 171 /**
172 * @return {boolean} 172 * @return {boolean}
173 */ 173 */
174 hasAttributes() { 174 hasAttributes() {
175 return this._attributes.length > 0; 175 return this._attributes.length > 0;
176 } 176 }
177 177
178 /** 178 /**
179 * @return {number} 179 * @return {number}
180 */ 180 */
181 childNodeCount() { 181 childNodeCount() {
182 return this._childNodeCount; 182 return this._childNodeCount;
183 } 183 }
184 184
185 /** 185 /**
186 * @return {boolean} 186 * @return {boolean}
187 */ 187 */
188 hasShadowRoots() { 188 hasShadowRoots() {
189 return !!this._shadowRoots.length; 189 return !!this._shadowRoots.length;
190 } 190 }
191 191
192 /** 192 /**
193 * @return {!Array.<!WebInspector.DOMNode>} 193 * @return {!Array.<!SDK.DOMNode>}
194 */ 194 */
195 shadowRoots() { 195 shadowRoots() {
196 return this._shadowRoots.slice(); 196 return this._shadowRoots.slice();
197 } 197 }
198 198
199 /** 199 /**
200 * @return {?WebInspector.DOMNode} 200 * @return {?SDK.DOMNode}
201 */ 201 */
202 templateContent() { 202 templateContent() {
203 return this._templateContent || null; 203 return this._templateContent || null;
204 } 204 }
205 205
206 /** 206 /**
207 * @return {?WebInspector.DOMNode} 207 * @return {?SDK.DOMNode}
208 */ 208 */
209 importedDocument() { 209 importedDocument() {
210 return this._importedDocument || null; 210 return this._importedDocument || null;
211 } 211 }
212 212
213 /** 213 /**
214 * @return {number} 214 * @return {number}
215 */ 215 */
216 nodeType() { 216 nodeType() {
217 return this._nodeType; 217 return this._nodeType;
(...skipping 14 matching lines...) Expand all
232 } 232 }
233 233
234 /** 234 /**
235 * @return {boolean} 235 * @return {boolean}
236 */ 236 */
237 hasPseudoElements() { 237 hasPseudoElements() {
238 return this._pseudoElements.size > 0; 238 return this._pseudoElements.size > 0;
239 } 239 }
240 240
241 /** 241 /**
242 * @return {!Map<string, !WebInspector.DOMNode>} 242 * @return {!Map<string, !SDK.DOMNode>}
243 */ 243 */
244 pseudoElements() { 244 pseudoElements() {
245 return this._pseudoElements; 245 return this._pseudoElements;
246 } 246 }
247 247
248 /** 248 /**
249 * @return {?WebInspector.DOMNode} 249 * @return {?SDK.DOMNode}
250 */ 250 */
251 beforePseudoElement() { 251 beforePseudoElement() {
252 if (!this._pseudoElements) 252 if (!this._pseudoElements)
253 return null; 253 return null;
254 return this._pseudoElements.get(WebInspector.DOMNode.PseudoElementNames.Befo re); 254 return this._pseudoElements.get(SDK.DOMNode.PseudoElementNames.Before);
255 } 255 }
256 256
257 /** 257 /**
258 * @return {?WebInspector.DOMNode} 258 * @return {?SDK.DOMNode}
259 */ 259 */
260 afterPseudoElement() { 260 afterPseudoElement() {
261 if (!this._pseudoElements) 261 if (!this._pseudoElements)
262 return null; 262 return null;
263 return this._pseudoElements.get(WebInspector.DOMNode.PseudoElementNames.Afte r); 263 return this._pseudoElements.get(SDK.DOMNode.PseudoElementNames.After);
264 } 264 }
265 265
266 /** 266 /**
267 * @return {boolean} 267 * @return {boolean}
268 */ 268 */
269 isInsertionPoint() { 269 isInsertionPoint() {
270 return !this.isXMLNode() && 270 return !this.isXMLNode() &&
271 (this._nodeName === 'SHADOW' || this._nodeName === 'CONTENT' || this._no deName === 'SLOT'); 271 (this._nodeName === 'SHADOW' || this._nodeName === 'CONTENT' || this._no deName === 'SLOT');
272 } 272 }
273 273
274 /** 274 /**
275 * @return {!Array.<!WebInspector.DOMNodeShortcut>} 275 * @return {!Array.<!SDK.DOMNodeShortcut>}
276 */ 276 */
277 distributedNodes() { 277 distributedNodes() {
278 return this._distributedNodes || []; 278 return this._distributedNodes || [];
279 } 279 }
280 280
281 /** 281 /**
282 * @return {boolean} 282 * @return {boolean}
283 */ 283 */
284 isInShadowTree() { 284 isInShadowTree() {
285 return this._isInShadowTree; 285 return this._isInShadowTree;
286 } 286 }
287 287
288 /** 288 /**
289 * @return {?WebInspector.DOMNode} 289 * @return {?SDK.DOMNode}
290 */ 290 */
291 ancestorShadowHost() { 291 ancestorShadowHost() {
292 var ancestorShadowRoot = this.ancestorShadowRoot(); 292 var ancestorShadowRoot = this.ancestorShadowRoot();
293 return ancestorShadowRoot ? ancestorShadowRoot.parentNode : null; 293 return ancestorShadowRoot ? ancestorShadowRoot.parentNode : null;
294 } 294 }
295 295
296 /** 296 /**
297 * @return {?WebInspector.DOMNode} 297 * @return {?SDK.DOMNode}
298 */ 298 */
299 ancestorShadowRoot() { 299 ancestorShadowRoot() {
300 if (!this._isInShadowTree) 300 if (!this._isInShadowTree)
301 return null; 301 return null;
302 302
303 var current = this; 303 var current = this;
304 while (current && !current.isShadowRoot()) 304 while (current && !current.isShadowRoot())
305 current = current.parentNode; 305 current = current.parentNode;
306 return current; 306 return current;
307 } 307 }
308 308
309 /** 309 /**
310 * @return {?WebInspector.DOMNode} 310 * @return {?SDK.DOMNode}
311 */ 311 */
312 ancestorUserAgentShadowRoot() { 312 ancestorUserAgentShadowRoot() {
313 var ancestorShadowRoot = this.ancestorShadowRoot(); 313 var ancestorShadowRoot = this.ancestorShadowRoot();
314 if (!ancestorShadowRoot) 314 if (!ancestorShadowRoot)
315 return null; 315 return null;
316 return ancestorShadowRoot.shadowRootType() === WebInspector.DOMNode.ShadowRo otTypes.UserAgent ? ancestorShadowRoot : 316 return ancestorShadowRoot.shadowRootType() === SDK.DOMNode.ShadowRootTypes.U serAgent ? ancestorShadowRoot :
317 null; 317 null;
318 } 318 }
319 319
320 /** 320 /**
321 * @return {boolean} 321 * @return {boolean}
322 */ 322 */
323 isShadowRoot() { 323 isShadowRoot() {
324 return !!this._shadowRootType; 324 return !!this._shadowRootType;
325 } 325 }
326 326
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 /** 402 /**
403 * @param {string} name 403 * @param {string} name
404 * @param {string} value 404 * @param {string} value
405 * @param {function(?Protocol.Error)=} callback 405 * @param {function(?Protocol.Error)=} callback
406 */ 406 */
407 setAttributeValue(name, value, callback) { 407 setAttributeValue(name, value, callback) {
408 this._agent.setAttributeValue(this.id, name, value, this._domModel._markRevi sion(this, callback)); 408 this._agent.setAttributeValue(this.id, name, value, this._domModel._markRevi sion(this, callback));
409 } 409 }
410 410
411 /** 411 /**
412 * @return {!Array<!WebInspector.DOMNode.Attribute>} 412 * @return {!Array<!SDK.DOMNode.Attribute>}
413 */ 413 */
414 attributes() { 414 attributes() {
415 return this._attributes; 415 return this._attributes;
416 } 416 }
417 417
418 /** 418 /**
419 * @param {string} name 419 * @param {string} name
420 * @param {function(?Protocol.Error)=} callback 420 * @param {function(?Protocol.Error)=} callback
421 */ 421 */
422 removeAttribute(name, callback) { 422 removeAttribute(name, callback) {
423 /** 423 /**
424 * @param {?Protocol.Error} error 424 * @param {?Protocol.Error} error
425 * @this {WebInspector.DOMNode} 425 * @this {SDK.DOMNode}
426 */ 426 */
427 function mycallback(error) { 427 function mycallback(error) {
428 if (!error) { 428 if (!error) {
429 delete this._attributesMap[name]; 429 delete this._attributesMap[name];
430 for (var i = 0; i < this._attributes.length; ++i) { 430 for (var i = 0; i < this._attributes.length; ++i) {
431 if (this._attributes[i].name === name) { 431 if (this._attributes[i].name === name) {
432 this._attributes.splice(i, 1); 432 this._attributes.splice(i, 1);
433 break; 433 break;
434 } 434 }
435 } 435 }
436 } 436 }
437 437
438 this._domModel._markRevision(this, callback)(error); 438 this._domModel._markRevision(this, callback)(error);
439 } 439 }
440 this._agent.removeAttribute(this.id, name, mycallback.bind(this)); 440 this._agent.removeAttribute(this.id, name, mycallback.bind(this));
441 } 441 }
442 442
443 /** 443 /**
444 * @param {function(?Array.<!WebInspector.DOMNode>)=} callback 444 * @param {function(?Array.<!SDK.DOMNode>)=} callback
445 */ 445 */
446 getChildNodes(callback) { 446 getChildNodes(callback) {
447 if (this._children) { 447 if (this._children) {
448 if (callback) 448 if (callback)
449 callback(this.children()); 449 callback(this.children());
450 return; 450 return;
451 } 451 }
452 452
453 /** 453 /**
454 * @this {WebInspector.DOMNode} 454 * @this {SDK.DOMNode}
455 * @param {?Protocol.Error} error 455 * @param {?Protocol.Error} error
456 */ 456 */
457 function mycallback(error) { 457 function mycallback(error) {
458 if (callback) 458 if (callback)
459 callback(error ? null : this.children()); 459 callback(error ? null : this.children());
460 } 460 }
461 461
462 this._agent.requestChildNodes(this.id, undefined, mycallback.bind(this)); 462 this._agent.requestChildNodes(this.id, undefined, mycallback.bind(this));
463 } 463 }
464 464
465 /** 465 /**
466 * @param {number} depth 466 * @param {number} depth
467 * @param {function(?Array.<!WebInspector.DOMNode>)=} callback 467 * @param {function(?Array.<!SDK.DOMNode>)=} callback
468 */ 468 */
469 getSubtree(depth, callback) { 469 getSubtree(depth, callback) {
470 /** 470 /**
471 * @this {WebInspector.DOMNode} 471 * @this {SDK.DOMNode}
472 * @param {?Protocol.Error} error 472 * @param {?Protocol.Error} error
473 */ 473 */
474 function mycallback(error) { 474 function mycallback(error) {
475 if (callback) 475 if (callback)
476 callback(error ? null : this._children); 476 callback(error ? null : this._children);
477 } 477 }
478 478
479 this._agent.requestChildNodes(this.id, depth, mycallback.bind(this)); 479 this._agent.requestChildNodes(this.id, depth, mycallback.bind(this));
480 } 480 }
481 481
(...skipping 30 matching lines...) Expand all
512 callback(error ? null : text); 512 callback(error ? null : text);
513 } 513 }
514 this._agent.getOuterHTML(this.id, copy); 514 this._agent.getOuterHTML(this.id, copy);
515 } 515 }
516 516
517 /** 517 /**
518 * @return {string} 518 * @return {string}
519 */ 519 */
520 path() { 520 path() {
521 /** 521 /**
522 * @param {?WebInspector.DOMNode} node 522 * @param {?SDK.DOMNode} node
523 */ 523 */
524 function canPush(node) { 524 function canPush(node) {
525 return node && ('index' in node || (node.isShadowRoot() && node.parentNode )) && node._nodeName.length; 525 return node && ('index' in node || (node.isShadowRoot() && node.parentNode )) && node._nodeName.length;
526 } 526 }
527 527
528 var path = []; 528 var path = [];
529 var node = this; 529 var node = this;
530 while (canPush(node)) { 530 while (canPush(node)) {
531 var index = typeof node.index === 'number' ? 531 var index = typeof node.index === 'number' ?
532 node.index : 532 node.index :
533 (node.shadowRootType() === WebInspector.DOMNode.ShadowRootTypes.UserAg ent ? 'u' : 'a'); 533 (node.shadowRootType() === SDK.DOMNode.ShadowRootTypes.UserAgent ? 'u' : 'a');
534 path.push([index, node._nodeName]); 534 path.push([index, node._nodeName]);
535 node = node.parentNode; 535 node = node.parentNode;
536 } 536 }
537 path.reverse(); 537 path.reverse();
538 return path.join(','); 538 return path.join(',');
539 } 539 }
540 540
541 /** 541 /**
542 * @param {!WebInspector.DOMNode} node 542 * @param {!SDK.DOMNode} node
543 * @return {boolean} 543 * @return {boolean}
544 */ 544 */
545 isAncestor(node) { 545 isAncestor(node) {
546 if (!node) 546 if (!node)
547 return false; 547 return false;
548 548
549 var currentNode = node.parentNode; 549 var currentNode = node.parentNode;
550 while (currentNode) { 550 while (currentNode) {
551 if (this === currentNode) 551 if (this === currentNode)
552 return true; 552 return true;
553 currentNode = currentNode.parentNode; 553 currentNode = currentNode.parentNode;
554 } 554 }
555 return false; 555 return false;
556 } 556 }
557 557
558 /** 558 /**
559 * @param {!WebInspector.DOMNode} descendant 559 * @param {!SDK.DOMNode} descendant
560 * @return {boolean} 560 * @return {boolean}
561 */ 561 */
562 isDescendant(descendant) { 562 isDescendant(descendant) {
563 return descendant !== null && descendant.isAncestor(this); 563 return descendant !== null && descendant.isAncestor(this);
564 } 564 }
565 565
566 /** 566 /**
567 * @return {?Protocol.Page.FrameId} 567 * @return {?Protocol.Page.FrameId}
568 */ 568 */
569 frameId() { 569 frameId() {
(...skipping 22 matching lines...) Expand all
592 if (attributesChanged) 592 if (attributesChanged)
593 continue; 593 continue;
594 594
595 if (!oldAttributesMap[name] || oldAttributesMap[name].value !== value) 595 if (!oldAttributesMap[name] || oldAttributesMap[name].value !== value)
596 attributesChanged = true; 596 attributesChanged = true;
597 } 597 }
598 return attributesChanged; 598 return attributesChanged;
599 } 599 }
600 600
601 /** 601 /**
602 * @param {!WebInspector.DOMNode} prev 602 * @param {!SDK.DOMNode} prev
603 * @param {!Protocol.DOM.Node} payload 603 * @param {!Protocol.DOM.Node} payload
604 * @return {!WebInspector.DOMNode} 604 * @return {!SDK.DOMNode}
605 */ 605 */
606 _insertChild(prev, payload) { 606 _insertChild(prev, payload) {
607 var node = WebInspector.DOMNode.create(this._domModel, this.ownerDocument, t his._isInShadowTree, payload); 607 var node = SDK.DOMNode.create(this._domModel, this.ownerDocument, this._isIn ShadowTree, payload);
608 this._children.splice(this._children.indexOf(prev) + 1, 0, node); 608 this._children.splice(this._children.indexOf(prev) + 1, 0, node);
609 this._renumber(); 609 this._renumber();
610 return node; 610 return node;
611 } 611 }
612 612
613 /** 613 /**
614 * @param {!WebInspector.DOMNode} node 614 * @param {!SDK.DOMNode} node
615 */ 615 */
616 _removeChild(node) { 616 _removeChild(node) {
617 if (node.pseudoType()) { 617 if (node.pseudoType()) {
618 this._pseudoElements.delete(node.pseudoType()); 618 this._pseudoElements.delete(node.pseudoType());
619 } else { 619 } else {
620 var shadowRootIndex = this._shadowRoots.indexOf(node); 620 var shadowRootIndex = this._shadowRoots.indexOf(node);
621 if (shadowRootIndex !== -1) { 621 if (shadowRootIndex !== -1) {
622 this._shadowRoots.splice(shadowRootIndex, 1); 622 this._shadowRoots.splice(shadowRootIndex, 1);
623 } else { 623 } else {
624 console.assert(this._children.indexOf(node) !== -1); 624 console.assert(this._children.indexOf(node) !== -1);
625 this._children.splice(this._children.indexOf(node), 1); 625 this._children.splice(this._children.indexOf(node), 1);
626 } 626 }
627 } 627 }
628 node.parentNode = null; 628 node.parentNode = null;
629 this._subtreeMarkerCount -= node._subtreeMarkerCount; 629 this._subtreeMarkerCount -= node._subtreeMarkerCount;
630 if (node._subtreeMarkerCount) 630 if (node._subtreeMarkerCount)
631 this._domModel.dispatchEventToListeners(WebInspector.DOMModel.Events.Marke rsChanged, this); 631 this._domModel.dispatchEventToListeners(SDK.DOMModel.Events.MarkersChanged , this);
632 this._renumber(); 632 this._renumber();
633 } 633 }
634 634
635 /** 635 /**
636 * @param {!Array.<!Protocol.DOM.Node>} payloads 636 * @param {!Array.<!Protocol.DOM.Node>} payloads
637 */ 637 */
638 _setChildrenPayload(payloads) { 638 _setChildrenPayload(payloads) {
639 // We set children in the constructor. 639 // We set children in the constructor.
640 if (this._contentDocument) 640 if (this._contentDocument)
641 return; 641 return;
642 642
643 this._children = []; 643 this._children = [];
644 for (var i = 0; i < payloads.length; ++i) { 644 for (var i = 0; i < payloads.length; ++i) {
645 var payload = payloads[i]; 645 var payload = payloads[i];
646 var node = WebInspector.DOMNode.create(this._domModel, this.ownerDocument, this._isInShadowTree, payload); 646 var node = SDK.DOMNode.create(this._domModel, this.ownerDocument, this._is InShadowTree, payload);
647 this._children.push(node); 647 this._children.push(node);
648 } 648 }
649 this._renumber(); 649 this._renumber();
650 } 650 }
651 651
652 /** 652 /**
653 * @param {!Array.<!Protocol.DOM.Node>|undefined} payloads 653 * @param {!Array.<!Protocol.DOM.Node>|undefined} payloads
654 */ 654 */
655 _setPseudoElements(payloads) { 655 _setPseudoElements(payloads) {
656 this._pseudoElements = new Map(); 656 this._pseudoElements = new Map();
657 if (!payloads) 657 if (!payloads)
658 return; 658 return;
659 659
660 for (var i = 0; i < payloads.length; ++i) { 660 for (var i = 0; i < payloads.length; ++i) {
661 var node = WebInspector.DOMNode.create(this._domModel, this.ownerDocument, this._isInShadowTree, payloads[i]); 661 var node = SDK.DOMNode.create(this._domModel, this.ownerDocument, this._is InShadowTree, payloads[i]);
662 node.parentNode = this; 662 node.parentNode = this;
663 this._pseudoElements.set(node.pseudoType(), node); 663 this._pseudoElements.set(node.pseudoType(), node);
664 } 664 }
665 } 665 }
666 666
667 /** 667 /**
668 * @param {!Array.<!Protocol.DOM.BackendNode>} payloads 668 * @param {!Array.<!Protocol.DOM.BackendNode>} payloads
669 */ 669 */
670 _setDistributedNodePayloads(payloads) { 670 _setDistributedNodePayloads(payloads) {
671 this._distributedNodes = []; 671 this._distributedNodes = [];
672 for (var payload of payloads) 672 for (var payload of payloads)
673 this._distributedNodes.push(new WebInspector.DOMNodeShortcut( 673 this._distributedNodes.push(new SDK.DOMNodeShortcut(
674 this._domModel.target(), payload.backendNodeId, payload.nodeType, payl oad.nodeName)); 674 this._domModel.target(), payload.backendNodeId, payload.nodeType, payl oad.nodeName));
675 } 675 }
676 676
677 _renumber() { 677 _renumber() {
678 this._childNodeCount = this._children.length; 678 this._childNodeCount = this._children.length;
679 if (this._childNodeCount === 0) { 679 if (this._childNodeCount === 0) {
680 this.firstChild = null; 680 this.firstChild = null;
681 this.lastChild = null; 681 this.lastChild = null;
682 return; 682 return;
683 } 683 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 */ 719 */
720 _removeAttribute(name) { 720 _removeAttribute(name) {
721 var attr = this._attributesMap[name]; 721 var attr = this._attributesMap[name];
722 if (attr) { 722 if (attr) {
723 this._attributes.remove(attr); 723 this._attributes.remove(attr);
724 delete this._attributesMap[name]; 724 delete this._attributesMap[name];
725 } 725 }
726 } 726 }
727 727
728 /** 728 /**
729 * @param {!WebInspector.DOMNode} targetNode 729 * @param {!SDK.DOMNode} targetNode
730 * @param {?WebInspector.DOMNode} anchorNode 730 * @param {?SDK.DOMNode} anchorNode
731 * @param {function(?Protocol.Error, !Protocol.DOM.NodeId=)=} callback 731 * @param {function(?Protocol.Error, !Protocol.DOM.NodeId=)=} callback
732 */ 732 */
733 copyTo(targetNode, anchorNode, callback) { 733 copyTo(targetNode, anchorNode, callback) {
734 this._agent.copyTo( 734 this._agent.copyTo(
735 this.id, targetNode.id, anchorNode ? anchorNode.id : undefined, this._do mModel._markRevision(this, callback)); 735 this.id, targetNode.id, anchorNode ? anchorNode.id : undefined, this._do mModel._markRevision(this, callback));
736 } 736 }
737 737
738 /** 738 /**
739 * @param {!WebInspector.DOMNode} targetNode 739 * @param {!SDK.DOMNode} targetNode
740 * @param {?WebInspector.DOMNode} anchorNode 740 * @param {?SDK.DOMNode} anchorNode
741 * @param {function(?Protocol.Error, !Protocol.DOM.NodeId=)=} callback 741 * @param {function(?Protocol.Error, !Protocol.DOM.NodeId=)=} callback
742 */ 742 */
743 moveTo(targetNode, anchorNode, callback) { 743 moveTo(targetNode, anchorNode, callback) {
744 this._agent.moveTo( 744 this._agent.moveTo(
745 this.id, targetNode.id, anchorNode ? anchorNode.id : undefined, this._do mModel._markRevision(this, callback)); 745 this.id, targetNode.id, anchorNode ? anchorNode.id : undefined, this._do mModel._markRevision(this, callback));
746 } 746 }
747 747
748 /** 748 /**
749 * @return {boolean} 749 * @return {boolean}
750 */ 750 */
751 isXMLNode() { 751 isXMLNode() {
752 return !!this._xmlVersion; 752 return !!this._xmlVersion;
753 } 753 }
754 754
755 /** 755 /**
756 * @param {string} name 756 * @param {string} name
757 * @param {?*} value 757 * @param {?*} value
758 */ 758 */
759 setMarker(name, value) { 759 setMarker(name, value) {
760 if (value === null) { 760 if (value === null) {
761 if (!this._markers.has(name)) 761 if (!this._markers.has(name))
762 return; 762 return;
763 763
764 this._markers.delete(name); 764 this._markers.delete(name);
765 for (var node = this; node; node = node.parentNode) 765 for (var node = this; node; node = node.parentNode)
766 --node._subtreeMarkerCount; 766 --node._subtreeMarkerCount;
767 for (var node = this; node; node = node.parentNode) 767 for (var node = this; node; node = node.parentNode)
768 this._domModel.dispatchEventToListeners(WebInspector.DOMModel.Events.Mar kersChanged, node); 768 this._domModel.dispatchEventToListeners(SDK.DOMModel.Events.MarkersChang ed, node);
769 return; 769 return;
770 } 770 }
771 771
772 if (this.parentNode && !this._markers.has(name)) { 772 if (this.parentNode && !this._markers.has(name)) {
773 for (var node = this; node; node = node.parentNode) 773 for (var node = this; node; node = node.parentNode)
774 ++node._subtreeMarkerCount; 774 ++node._subtreeMarkerCount;
775 } 775 }
776 this._markers.set(name, value); 776 this._markers.set(name, value);
777 for (var node = this; node; node = node.parentNode) 777 for (var node = this; node; node = node.parentNode)
778 this._domModel.dispatchEventToListeners(WebInspector.DOMModel.Events.Marke rsChanged, node); 778 this._domModel.dispatchEventToListeners(SDK.DOMModel.Events.MarkersChanged , node);
779 } 779 }
780 780
781 /** 781 /**
782 * @param {string} name 782 * @param {string} name
783 * @return {?T} 783 * @return {?T}
784 * @template T 784 * @template T
785 */ 785 */
786 marker(name) { 786 marker(name) {
787 return this._markers.get(name) || null; 787 return this._markers.get(name) || null;
788 } 788 }
789 789
790 /** 790 /**
791 * @param {function(!WebInspector.DOMNode, string)} visitor 791 * @param {function(!SDK.DOMNode, string)} visitor
792 */ 792 */
793 traverseMarkers(visitor) { 793 traverseMarkers(visitor) {
794 /** 794 /**
795 * @param {!WebInspector.DOMNode} node 795 * @param {!SDK.DOMNode} node
796 */ 796 */
797 function traverse(node) { 797 function traverse(node) {
798 if (!node._subtreeMarkerCount) 798 if (!node._subtreeMarkerCount)
799 return; 799 return;
800 for (var marker of node._markers.keys()) 800 for (var marker of node._markers.keys())
801 visitor(node, marker); 801 visitor(node, marker);
802 if (!node._children) 802 if (!node._children)
803 return; 803 return;
804 for (var child of node._children) 804 for (var child of node._children)
805 traverse(child); 805 traverse(child);
806 } 806 }
807 traverse(this); 807 traverse(this);
808 } 808 }
809 809
810 /** 810 /**
811 * @param {string} url 811 * @param {string} url
812 * @return {?string} 812 * @return {?string}
813 */ 813 */
814 resolveURL(url) { 814 resolveURL(url) {
815 if (!url) 815 if (!url)
816 return url; 816 return url;
817 for (var frameOwnerCandidate = this; frameOwnerCandidate; frameOwnerCandidat e = frameOwnerCandidate.parentNode) { 817 for (var frameOwnerCandidate = this; frameOwnerCandidate; frameOwnerCandidat e = frameOwnerCandidate.parentNode) {
818 if (frameOwnerCandidate.baseURL) 818 if (frameOwnerCandidate.baseURL)
819 return WebInspector.ParsedURL.completeURL(frameOwnerCandidate.baseURL, u rl); 819 return Common.ParsedURL.completeURL(frameOwnerCandidate.baseURL, url);
820 } 820 }
821 return null; 821 return null;
822 } 822 }
823 823
824 /** 824 /**
825 * @param {string=} mode 825 * @param {string=} mode
826 * @param {!Protocol.Runtime.RemoteObjectId=} objectId 826 * @param {!Protocol.Runtime.RemoteObjectId=} objectId
827 */ 827 */
828 highlight(mode, objectId) { 828 highlight(mode, objectId) {
829 this._domModel.highlightDOMNode(this.id, mode, undefined, objectId); 829 this._domModel.highlightDOMNode(this.id, mode, undefined, objectId);
830 } 830 }
831 831
832 highlightForTwoSeconds() { 832 highlightForTwoSeconds() {
833 this._domModel.highlightDOMNodeForTwoSeconds(this.id); 833 this._domModel.highlightDOMNodeForTwoSeconds(this.id);
834 } 834 }
835 835
836 /** 836 /**
837 * @param {string=} objectGroup 837 * @param {string=} objectGroup
838 * @param {function(?WebInspector.RemoteObject)=} callback 838 * @param {function(?SDK.RemoteObject)=} callback
839 */ 839 */
840 resolveToObject(objectGroup, callback) { 840 resolveToObject(objectGroup, callback) {
841 this._agent.resolveNode(this.id, objectGroup, mycallback.bind(this)); 841 this._agent.resolveNode(this.id, objectGroup, mycallback.bind(this));
842 842
843 /** 843 /**
844 * @param {?Protocol.Error} error 844 * @param {?Protocol.Error} error
845 * @param {!Protocol.Runtime.RemoteObject} object 845 * @param {!Protocol.Runtime.RemoteObject} object
846 * @this {WebInspector.DOMNode} 846 * @this {SDK.DOMNode}
847 */ 847 */
848 function mycallback(error, object) { 848 function mycallback(error, object) {
849 if (!callback) 849 if (!callback)
850 return; 850 return;
851 851
852 if (error || !object) 852 if (error || !object)
853 callback(null); 853 callback(null);
854 else 854 else
855 callback(this.target().runtimeModel.createRemoteObject(object)); 855 callback(this.target().runtimeModel.createRemoteObject(object));
856 } 856 }
857 } 857 }
858 858
859 /** 859 /**
860 * @param {string=} objectGroup 860 * @param {string=} objectGroup
861 * @return {!Promise<!WebInspector.RemoteObject>} 861 * @return {!Promise<!SDK.RemoteObject>}
862 */ 862 */
863 resolveToObjectPromise(objectGroup) { 863 resolveToObjectPromise(objectGroup) {
864 return new Promise(resolveToObject.bind(this)); 864 return new Promise(resolveToObject.bind(this));
865 /** 865 /**
866 * @param {function(?)} fulfill 866 * @param {function(?)} fulfill
867 * @param {function(*)} reject 867 * @param {function(*)} reject
868 * @this {WebInspector.DOMNode} 868 * @this {SDK.DOMNode}
869 */ 869 */
870 function resolveToObject(fulfill, reject) { 870 function resolveToObject(fulfill, reject) {
871 this.resolveToObject(objectGroup, mycallback); 871 this.resolveToObject(objectGroup, mycallback);
872 function mycallback(object) { 872 function mycallback(object) {
873 if (object) 873 if (object)
874 fulfill(object); 874 fulfill(object);
875 else 875 else
876 reject(null); 876 reject(null);
877 } 877 }
878 } 878 }
(...skipping 15 matching lines...) Expand all
894 ancestor = node.ancestorShadowHost(); 894 ancestor = node.ancestorShadowHost();
895 if (!ancestor) 895 if (!ancestor)
896 break; 896 break;
897 // User agent shadow root, keep climbing up. 897 // User agent shadow root, keep climbing up.
898 node = ancestor; 898 node = ancestor;
899 } 899 }
900 this._agent.setInspectedNode(node.id); 900 this._agent.setInspectedNode(node.id);
901 } 901 }
902 902
903 /** 903 /**
904 * @return {?WebInspector.DOMNode} 904 * @return {?SDK.DOMNode}
905 */ 905 */
906 enclosingElementOrSelf() { 906 enclosingElementOrSelf() {
907 var node = this; 907 var node = this;
908 if (node && node.nodeType() === Node.TEXT_NODE && node.parentNode) 908 if (node && node.nodeType() === Node.TEXT_NODE && node.parentNode)
909 node = node.parentNode; 909 node = node.parentNode;
910 910
911 if (node && node.nodeType() !== Node.ELEMENT_NODE) 911 if (node && node.nodeType() !== Node.ELEMENT_NODE)
912 node = null; 912 node = null;
913 return node; 913 return node;
914 } 914 }
915 }; 915 };
916 916
917 /** 917 /**
918 * @enum {string} 918 * @enum {string}
919 */ 919 */
920 WebInspector.DOMNode.PseudoElementNames = { 920 SDK.DOMNode.PseudoElementNames = {
921 Before: 'before', 921 Before: 'before',
922 After: 'after' 922 After: 'after'
923 }; 923 };
924 924
925 /** 925 /**
926 * @enum {string} 926 * @enum {string}
927 */ 927 */
928 WebInspector.DOMNode.ShadowRootTypes = { 928 SDK.DOMNode.ShadowRootTypes = {
929 UserAgent: 'user-agent', 929 UserAgent: 'user-agent',
930 Open: 'open', 930 Open: 'open',
931 Closed: 'closed' 931 Closed: 'closed'
932 }; 932 };
933 933
934 /** @typedef {{name: string, value: string, _node: WebInspector.DOMNode}} */ 934 /** @typedef {{name: string, value: string, _node: SDK.DOMNode}} */
935 WebInspector.DOMNode.Attribute; 935 SDK.DOMNode.Attribute;
936 936
937 /** 937 /**
938 * @unrestricted 938 * @unrestricted
939 */ 939 */
940 WebInspector.DeferredDOMNode = class { 940 SDK.DeferredDOMNode = class {
941 /** 941 /**
942 * @param {!WebInspector.Target} target 942 * @param {!SDK.Target} target
943 * @param {number} backendNodeId 943 * @param {number} backendNodeId
944 */ 944 */
945 constructor(target, backendNodeId) { 945 constructor(target, backendNodeId) {
946 this._domModel = WebInspector.DOMModel.fromTarget(target); 946 this._domModel = SDK.DOMModel.fromTarget(target);
947 this._backendNodeId = backendNodeId; 947 this._backendNodeId = backendNodeId;
948 } 948 }
949 949
950 /** 950 /**
951 * @param {function(?WebInspector.DOMNode)} callback 951 * @param {function(?SDK.DOMNode)} callback
952 */ 952 */
953 resolve(callback) { 953 resolve(callback) {
954 if (!this._domModel) { 954 if (!this._domModel) {
955 callback(null); 955 callback(null);
956 return; 956 return;
957 } 957 }
958 958
959 this._domModel.pushNodesByBackendIdsToFrontend(new Set([this._backendNodeId] ), onGotNode.bind(this)); 959 this._domModel.pushNodesByBackendIdsToFrontend(new Set([this._backendNodeId] ), onGotNode.bind(this));
960 960
961 /** 961 /**
962 * @param {?Map<number, ?WebInspector.DOMNode>} nodeIds 962 * @param {?Map<number, ?SDK.DOMNode>} nodeIds
963 * @this {WebInspector.DeferredDOMNode} 963 * @this {SDK.DeferredDOMNode}
964 */ 964 */
965 function onGotNode(nodeIds) { 965 function onGotNode(nodeIds) {
966 callback(nodeIds && (nodeIds.get(this._backendNodeId) || null)); 966 callback(nodeIds && (nodeIds.get(this._backendNodeId) || null));
967 } 967 }
968 } 968 }
969 969
970 /** 970 /**
971 * @return {!Promise.<!WebInspector.DOMNode>} 971 * @return {!Promise.<!SDK.DOMNode>}
972 */ 972 */
973 resolvePromise() { 973 resolvePromise() {
974 /** 974 /**
975 * @param {function(?)} fulfill 975 * @param {function(?)} fulfill
976 * @param {function(*)} reject 976 * @param {function(*)} reject
977 * @this {WebInspector.DeferredDOMNode} 977 * @this {SDK.DeferredDOMNode}
978 */ 978 */
979 function resolveNode(fulfill, reject) { 979 function resolveNode(fulfill, reject) {
980 /** 980 /**
981 * @param {?WebInspector.DOMNode} node 981 * @param {?SDK.DOMNode} node
982 */ 982 */
983 function mycallback(node) { 983 function mycallback(node) {
984 fulfill(node); 984 fulfill(node);
985 } 985 }
986 this.resolve(mycallback); 986 this.resolve(mycallback);
987 } 987 }
988 return new Promise(resolveNode.bind(this)); 988 return new Promise(resolveNode.bind(this));
989 } 989 }
990 990
991 /** 991 /**
992 * @return {number} 992 * @return {number}
993 */ 993 */
994 backendNodeId() { 994 backendNodeId() {
995 return this._backendNodeId; 995 return this._backendNodeId;
996 } 996 }
997 997
998 highlight() { 998 highlight() {
999 if (this._domModel) 999 if (this._domModel)
1000 this._domModel.highlightDOMNode(undefined, undefined, this._backendNodeId) ; 1000 this._domModel.highlightDOMNode(undefined, undefined, this._backendNodeId) ;
1001 } 1001 }
1002 }; 1002 };
1003 1003
1004 /** 1004 /**
1005 * @unrestricted 1005 * @unrestricted
1006 */ 1006 */
1007 WebInspector.DOMNodeShortcut = class { 1007 SDK.DOMNodeShortcut = class {
1008 /** 1008 /**
1009 * @param {!WebInspector.Target} target 1009 * @param {!SDK.Target} target
1010 * @param {number} backendNodeId 1010 * @param {number} backendNodeId
1011 * @param {number} nodeType 1011 * @param {number} nodeType
1012 * @param {string} nodeName 1012 * @param {string} nodeName
1013 */ 1013 */
1014 constructor(target, backendNodeId, nodeType, nodeName) { 1014 constructor(target, backendNodeId, nodeType, nodeName) {
1015 this.nodeType = nodeType; 1015 this.nodeType = nodeType;
1016 this.nodeName = nodeName; 1016 this.nodeName = nodeName;
1017 this.deferredNode = new WebInspector.DeferredDOMNode(target, backendNodeId); 1017 this.deferredNode = new SDK.DeferredDOMNode(target, backendNodeId);
1018 } 1018 }
1019 }; 1019 };
1020 1020
1021 /** 1021 /**
1022 * @unrestricted 1022 * @unrestricted
1023 */ 1023 */
1024 WebInspector.DOMDocument = class extends WebInspector.DOMNode { 1024 SDK.DOMDocument = class extends SDK.DOMNode {
1025 /** 1025 /**
1026 * @param {!WebInspector.DOMModel} domModel 1026 * @param {!SDK.DOMModel} domModel
1027 * @param {!Protocol.DOM.Node} payload 1027 * @param {!Protocol.DOM.Node} payload
1028 */ 1028 */
1029 constructor(domModel, payload) { 1029 constructor(domModel, payload) {
1030 super(domModel); 1030 super(domModel);
1031 this._init(this, false, payload); 1031 this._init(this, false, payload);
1032 this.documentURL = payload.documentURL || ''; 1032 this.documentURL = payload.documentURL || '';
1033 this.baseURL = payload.baseURL || ''; 1033 this.baseURL = payload.baseURL || '';
1034 this._listeners = {}; 1034 this._listeners = {};
1035 } 1035 }
1036 }; 1036 };
1037 1037
1038 /** 1038 /**
1039 * @unrestricted 1039 * @unrestricted
1040 */ 1040 */
1041 WebInspector.DOMModel = class extends WebInspector.SDKModel { 1041 SDK.DOMModel = class extends SDK.SDKModel {
1042 /** 1042 /**
1043 * @param {!WebInspector.Target} target 1043 * @param {!SDK.Target} target
1044 */ 1044 */
1045 constructor(target) { 1045 constructor(target) {
1046 super(WebInspector.DOMModel, target); 1046 super(SDK.DOMModel, target);
1047 1047
1048 this._agent = target.domAgent(); 1048 this._agent = target.domAgent();
1049 1049
1050 /** @type {!Object.<number, !WebInspector.DOMNode>} */ 1050 /** @type {!Object.<number, !SDK.DOMNode>} */
1051 this._idToDOMNode = {}; 1051 this._idToDOMNode = {};
1052 /** @type {?WebInspector.DOMDocument} */ 1052 /** @type {?SDK.DOMDocument} */
1053 this._document = null; 1053 this._document = null;
1054 /** @type {!Object.<number, boolean>} */ 1054 /** @type {!Object.<number, boolean>} */
1055 this._attributeLoadNodeIds = {}; 1055 this._attributeLoadNodeIds = {};
1056 target.registerDOMDispatcher(new WebInspector.DOMDispatcher(this)); 1056 target.registerDOMDispatcher(new SDK.DOMDispatcher(this));
1057 1057
1058 this._inspectModeEnabled = false; 1058 this._inspectModeEnabled = false;
1059 1059
1060 this._defaultHighlighter = new WebInspector.DefaultDOMNodeHighlighter(this._ agent); 1060 this._defaultHighlighter = new SDK.DefaultDOMNodeHighlighter(this._agent);
1061 this._highlighter = this._defaultHighlighter; 1061 this._highlighter = this._defaultHighlighter;
1062 1062
1063 this._agent.enable(); 1063 this._agent.enable();
1064 } 1064 }
1065 1065
1066 /** 1066 /**
1067 * @param {!WebInspector.RemoteObject} object 1067 * @param {!SDK.RemoteObject} object
1068 */ 1068 */
1069 static highlightObjectAsDOMNode(object) { 1069 static highlightObjectAsDOMNode(object) {
1070 var domModel = WebInspector.DOMModel.fromTarget(object.target()); 1070 var domModel = SDK.DOMModel.fromTarget(object.target());
1071 if (domModel) 1071 if (domModel)
1072 domModel.highlightDOMNode(undefined, undefined, undefined, object.objectId ); 1072 domModel.highlightDOMNode(undefined, undefined, undefined, object.objectId );
1073 } 1073 }
1074 1074
1075 /** 1075 /**
1076 * @return {!Array<!WebInspector.DOMModel>} 1076 * @return {!Array<!SDK.DOMModel>}
1077 */ 1077 */
1078 static instances() { 1078 static instances() {
1079 var result = []; 1079 var result = [];
1080 for (var target of WebInspector.targetManager.targets()) { 1080 for (var target of SDK.targetManager.targets()) {
1081 var domModel = WebInspector.DOMModel.fromTarget(target); 1081 var domModel = SDK.DOMModel.fromTarget(target);
1082 if (domModel) 1082 if (domModel)
1083 result.push(domModel); 1083 result.push(domModel);
1084 } 1084 }
1085 return result; 1085 return result;
1086 } 1086 }
1087 1087
1088 static hideDOMNodeHighlight() { 1088 static hideDOMNodeHighlight() {
1089 for (var domModel of WebInspector.DOMModel.instances()) 1089 for (var domModel of SDK.DOMModel.instances())
1090 domModel.highlightDOMNode(0); 1090 domModel.highlightDOMNode(0);
1091 } 1091 }
1092 1092
1093 static muteHighlight() { 1093 static muteHighlight() {
1094 WebInspector.DOMModel.hideDOMNodeHighlight(); 1094 SDK.DOMModel.hideDOMNodeHighlight();
1095 WebInspector.DOMModel._highlightDisabled = true; 1095 SDK.DOMModel._highlightDisabled = true;
1096 } 1096 }
1097 1097
1098 static unmuteHighlight() { 1098 static unmuteHighlight() {
1099 WebInspector.DOMModel._highlightDisabled = false; 1099 SDK.DOMModel._highlightDisabled = false;
1100 } 1100 }
1101 1101
1102 static cancelSearch() { 1102 static cancelSearch() {
1103 for (var domModel of WebInspector.DOMModel.instances()) 1103 for (var domModel of SDK.DOMModel.instances())
1104 domModel._cancelSearch(); 1104 domModel._cancelSearch();
1105 } 1105 }
1106 1106
1107 /** 1107 /**
1108 * @param {!WebInspector.Target} target 1108 * @param {!SDK.Target} target
1109 * @return {?WebInspector.DOMModel} 1109 * @return {?SDK.DOMModel}
1110 */ 1110 */
1111 static fromTarget(target) { 1111 static fromTarget(target) {
1112 return /** @type {?WebInspector.DOMModel} */ (target.model(WebInspector.DOMM odel)); 1112 return /** @type {?SDK.DOMModel} */ (target.model(SDK.DOMModel));
1113 } 1113 }
1114 1114
1115 /** 1115 /**
1116 * @param {!WebInspector.DOMNode} node 1116 * @param {!SDK.DOMNode} node
1117 */ 1117 */
1118 _scheduleMutationEvent(node) { 1118 _scheduleMutationEvent(node) {
1119 if (!this.hasEventListeners(WebInspector.DOMModel.Events.DOMMutated)) 1119 if (!this.hasEventListeners(SDK.DOMModel.Events.DOMMutated))
1120 return; 1120 return;
1121 1121
1122 this._lastMutationId = (this._lastMutationId || 0) + 1; 1122 this._lastMutationId = (this._lastMutationId || 0) + 1;
1123 Promise.resolve().then(callObserve.bind(this, node, this._lastMutationId)); 1123 Promise.resolve().then(callObserve.bind(this, node, this._lastMutationId));
1124 1124
1125 /** 1125 /**
1126 * @this {WebInspector.DOMModel} 1126 * @this {SDK.DOMModel}
1127 * @param {!WebInspector.DOMNode} node 1127 * @param {!SDK.DOMNode} node
1128 * @param {number} mutationId 1128 * @param {number} mutationId
1129 */ 1129 */
1130 function callObserve(node, mutationId) { 1130 function callObserve(node, mutationId) {
1131 if (!this.hasEventListeners(WebInspector.DOMModel.Events.DOMMutated) || th is._lastMutationId !== mutationId) 1131 if (!this.hasEventListeners(SDK.DOMModel.Events.DOMMutated) || this._lastM utationId !== mutationId)
1132 return; 1132 return;
1133 1133
1134 this.dispatchEventToListeners(WebInspector.DOMModel.Events.DOMMutated, nod e); 1134 this.dispatchEventToListeners(SDK.DOMModel.Events.DOMMutated, node);
1135 } 1135 }
1136 } 1136 }
1137 1137
1138 /** 1138 /**
1139 * @param {function(!WebInspector.DOMDocument)=} callback 1139 * @param {function(!SDK.DOMDocument)=} callback
1140 */ 1140 */
1141 requestDocument(callback) { 1141 requestDocument(callback) {
1142 if (this._document) { 1142 if (this._document) {
1143 if (callback) 1143 if (callback)
1144 callback(this._document); 1144 callback(this._document);
1145 return; 1145 return;
1146 } 1146 }
1147 1147
1148 if (this._pendingDocumentRequestCallbacks) { 1148 if (this._pendingDocumentRequestCallbacks) {
1149 this._pendingDocumentRequestCallbacks.push(callback); 1149 this._pendingDocumentRequestCallbacks.push(callback);
1150 return; 1150 return;
1151 } 1151 }
1152 1152
1153 this._pendingDocumentRequestCallbacks = [callback]; 1153 this._pendingDocumentRequestCallbacks = [callback];
1154 1154
1155 /** 1155 /**
1156 * @this {WebInspector.DOMModel} 1156 * @this {SDK.DOMModel}
1157 * @param {?Protocol.Error} error 1157 * @param {?Protocol.Error} error
1158 * @param {!Protocol.DOM.Node} root 1158 * @param {!Protocol.DOM.Node} root
1159 */ 1159 */
1160 function onDocumentAvailable(error, root) { 1160 function onDocumentAvailable(error, root) {
1161 if (!error) 1161 if (!error)
1162 this._setDocument(root); 1162 this._setDocument(root);
1163 1163
1164 for (var i = 0; i < this._pendingDocumentRequestCallbacks.length; ++i) { 1164 for (var i = 0; i < this._pendingDocumentRequestCallbacks.length; ++i) {
1165 var callback = this._pendingDocumentRequestCallbacks[i]; 1165 var callback = this._pendingDocumentRequestCallbacks[i];
1166 if (callback) 1166 if (callback)
1167 callback(this._document); 1167 callback(this._document);
1168 } 1168 }
1169 delete this._pendingDocumentRequestCallbacks; 1169 delete this._pendingDocumentRequestCallbacks;
1170 } 1170 }
1171 1171
1172 this._agent.getDocument(undefined, undefined, onDocumentAvailable.bind(this) ); 1172 this._agent.getDocument(undefined, undefined, onDocumentAvailable.bind(this) );
1173 } 1173 }
1174 1174
1175 /** 1175 /**
1176 * @return {?WebInspector.DOMDocument} 1176 * @return {?SDK.DOMDocument}
1177 */ 1177 */
1178 existingDocument() { 1178 existingDocument() {
1179 return this._document; 1179 return this._document;
1180 } 1180 }
1181 1181
1182 /** 1182 /**
1183 * @param {!Protocol.Runtime.RemoteObjectId} objectId 1183 * @param {!Protocol.Runtime.RemoteObjectId} objectId
1184 * @param {function(?WebInspector.DOMNode)=} callback 1184 * @param {function(?SDK.DOMNode)=} callback
1185 */ 1185 */
1186 pushNodeToFrontend(objectId, callback) { 1186 pushNodeToFrontend(objectId, callback) {
1187 /** 1187 /**
1188 * @param {?Protocol.DOM.NodeId} nodeId 1188 * @param {?Protocol.DOM.NodeId} nodeId
1189 * @this {!WebInspector.DOMModel} 1189 * @this {!SDK.DOMModel}
1190 */ 1190 */
1191 function mycallback(nodeId) { 1191 function mycallback(nodeId) {
1192 callback(nodeId ? this.nodeForId(nodeId) : null); 1192 callback(nodeId ? this.nodeForId(nodeId) : null);
1193 } 1193 }
1194 this._dispatchWhenDocumentAvailable(this._agent.requestNode.bind(this._agent , objectId), mycallback.bind(this)); 1194 this._dispatchWhenDocumentAvailable(this._agent.requestNode.bind(this._agent , objectId), mycallback.bind(this));
1195 } 1195 }
1196 1196
1197 /** 1197 /**
1198 * @param {string} path 1198 * @param {string} path
1199 * @param {function(?number)=} callback 1199 * @param {function(?number)=} callback
1200 */ 1200 */
1201 pushNodeByPathToFrontend(path, callback) { 1201 pushNodeByPathToFrontend(path, callback) {
1202 this._dispatchWhenDocumentAvailable(this._agent.pushNodeByPathToFrontend.bin d(this._agent, path), callback); 1202 this._dispatchWhenDocumentAvailable(this._agent.pushNodeByPathToFrontend.bin d(this._agent, path), callback);
1203 } 1203 }
1204 1204
1205 /** 1205 /**
1206 * @param {!Set<number>} backendNodeIds 1206 * @param {!Set<number>} backendNodeIds
1207 * @param {function(?Map<number, ?WebInspector.DOMNode>)} callback 1207 * @param {function(?Map<number, ?SDK.DOMNode>)} callback
1208 */ 1208 */
1209 pushNodesByBackendIdsToFrontend(backendNodeIds, callback) { 1209 pushNodesByBackendIdsToFrontend(backendNodeIds, callback) {
1210 var backendNodeIdsArray = backendNodeIds.valuesArray(); 1210 var backendNodeIdsArray = backendNodeIds.valuesArray();
1211 /** 1211 /**
1212 * @param {?Array<!Protocol.DOM.NodeId>} nodeIds 1212 * @param {?Array<!Protocol.DOM.NodeId>} nodeIds
1213 * @this {!WebInspector.DOMModel} 1213 * @this {!SDK.DOMModel}
1214 */ 1214 */
1215 function mycallback(nodeIds) { 1215 function mycallback(nodeIds) {
1216 if (!nodeIds) { 1216 if (!nodeIds) {
1217 callback(null); 1217 callback(null);
1218 return; 1218 return;
1219 } 1219 }
1220 /** @type {!Map<number, ?WebInspector.DOMNode>} */ 1220 /** @type {!Map<number, ?SDK.DOMNode>} */
1221 var map = new Map(); 1221 var map = new Map();
1222 for (var i = 0; i < nodeIds.length; ++i) { 1222 for (var i = 0; i < nodeIds.length; ++i) {
1223 if (nodeIds[i]) 1223 if (nodeIds[i])
1224 map.set(backendNodeIdsArray[i], this.nodeForId(nodeIds[i])); 1224 map.set(backendNodeIdsArray[i], this.nodeForId(nodeIds[i]));
1225 } 1225 }
1226 callback(map); 1226 callback(map);
1227 } 1227 }
1228 this._dispatchWhenDocumentAvailable( 1228 this._dispatchWhenDocumentAvailable(
1229 this._agent.pushNodesByBackendIdsToFrontend.bind(this._agent, backendNod eIdsArray), mycallback.bind(this)); 1229 this._agent.pushNodesByBackendIdsToFrontend.bind(this._agent, backendNod eIdsArray), mycallback.bind(this));
1230 } 1230 }
(...skipping 20 matching lines...) Expand all
1251 1251
1252 /** 1252 /**
1253 * @param {function(function(?Protocol.Error, !T=)=)} func 1253 * @param {function(function(?Protocol.Error, !T=)=)} func
1254 * @param {function(!T)=} callback 1254 * @param {function(!T)=} callback
1255 * @template T 1255 * @template T
1256 */ 1256 */
1257 _dispatchWhenDocumentAvailable(func, callback) { 1257 _dispatchWhenDocumentAvailable(func, callback) {
1258 var callbackWrapper = this._wrapClientCallback(callback); 1258 var callbackWrapper = this._wrapClientCallback(callback);
1259 1259
1260 /** 1260 /**
1261 * @this {WebInspector.DOMModel} 1261 * @this {SDK.DOMModel}
1262 */ 1262 */
1263 function onDocumentAvailable() { 1263 function onDocumentAvailable() {
1264 if (this._document) 1264 if (this._document)
1265 func(callbackWrapper); 1265 func(callbackWrapper);
1266 else { 1266 else {
1267 if (callbackWrapper) 1267 if (callbackWrapper)
1268 callbackWrapper('No document'); 1268 callbackWrapper('No document');
1269 } 1269 }
1270 } 1270 }
1271 this.requestDocument(onDocumentAvailable.bind(this)); 1271 this.requestDocument(onDocumentAvailable.bind(this));
1272 } 1272 }
1273 1273
1274 /** 1274 /**
1275 * @param {!Protocol.DOM.NodeId} nodeId 1275 * @param {!Protocol.DOM.NodeId} nodeId
1276 * @param {string} name 1276 * @param {string} name
1277 * @param {string} value 1277 * @param {string} value
1278 */ 1278 */
1279 _attributeModified(nodeId, name, value) { 1279 _attributeModified(nodeId, name, value) {
1280 var node = this._idToDOMNode[nodeId]; 1280 var node = this._idToDOMNode[nodeId];
1281 if (!node) 1281 if (!node)
1282 return; 1282 return;
1283 1283
1284 node._setAttribute(name, value); 1284 node._setAttribute(name, value);
1285 this.dispatchEventToListeners(WebInspector.DOMModel.Events.AttrModified, {no de: node, name: name}); 1285 this.dispatchEventToListeners(SDK.DOMModel.Events.AttrModified, {node: node, name: name});
1286 this._scheduleMutationEvent(node); 1286 this._scheduleMutationEvent(node);
1287 } 1287 }
1288 1288
1289 /** 1289 /**
1290 * @param {!Protocol.DOM.NodeId} nodeId 1290 * @param {!Protocol.DOM.NodeId} nodeId
1291 * @param {string} name 1291 * @param {string} name
1292 */ 1292 */
1293 _attributeRemoved(nodeId, name) { 1293 _attributeRemoved(nodeId, name) {
1294 var node = this._idToDOMNode[nodeId]; 1294 var node = this._idToDOMNode[nodeId];
1295 if (!node) 1295 if (!node)
1296 return; 1296 return;
1297 node._removeAttribute(name); 1297 node._removeAttribute(name);
1298 this.dispatchEventToListeners(WebInspector.DOMModel.Events.AttrRemoved, {nod e: node, name: name}); 1298 this.dispatchEventToListeners(SDK.DOMModel.Events.AttrRemoved, {node: node, name: name});
1299 this._scheduleMutationEvent(node); 1299 this._scheduleMutationEvent(node);
1300 } 1300 }
1301 1301
1302 /** 1302 /**
1303 * @param {!Array.<!Protocol.DOM.NodeId>} nodeIds 1303 * @param {!Array.<!Protocol.DOM.NodeId>} nodeIds
1304 */ 1304 */
1305 _inlineStyleInvalidated(nodeIds) { 1305 _inlineStyleInvalidated(nodeIds) {
1306 for (var i = 0; i < nodeIds.length; ++i) 1306 for (var i = 0; i < nodeIds.length; ++i)
1307 this._attributeLoadNodeIds[nodeIds[i]] = true; 1307 this._attributeLoadNodeIds[nodeIds[i]] = true;
1308 if ('_loadNodeAttributesTimeout' in this) 1308 if ('_loadNodeAttributesTimeout' in this)
1309 return; 1309 return;
1310 this._loadNodeAttributesTimeout = setTimeout(this._loadNodeAttributes.bind(t his), 20); 1310 this._loadNodeAttributesTimeout = setTimeout(this._loadNodeAttributes.bind(t his), 20);
1311 } 1311 }
1312 1312
1313 _loadNodeAttributes() { 1313 _loadNodeAttributes() {
1314 /** 1314 /**
1315 * @this {WebInspector.DOMModel} 1315 * @this {SDK.DOMModel}
1316 * @param {!Protocol.DOM.NodeId} nodeId 1316 * @param {!Protocol.DOM.NodeId} nodeId
1317 * @param {?Protocol.Error} error 1317 * @param {?Protocol.Error} error
1318 * @param {!Array.<string>} attributes 1318 * @param {!Array.<string>} attributes
1319 */ 1319 */
1320 function callback(nodeId, error, attributes) { 1320 function callback(nodeId, error, attributes) {
1321 if (error) { 1321 if (error) {
1322 // We are calling _loadNodeAttributes asynchronously, it is ok if node i s not found. 1322 // We are calling _loadNodeAttributes asynchronously, it is ok if node i s not found.
1323 return; 1323 return;
1324 } 1324 }
1325 var node = this._idToDOMNode[nodeId]; 1325 var node = this._idToDOMNode[nodeId];
1326 if (node) { 1326 if (node) {
1327 if (node._setAttributesPayload(attributes)) { 1327 if (node._setAttributesPayload(attributes)) {
1328 this.dispatchEventToListeners(WebInspector.DOMModel.Events.AttrModifie d, {node: node, name: 'style'}); 1328 this.dispatchEventToListeners(SDK.DOMModel.Events.AttrModified, {node: node, name: 'style'});
1329 this._scheduleMutationEvent(node); 1329 this._scheduleMutationEvent(node);
1330 } 1330 }
1331 } 1331 }
1332 } 1332 }
1333 1333
1334 delete this._loadNodeAttributesTimeout; 1334 delete this._loadNodeAttributesTimeout;
1335 1335
1336 for (var nodeId in this._attributeLoadNodeIds) { 1336 for (var nodeId in this._attributeLoadNodeIds) {
1337 var nodeIdAsNumber = parseInt(nodeId, 10); 1337 var nodeIdAsNumber = parseInt(nodeId, 10);
1338 this._agent.getAttributes(nodeIdAsNumber, callback.bind(this, nodeIdAsNumb er)); 1338 this._agent.getAttributes(nodeIdAsNumber, callback.bind(this, nodeIdAsNumb er));
1339 } 1339 }
1340 this._attributeLoadNodeIds = {}; 1340 this._attributeLoadNodeIds = {};
1341 } 1341 }
1342 1342
1343 /** 1343 /**
1344 * @param {!Protocol.DOM.NodeId} nodeId 1344 * @param {!Protocol.DOM.NodeId} nodeId
1345 * @param {string} newValue 1345 * @param {string} newValue
1346 */ 1346 */
1347 _characterDataModified(nodeId, newValue) { 1347 _characterDataModified(nodeId, newValue) {
1348 var node = this._idToDOMNode[nodeId]; 1348 var node = this._idToDOMNode[nodeId];
1349 node._nodeValue = newValue; 1349 node._nodeValue = newValue;
1350 this.dispatchEventToListeners(WebInspector.DOMModel.Events.CharacterDataModi fied, node); 1350 this.dispatchEventToListeners(SDK.DOMModel.Events.CharacterDataModified, nod e);
1351 this._scheduleMutationEvent(node); 1351 this._scheduleMutationEvent(node);
1352 } 1352 }
1353 1353
1354 /** 1354 /**
1355 * @param {!Protocol.DOM.NodeId} nodeId 1355 * @param {!Protocol.DOM.NodeId} nodeId
1356 * @return {?WebInspector.DOMNode} 1356 * @return {?SDK.DOMNode}
1357 */ 1357 */
1358 nodeForId(nodeId) { 1358 nodeForId(nodeId) {
1359 return this._idToDOMNode[nodeId] || null; 1359 return this._idToDOMNode[nodeId] || null;
1360 } 1360 }
1361 1361
1362 _documentUpdated() { 1362 _documentUpdated() {
1363 this._setDocument(null); 1363 this._setDocument(null);
1364 } 1364 }
1365 1365
1366 /** 1366 /**
1367 * @param {?Protocol.DOM.Node} payload 1367 * @param {?Protocol.DOM.Node} payload
1368 */ 1368 */
1369 _setDocument(payload) { 1369 _setDocument(payload) {
1370 this._idToDOMNode = {}; 1370 this._idToDOMNode = {};
1371 if (payload && 'nodeId' in payload) 1371 if (payload && 'nodeId' in payload)
1372 this._document = new WebInspector.DOMDocument(this, payload); 1372 this._document = new SDK.DOMDocument(this, payload);
1373 else 1373 else
1374 this._document = null; 1374 this._document = null;
1375 this.dispatchEventToListeners(WebInspector.DOMModel.Events.DocumentUpdated, this._document); 1375 this.dispatchEventToListeners(SDK.DOMModel.Events.DocumentUpdated, this._doc ument);
1376 } 1376 }
1377 1377
1378 /** 1378 /**
1379 * @param {!Protocol.DOM.Node} payload 1379 * @param {!Protocol.DOM.Node} payload
1380 */ 1380 */
1381 _setDetachedRoot(payload) { 1381 _setDetachedRoot(payload) {
1382 if (payload.nodeName === '#document') 1382 if (payload.nodeName === '#document')
1383 new WebInspector.DOMDocument(this, payload); 1383 new SDK.DOMDocument(this, payload);
1384 else 1384 else
1385 WebInspector.DOMNode.create(this, null, false, payload); 1385 SDK.DOMNode.create(this, null, false, payload);
1386 } 1386 }
1387 1387
1388 /** 1388 /**
1389 * @param {!Protocol.DOM.NodeId} parentId 1389 * @param {!Protocol.DOM.NodeId} parentId
1390 * @param {!Array.<!Protocol.DOM.Node>} payloads 1390 * @param {!Array.<!Protocol.DOM.Node>} payloads
1391 */ 1391 */
1392 _setChildNodes(parentId, payloads) { 1392 _setChildNodes(parentId, payloads) {
1393 if (!parentId && payloads.length) { 1393 if (!parentId && payloads.length) {
1394 this._setDetachedRoot(payloads[0]); 1394 this._setDetachedRoot(payloads[0]);
1395 return; 1395 return;
1396 } 1396 }
1397 1397
1398 var parent = this._idToDOMNode[parentId]; 1398 var parent = this._idToDOMNode[parentId];
1399 parent._setChildrenPayload(payloads); 1399 parent._setChildrenPayload(payloads);
1400 } 1400 }
1401 1401
1402 /** 1402 /**
1403 * @param {!Protocol.DOM.NodeId} nodeId 1403 * @param {!Protocol.DOM.NodeId} nodeId
1404 * @param {number} newValue 1404 * @param {number} newValue
1405 */ 1405 */
1406 _childNodeCountUpdated(nodeId, newValue) { 1406 _childNodeCountUpdated(nodeId, newValue) {
1407 var node = this._idToDOMNode[nodeId]; 1407 var node = this._idToDOMNode[nodeId];
1408 node._childNodeCount = newValue; 1408 node._childNodeCount = newValue;
1409 this.dispatchEventToListeners(WebInspector.DOMModel.Events.ChildNodeCountUpd ated, node); 1409 this.dispatchEventToListeners(SDK.DOMModel.Events.ChildNodeCountUpdated, nod e);
1410 this._scheduleMutationEvent(node); 1410 this._scheduleMutationEvent(node);
1411 } 1411 }
1412 1412
1413 /** 1413 /**
1414 * @param {!Protocol.DOM.NodeId} parentId 1414 * @param {!Protocol.DOM.NodeId} parentId
1415 * @param {!Protocol.DOM.NodeId} prevId 1415 * @param {!Protocol.DOM.NodeId} prevId
1416 * @param {!Protocol.DOM.Node} payload 1416 * @param {!Protocol.DOM.Node} payload
1417 */ 1417 */
1418 _childNodeInserted(parentId, prevId, payload) { 1418 _childNodeInserted(parentId, prevId, payload) {
1419 var parent = this._idToDOMNode[parentId]; 1419 var parent = this._idToDOMNode[parentId];
1420 var prev = this._idToDOMNode[prevId]; 1420 var prev = this._idToDOMNode[prevId];
1421 var node = parent._insertChild(prev, payload); 1421 var node = parent._insertChild(prev, payload);
1422 this._idToDOMNode[node.id] = node; 1422 this._idToDOMNode[node.id] = node;
1423 this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeInserted, nod e); 1423 this.dispatchEventToListeners(SDK.DOMModel.Events.NodeInserted, node);
1424 this._scheduleMutationEvent(node); 1424 this._scheduleMutationEvent(node);
1425 } 1425 }
1426 1426
1427 /** 1427 /**
1428 * @param {!Protocol.DOM.NodeId} parentId 1428 * @param {!Protocol.DOM.NodeId} parentId
1429 * @param {!Protocol.DOM.NodeId} nodeId 1429 * @param {!Protocol.DOM.NodeId} nodeId
1430 */ 1430 */
1431 _childNodeRemoved(parentId, nodeId) { 1431 _childNodeRemoved(parentId, nodeId) {
1432 var parent = this._idToDOMNode[parentId]; 1432 var parent = this._idToDOMNode[parentId];
1433 var node = this._idToDOMNode[nodeId]; 1433 var node = this._idToDOMNode[nodeId];
1434 parent._removeChild(node); 1434 parent._removeChild(node);
1435 this._unbind(node); 1435 this._unbind(node);
1436 this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeRemoved, {nod e: node, parent: parent}); 1436 this.dispatchEventToListeners(SDK.DOMModel.Events.NodeRemoved, {node: node, parent: parent});
1437 this._scheduleMutationEvent(node); 1437 this._scheduleMutationEvent(node);
1438 } 1438 }
1439 1439
1440 /** 1440 /**
1441 * @param {!Protocol.DOM.NodeId} hostId 1441 * @param {!Protocol.DOM.NodeId} hostId
1442 * @param {!Protocol.DOM.Node} root 1442 * @param {!Protocol.DOM.Node} root
1443 */ 1443 */
1444 _shadowRootPushed(hostId, root) { 1444 _shadowRootPushed(hostId, root) {
1445 var host = this._idToDOMNode[hostId]; 1445 var host = this._idToDOMNode[hostId];
1446 if (!host) 1446 if (!host)
1447 return; 1447 return;
1448 var node = WebInspector.DOMNode.create(this, host.ownerDocument, true, root) ; 1448 var node = SDK.DOMNode.create(this, host.ownerDocument, true, root);
1449 node.parentNode = host; 1449 node.parentNode = host;
1450 this._idToDOMNode[node.id] = node; 1450 this._idToDOMNode[node.id] = node;
1451 host._shadowRoots.unshift(node); 1451 host._shadowRoots.unshift(node);
1452 this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeInserted, nod e); 1452 this.dispatchEventToListeners(SDK.DOMModel.Events.NodeInserted, node);
1453 this._scheduleMutationEvent(node); 1453 this._scheduleMutationEvent(node);
1454 } 1454 }
1455 1455
1456 /** 1456 /**
1457 * @param {!Protocol.DOM.NodeId} hostId 1457 * @param {!Protocol.DOM.NodeId} hostId
1458 * @param {!Protocol.DOM.NodeId} rootId 1458 * @param {!Protocol.DOM.NodeId} rootId
1459 */ 1459 */
1460 _shadowRootPopped(hostId, rootId) { 1460 _shadowRootPopped(hostId, rootId) {
1461 var host = this._idToDOMNode[hostId]; 1461 var host = this._idToDOMNode[hostId];
1462 if (!host) 1462 if (!host)
1463 return; 1463 return;
1464 var root = this._idToDOMNode[rootId]; 1464 var root = this._idToDOMNode[rootId];
1465 if (!root) 1465 if (!root)
1466 return; 1466 return;
1467 host._removeChild(root); 1467 host._removeChild(root);
1468 this._unbind(root); 1468 this._unbind(root);
1469 this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeRemoved, {nod e: root, parent: host}); 1469 this.dispatchEventToListeners(SDK.DOMModel.Events.NodeRemoved, {node: root, parent: host});
1470 this._scheduleMutationEvent(root); 1470 this._scheduleMutationEvent(root);
1471 } 1471 }
1472 1472
1473 /** 1473 /**
1474 * @param {!Protocol.DOM.NodeId} parentId 1474 * @param {!Protocol.DOM.NodeId} parentId
1475 * @param {!Protocol.DOM.Node} pseudoElement 1475 * @param {!Protocol.DOM.Node} pseudoElement
1476 */ 1476 */
1477 _pseudoElementAdded(parentId, pseudoElement) { 1477 _pseudoElementAdded(parentId, pseudoElement) {
1478 var parent = this._idToDOMNode[parentId]; 1478 var parent = this._idToDOMNode[parentId];
1479 if (!parent) 1479 if (!parent)
1480 return; 1480 return;
1481 var node = WebInspector.DOMNode.create(this, parent.ownerDocument, false, ps eudoElement); 1481 var node = SDK.DOMNode.create(this, parent.ownerDocument, false, pseudoEleme nt);
1482 node.parentNode = parent; 1482 node.parentNode = parent;
1483 this._idToDOMNode[node.id] = node; 1483 this._idToDOMNode[node.id] = node;
1484 console.assert(!parent._pseudoElements.get(node.pseudoType())); 1484 console.assert(!parent._pseudoElements.get(node.pseudoType()));
1485 parent._pseudoElements.set(node.pseudoType(), node); 1485 parent._pseudoElements.set(node.pseudoType(), node);
1486 this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeInserted, nod e); 1486 this.dispatchEventToListeners(SDK.DOMModel.Events.NodeInserted, node);
1487 this._scheduleMutationEvent(node); 1487 this._scheduleMutationEvent(node);
1488 } 1488 }
1489 1489
1490 /** 1490 /**
1491 * @param {!Protocol.DOM.NodeId} parentId 1491 * @param {!Protocol.DOM.NodeId} parentId
1492 * @param {!Protocol.DOM.NodeId} pseudoElementId 1492 * @param {!Protocol.DOM.NodeId} pseudoElementId
1493 */ 1493 */
1494 _pseudoElementRemoved(parentId, pseudoElementId) { 1494 _pseudoElementRemoved(parentId, pseudoElementId) {
1495 var parent = this._idToDOMNode[parentId]; 1495 var parent = this._idToDOMNode[parentId];
1496 if (!parent) 1496 if (!parent)
1497 return; 1497 return;
1498 var pseudoElement = this._idToDOMNode[pseudoElementId]; 1498 var pseudoElement = this._idToDOMNode[pseudoElementId];
1499 if (!pseudoElement) 1499 if (!pseudoElement)
1500 return; 1500 return;
1501 parent._removeChild(pseudoElement); 1501 parent._removeChild(pseudoElement);
1502 this._unbind(pseudoElement); 1502 this._unbind(pseudoElement);
1503 this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeRemoved, {nod e: pseudoElement, parent: parent}); 1503 this.dispatchEventToListeners(SDK.DOMModel.Events.NodeRemoved, {node: pseudo Element, parent: parent});
1504 this._scheduleMutationEvent(pseudoElement); 1504 this._scheduleMutationEvent(pseudoElement);
1505 } 1505 }
1506 1506
1507 /** 1507 /**
1508 * @param {!Protocol.DOM.NodeId} insertionPointId 1508 * @param {!Protocol.DOM.NodeId} insertionPointId
1509 * @param {!Array.<!Protocol.DOM.BackendNode>} distributedNodes 1509 * @param {!Array.<!Protocol.DOM.BackendNode>} distributedNodes
1510 */ 1510 */
1511 _distributedNodesUpdated(insertionPointId, distributedNodes) { 1511 _distributedNodesUpdated(insertionPointId, distributedNodes) {
1512 var insertionPoint = this._idToDOMNode[insertionPointId]; 1512 var insertionPoint = this._idToDOMNode[insertionPointId];
1513 if (!insertionPoint) 1513 if (!insertionPoint)
1514 return; 1514 return;
1515 insertionPoint._setDistributedNodePayloads(distributedNodes); 1515 insertionPoint._setDistributedNodePayloads(distributedNodes);
1516 this.dispatchEventToListeners(WebInspector.DOMModel.Events.DistributedNodesC hanged, insertionPoint); 1516 this.dispatchEventToListeners(SDK.DOMModel.Events.DistributedNodesChanged, i nsertionPoint);
1517 this._scheduleMutationEvent(insertionPoint); 1517 this._scheduleMutationEvent(insertionPoint);
1518 } 1518 }
1519 1519
1520 /** 1520 /**
1521 * @param {!WebInspector.DOMNode} node 1521 * @param {!SDK.DOMNode} node
1522 */ 1522 */
1523 _unbind(node) { 1523 _unbind(node) {
1524 delete this._idToDOMNode[node.id]; 1524 delete this._idToDOMNode[node.id];
1525 for (var i = 0; node._children && i < node._children.length; ++i) 1525 for (var i = 0; node._children && i < node._children.length; ++i)
1526 this._unbind(node._children[i]); 1526 this._unbind(node._children[i]);
1527 for (var i = 0; i < node._shadowRoots.length; ++i) 1527 for (var i = 0; i < node._shadowRoots.length; ++i)
1528 this._unbind(node._shadowRoots[i]); 1528 this._unbind(node._shadowRoots[i]);
1529 var pseudoElements = node.pseudoElements(); 1529 var pseudoElements = node.pseudoElements();
1530 for (var value of pseudoElements.values()) 1530 for (var value of pseudoElements.values())
1531 this._unbind(value); 1531 this._unbind(value);
1532 if (node._templateContent) 1532 if (node._templateContent)
1533 this._unbind(node._templateContent); 1533 this._unbind(node._templateContent);
1534 } 1534 }
1535 1535
1536 /** 1536 /**
1537 * @param {!Protocol.DOM.BackendNodeId} backendNodeId 1537 * @param {!Protocol.DOM.BackendNodeId} backendNodeId
1538 */ 1538 */
1539 _inspectNodeRequested(backendNodeId) { 1539 _inspectNodeRequested(backendNodeId) {
1540 var deferredNode = new WebInspector.DeferredDOMNode(this.target(), backendNo deId); 1540 var deferredNode = new SDK.DeferredDOMNode(this.target(), backendNodeId);
1541 this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeInspected, de ferredNode); 1541 this.dispatchEventToListeners(SDK.DOMModel.Events.NodeInspected, deferredNod e);
1542 } 1542 }
1543 1543
1544 /** 1544 /**
1545 * @param {string} query 1545 * @param {string} query
1546 * @param {boolean} includeUserAgentShadowDOM 1546 * @param {boolean} includeUserAgentShadowDOM
1547 * @param {function(number)} searchCallback 1547 * @param {function(number)} searchCallback
1548 */ 1548 */
1549 performSearch(query, includeUserAgentShadowDOM, searchCallback) { 1549 performSearch(query, includeUserAgentShadowDOM, searchCallback) {
1550 WebInspector.DOMModel.cancelSearch(); 1550 SDK.DOMModel.cancelSearch();
1551 1551
1552 /** 1552 /**
1553 * @param {?Protocol.Error} error 1553 * @param {?Protocol.Error} error
1554 * @param {string} searchId 1554 * @param {string} searchId
1555 * @param {number} resultsCount 1555 * @param {number} resultsCount
1556 * @this {WebInspector.DOMModel} 1556 * @this {SDK.DOMModel}
1557 */ 1557 */
1558 function callback(error, searchId, resultsCount) { 1558 function callback(error, searchId, resultsCount) {
1559 this._searchId = searchId; 1559 this._searchId = searchId;
1560 searchCallback(resultsCount); 1560 searchCallback(resultsCount);
1561 } 1561 }
1562 this._agent.performSearch(query, includeUserAgentShadowDOM, callback.bind(th is)); 1562 this._agent.performSearch(query, includeUserAgentShadowDOM, callback.bind(th is));
1563 } 1563 }
1564 1564
1565 /** 1565 /**
1566 * @param {string} query 1566 * @param {string} query
1567 * @param {boolean} includeUserAgentShadowDOM 1567 * @param {boolean} includeUserAgentShadowDOM
1568 * @return {!Promise.<number>} 1568 * @return {!Promise.<number>}
1569 */ 1569 */
1570 performSearchPromise(query, includeUserAgentShadowDOM) { 1570 performSearchPromise(query, includeUserAgentShadowDOM) {
1571 return new Promise(performSearch.bind(this)); 1571 return new Promise(performSearch.bind(this));
1572 1572
1573 /** 1573 /**
1574 * @param {function(number)} resolve 1574 * @param {function(number)} resolve
1575 * @this {WebInspector.DOMModel} 1575 * @this {SDK.DOMModel}
1576 */ 1576 */
1577 function performSearch(resolve) { 1577 function performSearch(resolve) {
1578 this._agent.performSearch(query, includeUserAgentShadowDOM, callback.bind( this)); 1578 this._agent.performSearch(query, includeUserAgentShadowDOM, callback.bind( this));
1579 1579
1580 /** 1580 /**
1581 * @param {?Protocol.Error} error 1581 * @param {?Protocol.Error} error
1582 * @param {string} searchId 1582 * @param {string} searchId
1583 * @param {number} resultsCount 1583 * @param {number} resultsCount
1584 * @this {WebInspector.DOMModel} 1584 * @this {SDK.DOMModel}
1585 */ 1585 */
1586 function callback(error, searchId, resultsCount) { 1586 function callback(error, searchId, resultsCount) {
1587 if (!error) 1587 if (!error)
1588 this._searchId = searchId; 1588 this._searchId = searchId;
1589 resolve(error ? 0 : resultsCount); 1589 resolve(error ? 0 : resultsCount);
1590 } 1590 }
1591 } 1591 }
1592 } 1592 }
1593 1593
1594 /** 1594 /**
1595 * @param {number} index 1595 * @param {number} index
1596 * @param {?function(?WebInspector.DOMNode)} callback 1596 * @param {?function(?SDK.DOMNode)} callback
1597 */ 1597 */
1598 searchResult(index, callback) { 1598 searchResult(index, callback) {
1599 if (this._searchId) 1599 if (this._searchId)
1600 this._agent.getSearchResults(this._searchId, index, index + 1, searchResul tsCallback.bind(this)); 1600 this._agent.getSearchResults(this._searchId, index, index + 1, searchResul tsCallback.bind(this));
1601 else 1601 else
1602 callback(null); 1602 callback(null);
1603 1603
1604 /** 1604 /**
1605 * @param {?Protocol.Error} error 1605 * @param {?Protocol.Error} error
1606 * @param {!Array.<number>} nodeIds 1606 * @param {!Array.<number>} nodeIds
1607 * @this {WebInspector.DOMModel} 1607 * @this {SDK.DOMModel}
1608 */ 1608 */
1609 function searchResultsCallback(error, nodeIds) { 1609 function searchResultsCallback(error, nodeIds) {
1610 if (error) { 1610 if (error) {
1611 console.error(error); 1611 console.error(error);
1612 callback(null); 1612 callback(null);
1613 return; 1613 return;
1614 } 1614 }
1615 if (nodeIds.length !== 1) 1615 if (nodeIds.length !== 1)
1616 return; 1616 return;
1617 1617
(...skipping 10 matching lines...) Expand all
1628 1628
1629 /** 1629 /**
1630 * @param {!Protocol.DOM.NodeId} nodeId 1630 * @param {!Protocol.DOM.NodeId} nodeId
1631 * @return {!Promise<!Array<string>>} 1631 * @return {!Promise<!Array<string>>}
1632 */ 1632 */
1633 classNamesPromise(nodeId) { 1633 classNamesPromise(nodeId) {
1634 return new Promise(promiseBody.bind(this)); 1634 return new Promise(promiseBody.bind(this));
1635 1635
1636 /** 1636 /**
1637 * @param {function(!Array<string>)} fulfill 1637 * @param {function(!Array<string>)} fulfill
1638 * @this {WebInspector.DOMModel} 1638 * @this {SDK.DOMModel}
1639 */ 1639 */
1640 function promiseBody(fulfill) { 1640 function promiseBody(fulfill) {
1641 this._agent.collectClassNamesFromSubtree(nodeId, classNamesCallback); 1641 this._agent.collectClassNamesFromSubtree(nodeId, classNamesCallback);
1642 1642
1643 /** 1643 /**
1644 * @param {?string} error 1644 * @param {?string} error
1645 * @param {?Array<string>} classNames 1645 * @param {?Array<string>} classNames
1646 */ 1646 */
1647 function classNamesCallback(error, classNames) { 1647 function classNamesCallback(error, classNames) {
1648 if (!error && classNames) 1648 if (!error && classNames)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 this.highlightDOMNodeWithConfig(nodeId, {mode: mode}, backendNodeId, objectI d); 1681 this.highlightDOMNodeWithConfig(nodeId, {mode: mode}, backendNodeId, objectI d);
1682 } 1682 }
1683 1683
1684 /** 1684 /**
1685 * @param {!Protocol.DOM.NodeId=} nodeId 1685 * @param {!Protocol.DOM.NodeId=} nodeId
1686 * @param {!{mode: (string|undefined), showInfo: (boolean|undefined), selector s: (string|undefined)}=} config 1686 * @param {!{mode: (string|undefined), showInfo: (boolean|undefined), selector s: (string|undefined)}=} config
1687 * @param {!Protocol.DOM.BackendNodeId=} backendNodeId 1687 * @param {!Protocol.DOM.BackendNodeId=} backendNodeId
1688 * @param {!Protocol.Runtime.RemoteObjectId=} objectId 1688 * @param {!Protocol.Runtime.RemoteObjectId=} objectId
1689 */ 1689 */
1690 highlightDOMNodeWithConfig(nodeId, config, backendNodeId, objectId) { 1690 highlightDOMNodeWithConfig(nodeId, config, backendNodeId, objectId) {
1691 if (WebInspector.DOMModel._highlightDisabled) 1691 if (SDK.DOMModel._highlightDisabled)
1692 return; 1692 return;
1693 config = config || {mode: 'all', showInfo: undefined, selectors: undefined}; 1693 config = config || {mode: 'all', showInfo: undefined, selectors: undefined};
1694 if (this._hideDOMNodeHighlightTimeout) { 1694 if (this._hideDOMNodeHighlightTimeout) {
1695 clearTimeout(this._hideDOMNodeHighlightTimeout); 1695 clearTimeout(this._hideDOMNodeHighlightTimeout);
1696 delete this._hideDOMNodeHighlightTimeout; 1696 delete this._hideDOMNodeHighlightTimeout;
1697 } 1697 }
1698 var highlightConfig = this._buildHighlightConfig(config.mode); 1698 var highlightConfig = this._buildHighlightConfig(config.mode);
1699 if (typeof config.showInfo !== 'undefined') 1699 if (typeof config.showInfo !== 'undefined')
1700 highlightConfig.showInfo = config.showInfo; 1700 highlightConfig.showInfo = config.showInfo;
1701 if (typeof config.selectors !== 'undefined') 1701 if (typeof config.selectors !== 'undefined')
1702 highlightConfig.selectorList = config.selectors; 1702 highlightConfig.selectorList = config.selectors;
1703 this._highlighter.highlightDOMNode(this.nodeForId(nodeId || 0), highlightCon fig, backendNodeId, objectId); 1703 this._highlighter.highlightDOMNode(this.nodeForId(nodeId || 0), highlightCon fig, backendNodeId, objectId);
1704 } 1704 }
1705 1705
1706 /** 1706 /**
1707 * @param {!Protocol.DOM.NodeId} nodeId 1707 * @param {!Protocol.DOM.NodeId} nodeId
1708 */ 1708 */
1709 highlightDOMNodeForTwoSeconds(nodeId) { 1709 highlightDOMNodeForTwoSeconds(nodeId) {
1710 this.highlightDOMNode(nodeId); 1710 this.highlightDOMNode(nodeId);
1711 this._hideDOMNodeHighlightTimeout = 1711 this._hideDOMNodeHighlightTimeout =
1712 setTimeout(WebInspector.DOMModel.hideDOMNodeHighlight.bind(WebInspector. DOMModel), 2000); 1712 setTimeout(SDK.DOMModel.hideDOMNodeHighlight.bind(SDK.DOMModel), 2000);
1713 } 1713 }
1714 1714
1715 /** 1715 /**
1716 * @param {!Protocol.Page.FrameId} frameId 1716 * @param {!Protocol.Page.FrameId} frameId
1717 */ 1717 */
1718 highlightFrame(frameId) { 1718 highlightFrame(frameId) {
1719 if (WebInspector.DOMModel._highlightDisabled) 1719 if (SDK.DOMModel._highlightDisabled)
1720 return; 1720 return;
1721 this._highlighter.highlightFrame(frameId); 1721 this._highlighter.highlightFrame(frameId);
1722 } 1722 }
1723 1723
1724 /** 1724 /**
1725 * @param {!Protocol.DOM.InspectMode} mode 1725 * @param {!Protocol.DOM.InspectMode} mode
1726 * @param {function(?Protocol.Error)=} callback 1726 * @param {function(?Protocol.Error)=} callback
1727 */ 1727 */
1728 setInspectMode(mode, callback) { 1728 setInspectMode(mode, callback) {
1729 /** 1729 /**
1730 * @this {WebInspector.DOMModel} 1730 * @this {SDK.DOMModel}
1731 */ 1731 */
1732 function onDocumentAvailable() { 1732 function onDocumentAvailable() {
1733 this._inspectModeEnabled = mode !== Protocol.DOM.InspectMode.None; 1733 this._inspectModeEnabled = mode !== Protocol.DOM.InspectMode.None;
1734 this.dispatchEventToListeners(WebInspector.DOMModel.Events.InspectModeWill BeToggled, this._inspectModeEnabled); 1734 this.dispatchEventToListeners(SDK.DOMModel.Events.InspectModeWillBeToggled , this._inspectModeEnabled);
1735 this._highlighter.setInspectMode(mode, this._buildHighlightConfig(), callb ack); 1735 this._highlighter.setInspectMode(mode, this._buildHighlightConfig(), callb ack);
1736 } 1736 }
1737 this.requestDocument(onDocumentAvailable.bind(this)); 1737 this.requestDocument(onDocumentAvailable.bind(this));
1738 } 1738 }
1739 1739
1740 /** 1740 /**
1741 * @return {boolean} 1741 * @return {boolean}
1742 */ 1742 */
1743 inspectModeEnabled() { 1743 inspectModeEnabled() {
1744 return this._inspectModeEnabled; 1744 return this._inspectModeEnabled;
1745 } 1745 }
1746 1746
1747 /** 1747 /**
1748 * @param {string=} mode 1748 * @param {string=} mode
1749 * @return {!Protocol.DOM.HighlightConfig} 1749 * @return {!Protocol.DOM.HighlightConfig}
1750 */ 1750 */
1751 _buildHighlightConfig(mode) { 1751 _buildHighlightConfig(mode) {
1752 mode = mode || 'all'; 1752 mode = mode || 'all';
1753 var showRulers = WebInspector.moduleSetting('showMetricsRulers').get(); 1753 var showRulers = Common.moduleSetting('showMetricsRulers').get();
1754 var highlightConfig = {showInfo: mode === 'all', showRulers: showRulers, sho wExtensionLines: showRulers}; 1754 var highlightConfig = {showInfo: mode === 'all', showRulers: showRulers, sho wExtensionLines: showRulers};
1755 if (mode === 'all' || mode === 'content') 1755 if (mode === 'all' || mode === 'content')
1756 highlightConfig.contentColor = WebInspector.Color.PageHighlight.Content.to ProtocolRGBA(); 1756 highlightConfig.contentColor = Common.Color.PageHighlight.Content.toProtoc olRGBA();
1757 1757
1758 if (mode === 'all' || mode === 'padding') 1758 if (mode === 'all' || mode === 'padding')
1759 highlightConfig.paddingColor = WebInspector.Color.PageHighlight.Padding.to ProtocolRGBA(); 1759 highlightConfig.paddingColor = Common.Color.PageHighlight.Padding.toProtoc olRGBA();
1760 1760
1761 if (mode === 'all' || mode === 'border') 1761 if (mode === 'all' || mode === 'border')
1762 highlightConfig.borderColor = WebInspector.Color.PageHighlight.Border.toPr otocolRGBA(); 1762 highlightConfig.borderColor = Common.Color.PageHighlight.Border.toProtocol RGBA();
1763 1763
1764 if (mode === 'all' || mode === 'margin') 1764 if (mode === 'all' || mode === 'margin')
1765 highlightConfig.marginColor = WebInspector.Color.PageHighlight.Margin.toPr otocolRGBA(); 1765 highlightConfig.marginColor = Common.Color.PageHighlight.Margin.toProtocol RGBA();
1766 1766
1767 if (mode === 'all') { 1767 if (mode === 'all') {
1768 highlightConfig.eventTargetColor = WebInspector.Color.PageHighlight.EventT arget.toProtocolRGBA(); 1768 highlightConfig.eventTargetColor = Common.Color.PageHighlight.EventTarget. toProtocolRGBA();
1769 highlightConfig.shapeColor = WebInspector.Color.PageHighlight.Shape.toProt ocolRGBA(); 1769 highlightConfig.shapeColor = Common.Color.PageHighlight.Shape.toProtocolRG BA();
1770 highlightConfig.shapeMarginColor = WebInspector.Color.PageHighlight.ShapeM argin.toProtocolRGBA(); 1770 highlightConfig.shapeMarginColor = Common.Color.PageHighlight.ShapeMargin. toProtocolRGBA();
1771 highlightConfig.displayAsMaterial = Runtime.experiments.isEnabled('inspect Tooltip'); 1771 highlightConfig.displayAsMaterial = Runtime.experiments.isEnabled('inspect Tooltip');
1772 } 1772 }
1773 return highlightConfig; 1773 return highlightConfig;
1774 } 1774 }
1775 1775
1776 /** 1776 /**
1777 * @param {!WebInspector.DOMNode} node 1777 * @param {!SDK.DOMNode} node
1778 * @param {function(?Protocol.Error, ...)=} callback 1778 * @param {function(?Protocol.Error, ...)=} callback
1779 * @return {function(...)} 1779 * @return {function(...)}
1780 * @template T 1780 * @template T
1781 */ 1781 */
1782 _markRevision(node, callback) { 1782 _markRevision(node, callback) {
1783 /** 1783 /**
1784 * @param {?Protocol.Error} error 1784 * @param {?Protocol.Error} error
1785 * @this {WebInspector.DOMModel} 1785 * @this {SDK.DOMModel}
1786 */ 1786 */
1787 function wrapperFunction(error) { 1787 function wrapperFunction(error) {
1788 if (!error) 1788 if (!error)
1789 this.markUndoableState(); 1789 this.markUndoableState();
1790 1790
1791 if (callback) 1791 if (callback)
1792 callback.apply(this, arguments); 1792 callback.apply(this, arguments);
1793 } 1793 }
1794 return wrapperFunction.bind(this); 1794 return wrapperFunction.bind(this);
1795 } 1795 }
1796 1796
1797 markUndoableState() { 1797 markUndoableState() {
1798 this._agent.markUndoableState(); 1798 this._agent.markUndoableState();
1799 } 1799 }
1800 1800
1801 /** 1801 /**
1802 * @param {function(?Protocol.Error)=} callback 1802 * @param {function(?Protocol.Error)=} callback
1803 */ 1803 */
1804 undo(callback) { 1804 undo(callback) {
1805 /** 1805 /**
1806 * @param {?Protocol.Error} error 1806 * @param {?Protocol.Error} error
1807 * @this {WebInspector.DOMModel} 1807 * @this {SDK.DOMModel}
1808 */ 1808 */
1809 function mycallback(error) { 1809 function mycallback(error) {
1810 this.dispatchEventToListeners(WebInspector.DOMModel.Events.UndoRedoComplet ed); 1810 this.dispatchEventToListeners(SDK.DOMModel.Events.UndoRedoCompleted);
1811 callback(error); 1811 callback(error);
1812 } 1812 }
1813 1813
1814 this.dispatchEventToListeners(WebInspector.DOMModel.Events.UndoRedoRequested ); 1814 this.dispatchEventToListeners(SDK.DOMModel.Events.UndoRedoRequested);
1815 this._agent.undo(callback); 1815 this._agent.undo(callback);
1816 } 1816 }
1817 1817
1818 /** 1818 /**
1819 * @param {function(?Protocol.Error)=} callback 1819 * @param {function(?Protocol.Error)=} callback
1820 */ 1820 */
1821 redo(callback) { 1821 redo(callback) {
1822 /** 1822 /**
1823 * @param {?Protocol.Error} error 1823 * @param {?Protocol.Error} error
1824 * @this {WebInspector.DOMModel} 1824 * @this {SDK.DOMModel}
1825 */ 1825 */
1826 function mycallback(error) { 1826 function mycallback(error) {
1827 this.dispatchEventToListeners(WebInspector.DOMModel.Events.UndoRedoComplet ed); 1827 this.dispatchEventToListeners(SDK.DOMModel.Events.UndoRedoCompleted);
1828 callback(error); 1828 callback(error);
1829 } 1829 }
1830 1830
1831 this.dispatchEventToListeners(WebInspector.DOMModel.Events.UndoRedoRequested ); 1831 this.dispatchEventToListeners(SDK.DOMModel.Events.UndoRedoRequested);
1832 this._agent.redo(callback); 1832 this._agent.redo(callback);
1833 } 1833 }
1834 1834
1835 /** 1835 /**
1836 * @param {?WebInspector.DOMNodeHighlighter} highlighter 1836 * @param {?SDK.DOMNodeHighlighter} highlighter
1837 */ 1837 */
1838 setHighlighter(highlighter) { 1838 setHighlighter(highlighter) {
1839 this._highlighter = highlighter || this._defaultHighlighter; 1839 this._highlighter = highlighter || this._defaultHighlighter;
1840 } 1840 }
1841 1841
1842 /** 1842 /**
1843 * @param {number} x 1843 * @param {number} x
1844 * @param {number} y 1844 * @param {number} y
1845 * @param {function(?WebInspector.DOMNode)} callback 1845 * @param {function(?SDK.DOMNode)} callback
1846 */ 1846 */
1847 nodeForLocation(x, y, callback) { 1847 nodeForLocation(x, y, callback) {
1848 this._agent.getNodeForLocation(x, y, mycallback.bind(this)); 1848 this._agent.getNodeForLocation(x, y, mycallback.bind(this));
1849 1849
1850 /** 1850 /**
1851 * @param {?Protocol.Error} error 1851 * @param {?Protocol.Error} error
1852 * @param {number} nodeId 1852 * @param {number} nodeId
1853 * @this {WebInspector.DOMModel} 1853 * @this {SDK.DOMModel}
1854 */ 1854 */
1855 function mycallback(error, nodeId) { 1855 function mycallback(error, nodeId) {
1856 if (error) { 1856 if (error) {
1857 callback(null); 1857 callback(null);
1858 return; 1858 return;
1859 } 1859 }
1860 callback(this.nodeForId(nodeId)); 1860 callback(this.nodeForId(nodeId));
1861 } 1861 }
1862 } 1862 }
1863 1863
1864 /** 1864 /**
1865 * @param {!WebInspector.RemoteObject} object 1865 * @param {!SDK.RemoteObject} object
1866 * @param {function(?WebInspector.DOMNode)} callback 1866 * @param {function(?SDK.DOMNode)} callback
1867 */ 1867 */
1868 pushObjectAsNodeToFrontend(object, callback) { 1868 pushObjectAsNodeToFrontend(object, callback) {
1869 if (object.isNode()) 1869 if (object.isNode())
1870 this.pushNodeToFrontend(object.objectId, callback); 1870 this.pushNodeToFrontend(object.objectId, callback);
1871 else 1871 else
1872 callback(null); 1872 callback(null);
1873 } 1873 }
1874 1874
1875 /** 1875 /**
1876 * @override 1876 * @override
1877 * @return {!Promise} 1877 * @return {!Promise}
1878 */ 1878 */
1879 suspendModel() { 1879 suspendModel() {
1880 return new Promise(promiseBody.bind(this)); 1880 return new Promise(promiseBody.bind(this));
1881 1881
1882 /** 1882 /**
1883 * @param {function()} fulfill 1883 * @param {function()} fulfill
1884 * @this {WebInspector.DOMModel} 1884 * @this {SDK.DOMModel}
1885 */ 1885 */
1886 function promiseBody(fulfill) { 1886 function promiseBody(fulfill) {
1887 this._agent.disable(callback.bind(this)); 1887 this._agent.disable(callback.bind(this));
1888 1888
1889 /** 1889 /**
1890 * @this {WebInspector.DOMModel} 1890 * @this {SDK.DOMModel}
1891 */ 1891 */
1892 function callback() { 1892 function callback() {
1893 this._setDocument(null); 1893 this._setDocument(null);
1894 fulfill(); 1894 fulfill();
1895 } 1895 }
1896 } 1896 }
1897 } 1897 }
1898 1898
1899 /** 1899 /**
1900 * @override 1900 * @override
1901 * @return {!Promise} 1901 * @return {!Promise}
1902 */ 1902 */
1903 resumeModel() { 1903 resumeModel() {
1904 return new Promise(promiseBody.bind(this)); 1904 return new Promise(promiseBody.bind(this));
1905 1905
1906 /** 1906 /**
1907 * @param {function()} fulfill 1907 * @param {function()} fulfill
1908 * @this {WebInspector.DOMModel} 1908 * @this {SDK.DOMModel}
1909 */ 1909 */
1910 function promiseBody(fulfill) { 1910 function promiseBody(fulfill) {
1911 this._agent.enable(fulfill); 1911 this._agent.enable(fulfill);
1912 } 1912 }
1913 } 1913 }
1914 1914
1915 /** 1915 /**
1916 * @param {!Protocol.DOM.NodeId} nodeId 1916 * @param {!Protocol.DOM.NodeId} nodeId
1917 */ 1917 */
1918 nodeHighlightRequested(nodeId) { 1918 nodeHighlightRequested(nodeId) {
1919 var node = this.nodeForId(nodeId); 1919 var node = this.nodeForId(nodeId);
1920 if (!node) 1920 if (!node)
1921 return; 1921 return;
1922 1922
1923 this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeHighlightedIn Overlay, node); 1923 this.dispatchEventToListeners(SDK.DOMModel.Events.NodeHighlightedInOverlay, node);
1924 } 1924 }
1925 }; 1925 };
1926 1926
1927 /** @enum {symbol} */ 1927 /** @enum {symbol} */
1928 WebInspector.DOMModel.Events = { 1928 SDK.DOMModel.Events = {
1929 AttrModified: Symbol('AttrModified'), 1929 AttrModified: Symbol('AttrModified'),
1930 AttrRemoved: Symbol('AttrRemoved'), 1930 AttrRemoved: Symbol('AttrRemoved'),
1931 CharacterDataModified: Symbol('CharacterDataModified'), 1931 CharacterDataModified: Symbol('CharacterDataModified'),
1932 DOMMutated: Symbol('DOMMutated'), 1932 DOMMutated: Symbol('DOMMutated'),
1933 NodeInserted: Symbol('NodeInserted'), 1933 NodeInserted: Symbol('NodeInserted'),
1934 NodeInspected: Symbol('NodeInspected'), 1934 NodeInspected: Symbol('NodeInspected'),
1935 NodeHighlightedInOverlay: Symbol('NodeHighlightedInOverlay'), 1935 NodeHighlightedInOverlay: Symbol('NodeHighlightedInOverlay'),
1936 NodeRemoved: Symbol('NodeRemoved'), 1936 NodeRemoved: Symbol('NodeRemoved'),
1937 DocumentUpdated: Symbol('DocumentUpdated'), 1937 DocumentUpdated: Symbol('DocumentUpdated'),
1938 ChildNodeCountUpdated: Symbol('ChildNodeCountUpdated'), 1938 ChildNodeCountUpdated: Symbol('ChildNodeCountUpdated'),
1939 UndoRedoRequested: Symbol('UndoRedoRequested'), 1939 UndoRedoRequested: Symbol('UndoRedoRequested'),
1940 UndoRedoCompleted: Symbol('UndoRedoCompleted'), 1940 UndoRedoCompleted: Symbol('UndoRedoCompleted'),
1941 DistributedNodesChanged: Symbol('DistributedNodesChanged'), 1941 DistributedNodesChanged: Symbol('DistributedNodesChanged'),
1942 ModelSuspended: Symbol('ModelSuspended'), 1942 ModelSuspended: Symbol('ModelSuspended'),
1943 InspectModeWillBeToggled: Symbol('InspectModeWillBeToggled'), 1943 InspectModeWillBeToggled: Symbol('InspectModeWillBeToggled'),
1944 MarkersChanged: Symbol('MarkersChanged') 1944 MarkersChanged: Symbol('MarkersChanged')
1945 }; 1945 };
1946 1946
1947 1947
1948 /** 1948 /**
1949 * @implements {Protocol.DOMDispatcher} 1949 * @implements {Protocol.DOMDispatcher}
1950 * @unrestricted 1950 * @unrestricted
1951 */ 1951 */
1952 WebInspector.DOMDispatcher = class { 1952 SDK.DOMDispatcher = class {
1953 /** 1953 /**
1954 * @param {!WebInspector.DOMModel} domModel 1954 * @param {!SDK.DOMModel} domModel
1955 */ 1955 */
1956 constructor(domModel) { 1956 constructor(domModel) {
1957 this._domModel = domModel; 1957 this._domModel = domModel;
1958 } 1958 }
1959 1959
1960 /** 1960 /**
1961 * @override 1961 * @override
1962 */ 1962 */
1963 documentUpdated() { 1963 documentUpdated() {
1964 this._domModel._documentUpdated(); 1964 this._domModel._documentUpdated();
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 * @param {!Protocol.DOM.NodeId} nodeId 2095 * @param {!Protocol.DOM.NodeId} nodeId
2096 */ 2096 */
2097 nodeHighlightRequested(nodeId) { 2097 nodeHighlightRequested(nodeId) {
2098 this._domModel.nodeHighlightRequested(nodeId); 2098 this._domModel.nodeHighlightRequested(nodeId);
2099 } 2099 }
2100 }; 2100 };
2101 2101
2102 /** 2102 /**
2103 * @interface 2103 * @interface
2104 */ 2104 */
2105 WebInspector.DOMNodeHighlighter = function() {}; 2105 SDK.DOMNodeHighlighter = function() {};
2106 2106
2107 WebInspector.DOMNodeHighlighter.prototype = { 2107 SDK.DOMNodeHighlighter.prototype = {
2108 /** 2108 /**
2109 * @param {?WebInspector.DOMNode} node 2109 * @param {?SDK.DOMNode} node
2110 * @param {!Protocol.DOM.HighlightConfig} config 2110 * @param {!Protocol.DOM.HighlightConfig} config
2111 * @param {!Protocol.DOM.BackendNodeId=} backendNodeId 2111 * @param {!Protocol.DOM.BackendNodeId=} backendNodeId
2112 * @param {!Protocol.Runtime.RemoteObjectId=} objectId 2112 * @param {!Protocol.Runtime.RemoteObjectId=} objectId
2113 */ 2113 */
2114 highlightDOMNode: function(node, config, backendNodeId, objectId) {}, 2114 highlightDOMNode: function(node, config, backendNodeId, objectId) {},
2115 2115
2116 /** 2116 /**
2117 * @param {!Protocol.DOM.InspectMode} mode 2117 * @param {!Protocol.DOM.InspectMode} mode
2118 * @param {!Protocol.DOM.HighlightConfig} config 2118 * @param {!Protocol.DOM.HighlightConfig} config
2119 * @param {function(?Protocol.Error)=} callback 2119 * @param {function(?Protocol.Error)=} callback
2120 */ 2120 */
2121 setInspectMode: function(mode, config, callback) {}, 2121 setInspectMode: function(mode, config, callback) {},
2122 2122
2123 /** 2123 /**
2124 * @param {!Protocol.Page.FrameId} frameId 2124 * @param {!Protocol.Page.FrameId} frameId
2125 */ 2125 */
2126 highlightFrame: function(frameId) {} 2126 highlightFrame: function(frameId) {}
2127 }; 2127 };
2128 2128
2129 /** 2129 /**
2130 * @implements {WebInspector.DOMNodeHighlighter} 2130 * @implements {SDK.DOMNodeHighlighter}
2131 * @unrestricted 2131 * @unrestricted
2132 */ 2132 */
2133 WebInspector.DefaultDOMNodeHighlighter = class { 2133 SDK.DefaultDOMNodeHighlighter = class {
2134 /** 2134 /**
2135 * @param {!Protocol.DOMAgent} agent 2135 * @param {!Protocol.DOMAgent} agent
2136 */ 2136 */
2137 constructor(agent) { 2137 constructor(agent) {
2138 this._agent = agent; 2138 this._agent = agent;
2139 } 2139 }
2140 2140
2141 /** 2141 /**
2142 * @override 2142 * @override
2143 * @param {?WebInspector.DOMNode} node 2143 * @param {?SDK.DOMNode} node
2144 * @param {!Protocol.DOM.HighlightConfig} config 2144 * @param {!Protocol.DOM.HighlightConfig} config
2145 * @param {!Protocol.DOM.BackendNodeId=} backendNodeId 2145 * @param {!Protocol.DOM.BackendNodeId=} backendNodeId
2146 * @param {!Protocol.Runtime.RemoteObjectId=} objectId 2146 * @param {!Protocol.Runtime.RemoteObjectId=} objectId
2147 */ 2147 */
2148 highlightDOMNode(node, config, backendNodeId, objectId) { 2148 highlightDOMNode(node, config, backendNodeId, objectId) {
2149 if (objectId || node || backendNodeId) 2149 if (objectId || node || backendNodeId)
2150 this._agent.highlightNode(config, (objectId || backendNodeId) ? undefined : node.id, backendNodeId, objectId); 2150 this._agent.highlightNode(config, (objectId || backendNodeId) ? undefined : node.id, backendNodeId, objectId);
2151 else 2151 else
2152 this._agent.hideHighlight(); 2152 this._agent.hideHighlight();
2153 } 2153 }
2154 2154
2155 /** 2155 /**
2156 * @override 2156 * @override
2157 * @param {!Protocol.DOM.InspectMode} mode 2157 * @param {!Protocol.DOM.InspectMode} mode
2158 * @param {!Protocol.DOM.HighlightConfig} config 2158 * @param {!Protocol.DOM.HighlightConfig} config
2159 * @param {function(?Protocol.Error)=} callback 2159 * @param {function(?Protocol.Error)=} callback
2160 */ 2160 */
2161 setInspectMode(mode, config, callback) { 2161 setInspectMode(mode, config, callback) {
2162 this._agent.setInspectMode(mode, config, callback); 2162 this._agent.setInspectMode(mode, config, callback);
2163 } 2163 }
2164 2164
2165 /** 2165 /**
2166 * @override 2166 * @override
2167 * @param {!Protocol.Page.FrameId} frameId 2167 * @param {!Protocol.Page.FrameId} frameId
2168 */ 2168 */
2169 highlightFrame(frameId) { 2169 highlightFrame(frameId) {
2170 this._agent.highlightFrame( 2170 this._agent.highlightFrame(
2171 frameId, WebInspector.Color.PageHighlight.Content.toProtocolRGBA(), 2171 frameId, Common.Color.PageHighlight.Content.toProtocolRGBA(),
2172 WebInspector.Color.PageHighlight.ContentOutline.toProtocolRGBA()); 2172 Common.Color.PageHighlight.ContentOutline.toProtocolRGBA());
2173 } 2173 }
2174 }; 2174 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698