OLD | NEW |
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 13 matching lines...) Expand all Loading... |
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
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 * @constructor | 33 * @constructor |
34 * @param {!WebInspector.DOMAgent} domAgent | 34 * @param {!WebInspector.DOMModel} domModel |
35 * @param {?WebInspector.DOMDocument} doc | 35 * @param {?WebInspector.DOMDocument} doc |
36 * @param {boolean} isInShadowTree | 36 * @param {boolean} isInShadowTree |
37 * @param {!DOMAgent.Node} payload | 37 * @param {!DOMAgent.Node} payload |
38 */ | 38 */ |
39 WebInspector.DOMNode = function(domAgent, doc, isInShadowTree, payload) { | 39 WebInspector.DOMNode = function(domModel, doc, isInShadowTree, payload) { |
40 this._domAgent = domAgent; | 40 this._domModel = domModel; |
41 this.ownerDocument = doc; | 41 this.ownerDocument = doc; |
42 this._isInShadowTree = isInShadowTree; | 42 this._isInShadowTree = isInShadowTree; |
43 | 43 |
44 this.id = payload.nodeId; | 44 this.id = payload.nodeId; |
45 domAgent._idToDOMNode[this.id] = this; | 45 domModel._idToDOMNode[this.id] = this; |
46 this._nodeType = payload.nodeType; | 46 this._nodeType = payload.nodeType; |
47 this._nodeName = payload.nodeName; | 47 this._nodeName = payload.nodeName; |
48 this._localName = payload.localName; | 48 this._localName = payload.localName; |
49 this._nodeValue = payload.nodeValue; | 49 this._nodeValue = payload.nodeValue; |
50 this._pseudoType = payload.pseudoType; | 50 this._pseudoType = payload.pseudoType; |
51 this._shadowRootType = payload.shadowRootType; | 51 this._shadowRootType = payload.shadowRootType; |
52 this._frameId = payload.frameId || null; | 52 this._frameId = payload.frameId || null; |
53 | 53 |
54 this._shadowRoots = []; | 54 this._shadowRoots = []; |
55 | 55 |
(...skipping 10 matching lines...) Expand all Loading... |
66 | 66 |
67 this.nextSibling = null; | 67 this.nextSibling = null; |
68 this.previousSibling = null; | 68 this.previousSibling = null; |
69 this.firstChild = null; | 69 this.firstChild = null; |
70 this.lastChild = null; | 70 this.lastChild = null; |
71 this.parentNode = null; | 71 this.parentNode = null; |
72 | 72 |
73 if (payload.shadowRoots) { | 73 if (payload.shadowRoots) { |
74 for (var i = 0; i < payload.shadowRoots.length; ++i) { | 74 for (var i = 0; i < payload.shadowRoots.length; ++i) { |
75 var root = payload.shadowRoots[i]; | 75 var root = payload.shadowRoots[i]; |
76 var node = new WebInspector.DOMNode(this._domAgent, this.ownerDocume
nt, true, root); | 76 var node = new WebInspector.DOMNode(this._domModel, this.ownerDocume
nt, true, root); |
77 this._shadowRoots.push(node); | 77 this._shadowRoots.push(node); |
78 node.parentNode = this; | 78 node.parentNode = this; |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
82 if (payload.templateContent) { | 82 if (payload.templateContent) { |
83 this._templateContent = new WebInspector.DOMNode(this._domAgent, this.ow
nerDocument, true, payload.templateContent); | 83 this._templateContent = new WebInspector.DOMNode(this._domModel, this.ow
nerDocument, true, payload.templateContent); |
84 this._templateContent.parentNode = this; | 84 this._templateContent.parentNode = this; |
85 } | 85 } |
86 | 86 |
87 if (payload.importedDocument) { | 87 if (payload.importedDocument) { |
88 this._importedDocument = new WebInspector.DOMNode(this._domAgent, this.o
wnerDocument, true, payload.importedDocument); | 88 this._importedDocument = new WebInspector.DOMNode(this._domModel, this.o
wnerDocument, true, payload.importedDocument); |
89 this._importedDocument.parentNode = this; | 89 this._importedDocument.parentNode = this; |
90 } | 90 } |
91 | 91 |
92 if (payload.children) | 92 if (payload.children) |
93 this._setChildrenPayload(payload.children); | 93 this._setChildrenPayload(payload.children); |
94 | 94 |
95 this._setPseudoElements(payload.pseudoElements); | 95 this._setPseudoElements(payload.pseudoElements); |
96 | 96 |
97 if (payload.contentDocument) { | 97 if (payload.contentDocument) { |
98 this._contentDocument = new WebInspector.DOMDocument(domAgent, payload.c
ontentDocument); | 98 this._contentDocument = new WebInspector.DOMDocument(domModel, payload.c
ontentDocument); |
99 this._children = [this._contentDocument]; | 99 this._children = [this._contentDocument]; |
100 this._renumber(); | 100 this._renumber(); |
101 } | 101 } |
102 | 102 |
103 if (this._nodeType === Node.ELEMENT_NODE) { | 103 if (this._nodeType === Node.ELEMENT_NODE) { |
104 // HTML and BODY from internal iframes should not overwrite top-level on
es. | 104 // HTML and BODY from internal iframes should not overwrite top-level on
es. |
105 if (this.ownerDocument && !this.ownerDocument.documentElement && this._n
odeName === "HTML") | 105 if (this.ownerDocument && !this.ownerDocument.documentElement && this._n
odeName === "HTML") |
106 this.ownerDocument.documentElement = this; | 106 this.ownerDocument.documentElement = this; |
107 if (this.ownerDocument && !this.ownerDocument.body && this._nodeName ===
"BODY") | 107 if (this.ownerDocument && !this.ownerDocument.body && this._nodeName ===
"BODY") |
108 this.ownerDocument.body = this; | 108 this.ownerDocument.body = this; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 return "#shadow-root" + (shadowRootType === WebInspector.DOMNode.Sha
dowRootTypes.UserAgent ? " (user-agent)" : ""); | 277 return "#shadow-root" + (shadowRootType === WebInspector.DOMNode.Sha
dowRootTypes.UserAgent ? " (user-agent)" : ""); |
278 return this.isXMLNode() ? this.nodeName() : this.nodeName().toLowerCase(
); | 278 return this.isXMLNode() ? this.nodeName() : this.nodeName().toLowerCase(
); |
279 }, | 279 }, |
280 | 280 |
281 /** | 281 /** |
282 * @param {string} name | 282 * @param {string} name |
283 * @param {function(?Protocol.Error)=} callback | 283 * @param {function(?Protocol.Error)=} callback |
284 */ | 284 */ |
285 setNodeName: function(name, callback) | 285 setNodeName: function(name, callback) |
286 { | 286 { |
287 DOMAgent.setNodeName(this.id, name, WebInspector.domAgent._markRevision(
this, callback)); | 287 DOMAgent.setNodeName(this.id, name, WebInspector.domModel._markRevision(
this, callback)); |
288 }, | 288 }, |
289 | 289 |
290 /** | 290 /** |
291 * @return {string} | 291 * @return {string} |
292 */ | 292 */ |
293 localName: function() | 293 localName: function() |
294 { | 294 { |
295 return this._localName; | 295 return this._localName; |
296 }, | 296 }, |
297 | 297 |
298 /** | 298 /** |
299 * @return {string} | 299 * @return {string} |
300 */ | 300 */ |
301 nodeValue: function() | 301 nodeValue: function() |
302 { | 302 { |
303 return this._nodeValue; | 303 return this._nodeValue; |
304 }, | 304 }, |
305 | 305 |
306 /** | 306 /** |
307 * @param {string} value | 307 * @param {string} value |
308 * @param {function(?Protocol.Error)=} callback | 308 * @param {function(?Protocol.Error)=} callback |
309 */ | 309 */ |
310 setNodeValue: function(value, callback) | 310 setNodeValue: function(value, callback) |
311 { | 311 { |
312 DOMAgent.setNodeValue(this.id, value, WebInspector.domAgent._markRevisio
n(this, callback)); | 312 DOMAgent.setNodeValue(this.id, value, WebInspector.domModel._markRevisio
n(this, callback)); |
313 }, | 313 }, |
314 | 314 |
315 /** | 315 /** |
316 * @param {string} name | 316 * @param {string} name |
317 * @return {string} | 317 * @return {string} |
318 */ | 318 */ |
319 getAttribute: function(name) | 319 getAttribute: function(name) |
320 { | 320 { |
321 var attr = this._attributesMap[name]; | 321 var attr = this._attributesMap[name]; |
322 return attr ? attr.value : undefined; | 322 return attr ? attr.value : undefined; |
323 }, | 323 }, |
324 | 324 |
325 /** | 325 /** |
326 * @param {string} name | 326 * @param {string} name |
327 * @param {string} text | 327 * @param {string} text |
328 * @param {function(?Protocol.Error)=} callback | 328 * @param {function(?Protocol.Error)=} callback |
329 */ | 329 */ |
330 setAttribute: function(name, text, callback) | 330 setAttribute: function(name, text, callback) |
331 { | 331 { |
332 DOMAgent.setAttributesAsText(this.id, text, name, WebInspector.domAgent.
_markRevision(this, callback)); | 332 DOMAgent.setAttributesAsText(this.id, text, name, WebInspector.domModel.
_markRevision(this, callback)); |
333 }, | 333 }, |
334 | 334 |
335 /** | 335 /** |
336 * @param {string} name | 336 * @param {string} name |
337 * @param {string} value | 337 * @param {string} value |
338 * @param {function(?Protocol.Error)=} callback | 338 * @param {function(?Protocol.Error)=} callback |
339 */ | 339 */ |
340 setAttributeValue: function(name, value, callback) | 340 setAttributeValue: function(name, value, callback) |
341 { | 341 { |
342 DOMAgent.setAttributeValue(this.id, name, value, WebInspector.domAgent._
markRevision(this, callback)); | 342 DOMAgent.setAttributeValue(this.id, name, value, WebInspector.domModel._
markRevision(this, callback)); |
343 }, | 343 }, |
344 | 344 |
345 /** | 345 /** |
346 * @return {!Object} | 346 * @return {!Object} |
347 */ | 347 */ |
348 attributes: function() | 348 attributes: function() |
349 { | 349 { |
350 return this._attributes; | 350 return this._attributes; |
351 }, | 351 }, |
352 | 352 |
(...skipping 12 matching lines...) Expand all Loading... |
365 if (!error) { | 365 if (!error) { |
366 delete this._attributesMap[name]; | 366 delete this._attributesMap[name]; |
367 for (var i = 0; i < this._attributes.length; ++i) { | 367 for (var i = 0; i < this._attributes.length; ++i) { |
368 if (this._attributes[i].name === name) { | 368 if (this._attributes[i].name === name) { |
369 this._attributes.splice(i, 1); | 369 this._attributes.splice(i, 1); |
370 break; | 370 break; |
371 } | 371 } |
372 } | 372 } |
373 } | 373 } |
374 | 374 |
375 WebInspector.domAgent._markRevision(this, callback)(error); | 375 WebInspector.domModel._markRevision(this, callback)(error); |
376 } | 376 } |
377 DOMAgent.removeAttribute(this.id, name, mycallback.bind(this)); | 377 DOMAgent.removeAttribute(this.id, name, mycallback.bind(this)); |
378 }, | 378 }, |
379 | 379 |
380 /** | 380 /** |
381 * @param {function(?Array.<!WebInspector.DOMNode>)=} callback | 381 * @param {function(?Array.<!WebInspector.DOMNode>)=} callback |
382 */ | 382 */ |
383 getChildNodes: function(callback) | 383 getChildNodes: function(callback) |
384 { | 384 { |
385 if (this._children) { | 385 if (this._children) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 { | 427 { |
428 DOMAgent.getOuterHTML(this.id, callback); | 428 DOMAgent.getOuterHTML(this.id, callback); |
429 }, | 429 }, |
430 | 430 |
431 /** | 431 /** |
432 * @param {string} html | 432 * @param {string} html |
433 * @param {function(?Protocol.Error)=} callback | 433 * @param {function(?Protocol.Error)=} callback |
434 */ | 434 */ |
435 setOuterHTML: function(html, callback) | 435 setOuterHTML: function(html, callback) |
436 { | 436 { |
437 DOMAgent.setOuterHTML(this.id, html, WebInspector.domAgent._markRevision
(this, callback)); | 437 DOMAgent.setOuterHTML(this.id, html, WebInspector.domModel._markRevision
(this, callback)); |
438 }, | 438 }, |
439 | 439 |
440 /** | 440 /** |
441 * @param {function(?Protocol.Error, !DOMAgent.NodeId=)=} callback | 441 * @param {function(?Protocol.Error, !DOMAgent.NodeId=)=} callback |
442 */ | 442 */ |
443 removeNode: function(callback) | 443 removeNode: function(callback) |
444 { | 444 { |
445 DOMAgent.removeNode(this.id, WebInspector.domAgent._markRevision(this, c
allback)); | 445 DOMAgent.removeNode(this.id, WebInspector.domModel._markRevision(this, c
allback)); |
446 }, | 446 }, |
447 | 447 |
448 copyNode: function() | 448 copyNode: function() |
449 { | 449 { |
450 function copy(error, text) | 450 function copy(error, text) |
451 { | 451 { |
452 if (!error) | 452 if (!error) |
453 InspectorFrontendHost.copyText(text); | 453 InspectorFrontendHost.copyText(text); |
454 } | 454 } |
455 DOMAgent.getOuterHTML(this.id, copy); | 455 DOMAgent.getOuterHTML(this.id, copy); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 return attributesChanged; | 552 return attributesChanged; |
553 }, | 553 }, |
554 | 554 |
555 /** | 555 /** |
556 * @param {!WebInspector.DOMNode} prev | 556 * @param {!WebInspector.DOMNode} prev |
557 * @param {!DOMAgent.Node} payload | 557 * @param {!DOMAgent.Node} payload |
558 * @return {!WebInspector.DOMNode} | 558 * @return {!WebInspector.DOMNode} |
559 */ | 559 */ |
560 _insertChild: function(prev, payload) | 560 _insertChild: function(prev, payload) |
561 { | 561 { |
562 var node = new WebInspector.DOMNode(this._domAgent, this.ownerDocument,
this._isInShadowTree, payload); | 562 var node = new WebInspector.DOMNode(this._domModel, this.ownerDocument,
this._isInShadowTree, payload); |
563 this._children.splice(this._children.indexOf(prev) + 1, 0, node); | 563 this._children.splice(this._children.indexOf(prev) + 1, 0, node); |
564 this._renumber(); | 564 this._renumber(); |
565 return node; | 565 return node; |
566 }, | 566 }, |
567 | 567 |
568 /** | 568 /** |
569 * @param {!WebInspector.DOMNode} node | 569 * @param {!WebInspector.DOMNode} node |
570 */ | 570 */ |
571 _removeChild: function(node) | 571 _removeChild: function(node) |
572 { | 572 { |
(...skipping 16 matching lines...) Expand all Loading... |
589 */ | 589 */ |
590 _setChildrenPayload: function(payloads) | 590 _setChildrenPayload: function(payloads) |
591 { | 591 { |
592 // We set children in the constructor. | 592 // We set children in the constructor. |
593 if (this._contentDocument) | 593 if (this._contentDocument) |
594 return; | 594 return; |
595 | 595 |
596 this._children = []; | 596 this._children = []; |
597 for (var i = 0; i < payloads.length; ++i) { | 597 for (var i = 0; i < payloads.length; ++i) { |
598 var payload = payloads[i]; | 598 var payload = payloads[i]; |
599 var node = new WebInspector.DOMNode(this._domAgent, this.ownerDocume
nt, this._isInShadowTree, payload); | 599 var node = new WebInspector.DOMNode(this._domModel, this.ownerDocume
nt, this._isInShadowTree, payload); |
600 this._children.push(node); | 600 this._children.push(node); |
601 } | 601 } |
602 this._renumber(); | 602 this._renumber(); |
603 }, | 603 }, |
604 | 604 |
605 /** | 605 /** |
606 * @param {!Array.<!DOMAgent.Node>|undefined} payloads | 606 * @param {!Array.<!DOMAgent.Node>|undefined} payloads |
607 */ | 607 */ |
608 _setPseudoElements: function(payloads) | 608 _setPseudoElements: function(payloads) |
609 { | 609 { |
610 this._pseudoElements = {}; | 610 this._pseudoElements = {}; |
611 if (!payloads) | 611 if (!payloads) |
612 return; | 612 return; |
613 | 613 |
614 for (var i = 0; i < payloads.length; ++i) { | 614 for (var i = 0; i < payloads.length; ++i) { |
615 var node = new WebInspector.DOMNode(this._domAgent, this.ownerDocume
nt, this._isInShadowTree, payloads[i]); | 615 var node = new WebInspector.DOMNode(this._domModel, this.ownerDocume
nt, this._isInShadowTree, payloads[i]); |
616 node.parentNode = this; | 616 node.parentNode = this; |
617 this._pseudoElements[node.pseudoType()] = node; | 617 this._pseudoElements[node.pseudoType()] = node; |
618 } | 618 } |
619 }, | 619 }, |
620 | 620 |
621 _renumber: function() | 621 _renumber: function() |
622 { | 622 { |
623 this._childNodeCount = this._children.length; | 623 this._childNodeCount = this._children.length; |
624 if (this._childNodeCount == 0) { | 624 if (this._childNodeCount == 0) { |
625 this.firstChild = null; | 625 this.firstChild = null; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 } | 677 } |
678 }, | 678 }, |
679 | 679 |
680 /** | 680 /** |
681 * @param {!WebInspector.DOMNode} targetNode | 681 * @param {!WebInspector.DOMNode} targetNode |
682 * @param {?WebInspector.DOMNode} anchorNode | 682 * @param {?WebInspector.DOMNode} anchorNode |
683 * @param {function(?Protocol.Error, !DOMAgent.NodeId=)=} callback | 683 * @param {function(?Protocol.Error, !DOMAgent.NodeId=)=} callback |
684 */ | 684 */ |
685 moveTo: function(targetNode, anchorNode, callback) | 685 moveTo: function(targetNode, anchorNode, callback) |
686 { | 686 { |
687 DOMAgent.moveTo(this.id, targetNode.id, anchorNode ? anchorNode.id : und
efined, WebInspector.domAgent._markRevision(this, callback)); | 687 DOMAgent.moveTo(this.id, targetNode.id, anchorNode ? anchorNode.id : und
efined, WebInspector.domModel._markRevision(this, callback)); |
688 }, | 688 }, |
689 | 689 |
690 /** | 690 /** |
691 * @return {boolean} | 691 * @return {boolean} |
692 */ | 692 */ |
693 isXMLNode: function() | 693 isXMLNode: function() |
694 { | 694 { |
695 return !!this.ownerDocument && !!this.ownerDocument.xmlVersion; | 695 return !!this.ownerDocument && !!this.ownerDocument.xmlVersion; |
696 }, | 696 }, |
697 | 697 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 if (frameOwnerCandidate.baseURL) | 779 if (frameOwnerCandidate.baseURL) |
780 return WebInspector.ParsedURL.completeURL(frameOwnerCandidate.ba
seURL, url); | 780 return WebInspector.ParsedURL.completeURL(frameOwnerCandidate.ba
seURL, url); |
781 } | 781 } |
782 return null; | 782 return null; |
783 } | 783 } |
784 } | 784 } |
785 | 785 |
786 /** | 786 /** |
787 * @extends {WebInspector.DOMNode} | 787 * @extends {WebInspector.DOMNode} |
788 * @constructor | 788 * @constructor |
789 * @param {!WebInspector.DOMAgent} domAgent | 789 * @param {!WebInspector.DOMModel} domModel |
790 * @param {!DOMAgent.Node} payload | 790 * @param {!DOMAgent.Node} payload |
791 */ | 791 */ |
792 WebInspector.DOMDocument = function(domAgent, payload) | 792 WebInspector.DOMDocument = function(domModel, payload) |
793 { | 793 { |
794 WebInspector.DOMNode.call(this, domAgent, this, false, payload); | 794 WebInspector.DOMNode.call(this, domModel, this, false, payload); |
795 this.documentURL = payload.documentURL || ""; | 795 this.documentURL = payload.documentURL || ""; |
796 this.baseURL = payload.baseURL || ""; | 796 this.baseURL = payload.baseURL || ""; |
797 this.xmlVersion = payload.xmlVersion; | 797 this.xmlVersion = payload.xmlVersion; |
798 this._listeners = {}; | 798 this._listeners = {}; |
799 } | 799 } |
800 | 800 |
801 WebInspector.DOMDocument.prototype = { | 801 WebInspector.DOMDocument.prototype = { |
802 __proto__: WebInspector.DOMNode.prototype | 802 __proto__: WebInspector.DOMNode.prototype |
803 } | 803 } |
804 | 804 |
805 /** | 805 /** |
806 * @extends {WebInspector.Object} | 806 * @extends {WebInspector.Object} |
807 * @constructor | 807 * @constructor |
808 */ | 808 */ |
809 WebInspector.DOMAgent = function() { | 809 WebInspector.DOMModel = function() { |
810 /** @type {!Object.<number, !WebInspector.DOMNode>} */ | 810 /** @type {!Object.<number, !WebInspector.DOMNode>} */ |
811 this._idToDOMNode = {}; | 811 this._idToDOMNode = {}; |
812 /** @type {?WebInspector.DOMDocument} */ | 812 /** @type {?WebInspector.DOMDocument} */ |
813 this._document = null; | 813 this._document = null; |
814 /** @type {!Object.<number, boolean>} */ | 814 /** @type {!Object.<number, boolean>} */ |
815 this._attributeLoadNodeIds = {}; | 815 this._attributeLoadNodeIds = {}; |
816 InspectorBackend.registerDOMDispatcher(new WebInspector.DOMDispatcher(this))
; | 816 InspectorBackend.registerDOMDispatcher(new WebInspector.DOMDispatcher(this))
; |
817 | 817 |
818 this._defaultHighlighter = new WebInspector.DefaultDOMNodeHighlighter(); | 818 this._defaultHighlighter = new WebInspector.DefaultDOMNodeHighlighter(); |
819 this._highlighter = this._defaultHighlighter; | 819 this._highlighter = this._defaultHighlighter; |
820 } | 820 } |
821 | 821 |
822 WebInspector.DOMAgent.Events = { | 822 WebInspector.DOMModel.Events = { |
823 AttrModified: "AttrModified", | 823 AttrModified: "AttrModified", |
824 AttrRemoved: "AttrRemoved", | 824 AttrRemoved: "AttrRemoved", |
825 CharacterDataModified: "CharacterDataModified", | 825 CharacterDataModified: "CharacterDataModified", |
826 NodeInserted: "NodeInserted", | 826 NodeInserted: "NodeInserted", |
827 NodeRemoved: "NodeRemoved", | 827 NodeRemoved: "NodeRemoved", |
828 DocumentUpdated: "DocumentUpdated", | 828 DocumentUpdated: "DocumentUpdated", |
829 ChildNodeCountUpdated: "ChildNodeCountUpdated", | 829 ChildNodeCountUpdated: "ChildNodeCountUpdated", |
830 UndoRedoRequested: "UndoRedoRequested", | 830 UndoRedoRequested: "UndoRedoRequested", |
831 UndoRedoCompleted: "UndoRedoCompleted", | 831 UndoRedoCompleted: "UndoRedoCompleted", |
832 } | 832 } |
833 | 833 |
834 WebInspector.DOMAgent.prototype = { | 834 WebInspector.DOMModel.prototype = { |
835 /** | 835 /** |
836 * @param {function(!WebInspector.DOMDocument)=} callback | 836 * @param {function(!WebInspector.DOMDocument)=} callback |
837 */ | 837 */ |
838 requestDocument: function(callback) | 838 requestDocument: function(callback) |
839 { | 839 { |
840 if (this._document) { | 840 if (this._document) { |
841 if (callback) | 841 if (callback) |
842 callback(this._document); | 842 callback(this._document); |
843 return; | 843 return; |
844 } | 844 } |
845 | 845 |
846 if (this._pendingDocumentRequestCallbacks) { | 846 if (this._pendingDocumentRequestCallbacks) { |
847 this._pendingDocumentRequestCallbacks.push(callback); | 847 this._pendingDocumentRequestCallbacks.push(callback); |
848 return; | 848 return; |
849 } | 849 } |
850 | 850 |
851 this._pendingDocumentRequestCallbacks = [callback]; | 851 this._pendingDocumentRequestCallbacks = [callback]; |
852 | 852 |
853 /** | 853 /** |
854 * @this {WebInspector.DOMAgent} | 854 * @this {WebInspector.DOMModel} |
855 * @param {?Protocol.Error} error | 855 * @param {?Protocol.Error} error |
856 * @param {!DOMAgent.Node} root | 856 * @param {!DOMAgent.Node} root |
857 */ | 857 */ |
858 function onDocumentAvailable(error, root) | 858 function onDocumentAvailable(error, root) |
859 { | 859 { |
860 if (!error) | 860 if (!error) |
861 this._setDocument(root); | 861 this._setDocument(root); |
862 | 862 |
863 for (var i = 0; i < this._pendingDocumentRequestCallbacks.length; ++
i) { | 863 for (var i = 0; i < this._pendingDocumentRequestCallbacks.length; ++
i) { |
864 var callback = this._pendingDocumentRequestCallbacks[i]; | 864 var callback = this._pendingDocumentRequestCallbacks[i]; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 /** | 930 /** |
931 * @param {function(function(?Protocol.Error, !T=)=)} func | 931 * @param {function(function(?Protocol.Error, !T=)=)} func |
932 * @param {function(!T)=} callback | 932 * @param {function(!T)=} callback |
933 * @template T | 933 * @template T |
934 */ | 934 */ |
935 _dispatchWhenDocumentAvailable: function(func, callback) | 935 _dispatchWhenDocumentAvailable: function(func, callback) |
936 { | 936 { |
937 var callbackWrapper = this._wrapClientCallback(callback); | 937 var callbackWrapper = this._wrapClientCallback(callback); |
938 | 938 |
939 /** | 939 /** |
940 * @this {WebInspector.DOMAgent} | 940 * @this {WebInspector.DOMModel} |
941 */ | 941 */ |
942 function onDocumentAvailable() | 942 function onDocumentAvailable() |
943 { | 943 { |
944 if (this._document) | 944 if (this._document) |
945 func(callbackWrapper); | 945 func(callbackWrapper); |
946 else { | 946 else { |
947 if (callbackWrapper) | 947 if (callbackWrapper) |
948 callbackWrapper("No document"); | 948 callbackWrapper("No document"); |
949 } | 949 } |
950 } | 950 } |
951 this.requestDocument(onDocumentAvailable.bind(this)); | 951 this.requestDocument(onDocumentAvailable.bind(this)); |
952 }, | 952 }, |
953 | 953 |
954 /** | 954 /** |
955 * @param {!DOMAgent.NodeId} nodeId | 955 * @param {!DOMAgent.NodeId} nodeId |
956 * @param {string} name | 956 * @param {string} name |
957 * @param {string} value | 957 * @param {string} value |
958 */ | 958 */ |
959 _attributeModified: function(nodeId, name, value) | 959 _attributeModified: function(nodeId, name, value) |
960 { | 960 { |
961 var node = this._idToDOMNode[nodeId]; | 961 var node = this._idToDOMNode[nodeId]; |
962 if (!node) | 962 if (!node) |
963 return; | 963 return; |
964 | 964 |
965 node._setAttribute(name, value); | 965 node._setAttribute(name, value); |
966 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.AttrModified,
{ node: node, name: name }); | 966 this.dispatchEventToListeners(WebInspector.DOMModel.Events.AttrModified,
{ node: node, name: name }); |
967 }, | 967 }, |
968 | 968 |
969 /** | 969 /** |
970 * @param {!DOMAgent.NodeId} nodeId | 970 * @param {!DOMAgent.NodeId} nodeId |
971 * @param {string} name | 971 * @param {string} name |
972 */ | 972 */ |
973 _attributeRemoved: function(nodeId, name) | 973 _attributeRemoved: function(nodeId, name) |
974 { | 974 { |
975 var node = this._idToDOMNode[nodeId]; | 975 var node = this._idToDOMNode[nodeId]; |
976 if (!node) | 976 if (!node) |
977 return; | 977 return; |
978 node._removeAttribute(name); | 978 node._removeAttribute(name); |
979 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.AttrRemoved,
{ node: node, name: name }); | 979 this.dispatchEventToListeners(WebInspector.DOMModel.Events.AttrRemoved,
{ node: node, name: name }); |
980 }, | 980 }, |
981 | 981 |
982 /** | 982 /** |
983 * @param {!Array.<!DOMAgent.NodeId>} nodeIds | 983 * @param {!Array.<!DOMAgent.NodeId>} nodeIds |
984 */ | 984 */ |
985 _inlineStyleInvalidated: function(nodeIds) | 985 _inlineStyleInvalidated: function(nodeIds) |
986 { | 986 { |
987 for (var i = 0; i < nodeIds.length; ++i) | 987 for (var i = 0; i < nodeIds.length; ++i) |
988 this._attributeLoadNodeIds[nodeIds[i]] = true; | 988 this._attributeLoadNodeIds[nodeIds[i]] = true; |
989 if ("_loadNodeAttributesTimeout" in this) | 989 if ("_loadNodeAttributesTimeout" in this) |
990 return; | 990 return; |
991 this._loadNodeAttributesTimeout = setTimeout(this._loadNodeAttributes.bi
nd(this), 20); | 991 this._loadNodeAttributesTimeout = setTimeout(this._loadNodeAttributes.bi
nd(this), 20); |
992 }, | 992 }, |
993 | 993 |
994 _loadNodeAttributes: function() | 994 _loadNodeAttributes: function() |
995 { | 995 { |
996 /** | 996 /** |
997 * @this {WebInspector.DOMAgent} | 997 * @this {WebInspector.DOMModel} |
998 * @param {!DOMAgent.NodeId} nodeId | 998 * @param {!DOMAgent.NodeId} nodeId |
999 * @param {?Protocol.Error} error | 999 * @param {?Protocol.Error} error |
1000 * @param {!Array.<string>} attributes | 1000 * @param {!Array.<string>} attributes |
1001 */ | 1001 */ |
1002 function callback(nodeId, error, attributes) | 1002 function callback(nodeId, error, attributes) |
1003 { | 1003 { |
1004 if (error) { | 1004 if (error) { |
1005 // We are calling _loadNodeAttributes asynchronously, it is ok i
f node is not found. | 1005 // We are calling _loadNodeAttributes asynchronously, it is ok i
f node is not found. |
1006 return; | 1006 return; |
1007 } | 1007 } |
1008 var node = this._idToDOMNode[nodeId]; | 1008 var node = this._idToDOMNode[nodeId]; |
1009 if (node) { | 1009 if (node) { |
1010 if (node._setAttributesPayload(attributes)) | 1010 if (node._setAttributesPayload(attributes)) |
1011 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.A
ttrModified, { node: node, name: "style" }); | 1011 this.dispatchEventToListeners(WebInspector.DOMModel.Events.A
ttrModified, { node: node, name: "style" }); |
1012 } | 1012 } |
1013 } | 1013 } |
1014 | 1014 |
1015 delete this._loadNodeAttributesTimeout; | 1015 delete this._loadNodeAttributesTimeout; |
1016 | 1016 |
1017 for (var nodeId in this._attributeLoadNodeIds) { | 1017 for (var nodeId in this._attributeLoadNodeIds) { |
1018 var nodeIdAsNumber = parseInt(nodeId, 10); | 1018 var nodeIdAsNumber = parseInt(nodeId, 10); |
1019 DOMAgent.getAttributes(nodeIdAsNumber, callback.bind(this, nodeIdAsN
umber)); | 1019 DOMAgent.getAttributes(nodeIdAsNumber, callback.bind(this, nodeIdAsN
umber)); |
1020 } | 1020 } |
1021 this._attributeLoadNodeIds = {}; | 1021 this._attributeLoadNodeIds = {}; |
1022 }, | 1022 }, |
1023 | 1023 |
1024 /** | 1024 /** |
1025 * @param {!DOMAgent.NodeId} nodeId | 1025 * @param {!DOMAgent.NodeId} nodeId |
1026 * @param {string} newValue | 1026 * @param {string} newValue |
1027 */ | 1027 */ |
1028 _characterDataModified: function(nodeId, newValue) | 1028 _characterDataModified: function(nodeId, newValue) |
1029 { | 1029 { |
1030 var node = this._idToDOMNode[nodeId]; | 1030 var node = this._idToDOMNode[nodeId]; |
1031 node._nodeValue = newValue; | 1031 node._nodeValue = newValue; |
1032 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.CharacterData
Modified, node); | 1032 this.dispatchEventToListeners(WebInspector.DOMModel.Events.CharacterData
Modified, node); |
1033 }, | 1033 }, |
1034 | 1034 |
1035 /** | 1035 /** |
1036 * @param {!DOMAgent.NodeId} nodeId | 1036 * @param {!DOMAgent.NodeId} nodeId |
1037 * @return {?WebInspector.DOMNode} | 1037 * @return {?WebInspector.DOMNode} |
1038 */ | 1038 */ |
1039 nodeForId: function(nodeId) | 1039 nodeForId: function(nodeId) |
1040 { | 1040 { |
1041 return this._idToDOMNode[nodeId] || null; | 1041 return this._idToDOMNode[nodeId] || null; |
1042 }, | 1042 }, |
1043 | 1043 |
1044 _documentUpdated: function() | 1044 _documentUpdated: function() |
1045 { | 1045 { |
1046 this._setDocument(null); | 1046 this._setDocument(null); |
1047 }, | 1047 }, |
1048 | 1048 |
1049 /** | 1049 /** |
1050 * @param {?DOMAgent.Node} payload | 1050 * @param {?DOMAgent.Node} payload |
1051 */ | 1051 */ |
1052 _setDocument: function(payload) | 1052 _setDocument: function(payload) |
1053 { | 1053 { |
1054 this._idToDOMNode = {}; | 1054 this._idToDOMNode = {}; |
1055 if (payload && "nodeId" in payload) | 1055 if (payload && "nodeId" in payload) |
1056 this._document = new WebInspector.DOMDocument(this, payload); | 1056 this._document = new WebInspector.DOMDocument(this, payload); |
1057 else | 1057 else |
1058 this._document = null; | 1058 this._document = null; |
1059 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.DocumentUpdat
ed, this._document); | 1059 this.dispatchEventToListeners(WebInspector.DOMModel.Events.DocumentUpdat
ed, this._document); |
1060 }, | 1060 }, |
1061 | 1061 |
1062 /** | 1062 /** |
1063 * @param {!DOMAgent.Node} payload | 1063 * @param {!DOMAgent.Node} payload |
1064 */ | 1064 */ |
1065 _setDetachedRoot: function(payload) | 1065 _setDetachedRoot: function(payload) |
1066 { | 1066 { |
1067 if (payload.nodeName === "#document") | 1067 if (payload.nodeName === "#document") |
1068 new WebInspector.DOMDocument(this, payload); | 1068 new WebInspector.DOMDocument(this, payload); |
1069 else | 1069 else |
(...skipping 16 matching lines...) Expand all Loading... |
1086 }, | 1086 }, |
1087 | 1087 |
1088 /** | 1088 /** |
1089 * @param {!DOMAgent.NodeId} nodeId | 1089 * @param {!DOMAgent.NodeId} nodeId |
1090 * @param {number} newValue | 1090 * @param {number} newValue |
1091 */ | 1091 */ |
1092 _childNodeCountUpdated: function(nodeId, newValue) | 1092 _childNodeCountUpdated: function(nodeId, newValue) |
1093 { | 1093 { |
1094 var node = this._idToDOMNode[nodeId]; | 1094 var node = this._idToDOMNode[nodeId]; |
1095 node._childNodeCount = newValue; | 1095 node._childNodeCount = newValue; |
1096 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.ChildNodeCoun
tUpdated, node); | 1096 this.dispatchEventToListeners(WebInspector.DOMModel.Events.ChildNodeCoun
tUpdated, node); |
1097 }, | 1097 }, |
1098 | 1098 |
1099 /** | 1099 /** |
1100 * @param {!DOMAgent.NodeId} parentId | 1100 * @param {!DOMAgent.NodeId} parentId |
1101 * @param {!DOMAgent.NodeId} prevId | 1101 * @param {!DOMAgent.NodeId} prevId |
1102 * @param {!DOMAgent.Node} payload | 1102 * @param {!DOMAgent.Node} payload |
1103 */ | 1103 */ |
1104 _childNodeInserted: function(parentId, prevId, payload) | 1104 _childNodeInserted: function(parentId, prevId, payload) |
1105 { | 1105 { |
1106 var parent = this._idToDOMNode[parentId]; | 1106 var parent = this._idToDOMNode[parentId]; |
1107 var prev = this._idToDOMNode[prevId]; | 1107 var prev = this._idToDOMNode[prevId]; |
1108 var node = parent._insertChild(prev, payload); | 1108 var node = parent._insertChild(prev, payload); |
1109 this._idToDOMNode[node.id] = node; | 1109 this._idToDOMNode[node.id] = node; |
1110 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.NodeInserted,
node); | 1110 this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeInserted,
node); |
1111 }, | 1111 }, |
1112 | 1112 |
1113 /** | 1113 /** |
1114 * @param {!DOMAgent.NodeId} parentId | 1114 * @param {!DOMAgent.NodeId} parentId |
1115 * @param {!DOMAgent.NodeId} nodeId | 1115 * @param {!DOMAgent.NodeId} nodeId |
1116 */ | 1116 */ |
1117 _childNodeRemoved: function(parentId, nodeId) | 1117 _childNodeRemoved: function(parentId, nodeId) |
1118 { | 1118 { |
1119 var parent = this._idToDOMNode[parentId]; | 1119 var parent = this._idToDOMNode[parentId]; |
1120 var node = this._idToDOMNode[nodeId]; | 1120 var node = this._idToDOMNode[nodeId]; |
1121 parent._removeChild(node); | 1121 parent._removeChild(node); |
1122 this._unbind(node); | 1122 this._unbind(node); |
1123 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.NodeRemoved,
{node: node, parent: parent}); | 1123 this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeRemoved,
{node: node, parent: parent}); |
1124 }, | 1124 }, |
1125 | 1125 |
1126 /** | 1126 /** |
1127 * @param {!DOMAgent.NodeId} hostId | 1127 * @param {!DOMAgent.NodeId} hostId |
1128 * @param {!DOMAgent.Node} root | 1128 * @param {!DOMAgent.Node} root |
1129 */ | 1129 */ |
1130 _shadowRootPushed: function(hostId, root) | 1130 _shadowRootPushed: function(hostId, root) |
1131 { | 1131 { |
1132 var host = this._idToDOMNode[hostId]; | 1132 var host = this._idToDOMNode[hostId]; |
1133 if (!host) | 1133 if (!host) |
1134 return; | 1134 return; |
1135 var node = new WebInspector.DOMNode(this, host.ownerDocument, true, root
); | 1135 var node = new WebInspector.DOMNode(this, host.ownerDocument, true, root
); |
1136 node.parentNode = host; | 1136 node.parentNode = host; |
1137 this._idToDOMNode[node.id] = node; | 1137 this._idToDOMNode[node.id] = node; |
1138 host._shadowRoots.push(node); | 1138 host._shadowRoots.push(node); |
1139 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.NodeInserted,
node); | 1139 this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeInserted,
node); |
1140 }, | 1140 }, |
1141 | 1141 |
1142 /** | 1142 /** |
1143 * @param {!DOMAgent.NodeId} hostId | 1143 * @param {!DOMAgent.NodeId} hostId |
1144 * @param {!DOMAgent.NodeId} rootId | 1144 * @param {!DOMAgent.NodeId} rootId |
1145 */ | 1145 */ |
1146 _shadowRootPopped: function(hostId, rootId) | 1146 _shadowRootPopped: function(hostId, rootId) |
1147 { | 1147 { |
1148 var host = this._idToDOMNode[hostId]; | 1148 var host = this._idToDOMNode[hostId]; |
1149 if (!host) | 1149 if (!host) |
1150 return; | 1150 return; |
1151 var root = this._idToDOMNode[rootId]; | 1151 var root = this._idToDOMNode[rootId]; |
1152 if (!root) | 1152 if (!root) |
1153 return; | 1153 return; |
1154 host._removeChild(root); | 1154 host._removeChild(root); |
1155 this._unbind(root); | 1155 this._unbind(root); |
1156 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.NodeRemoved,
{node: root, parent: host}); | 1156 this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeRemoved,
{node: root, parent: host}); |
1157 }, | 1157 }, |
1158 | 1158 |
1159 /** | 1159 /** |
1160 * @param {!DOMAgent.NodeId} parentId | 1160 * @param {!DOMAgent.NodeId} parentId |
1161 * @param {!DOMAgent.Node} pseudoElement | 1161 * @param {!DOMAgent.Node} pseudoElement |
1162 */ | 1162 */ |
1163 _pseudoElementAdded: function(parentId, pseudoElement) | 1163 _pseudoElementAdded: function(parentId, pseudoElement) |
1164 { | 1164 { |
1165 var parent = this._idToDOMNode[parentId]; | 1165 var parent = this._idToDOMNode[parentId]; |
1166 if (!parent) | 1166 if (!parent) |
1167 return; | 1167 return; |
1168 var node = new WebInspector.DOMNode(this, parent.ownerDocument, false, p
seudoElement); | 1168 var node = new WebInspector.DOMNode(this, parent.ownerDocument, false, p
seudoElement); |
1169 node.parentNode = parent; | 1169 node.parentNode = parent; |
1170 this._idToDOMNode[node.id] = node; | 1170 this._idToDOMNode[node.id] = node; |
1171 console.assert(!parent._pseudoElements[node.pseudoType()]); | 1171 console.assert(!parent._pseudoElements[node.pseudoType()]); |
1172 parent._pseudoElements[node.pseudoType()] = node; | 1172 parent._pseudoElements[node.pseudoType()] = node; |
1173 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.NodeInserted,
node); | 1173 this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeInserted,
node); |
1174 }, | 1174 }, |
1175 | 1175 |
1176 /** | 1176 /** |
1177 * @param {!DOMAgent.NodeId} parentId | 1177 * @param {!DOMAgent.NodeId} parentId |
1178 * @param {!DOMAgent.NodeId} pseudoElementId | 1178 * @param {!DOMAgent.NodeId} pseudoElementId |
1179 */ | 1179 */ |
1180 _pseudoElementRemoved: function(parentId, pseudoElementId) | 1180 _pseudoElementRemoved: function(parentId, pseudoElementId) |
1181 { | 1181 { |
1182 var parent = this._idToDOMNode[parentId]; | 1182 var parent = this._idToDOMNode[parentId]; |
1183 if (!parent) | 1183 if (!parent) |
1184 return; | 1184 return; |
1185 var pseudoElement = this._idToDOMNode[pseudoElementId]; | 1185 var pseudoElement = this._idToDOMNode[pseudoElementId]; |
1186 if (!pseudoElement) | 1186 if (!pseudoElement) |
1187 return; | 1187 return; |
1188 parent._removeChild(pseudoElement); | 1188 parent._removeChild(pseudoElement); |
1189 this._unbind(pseudoElement); | 1189 this._unbind(pseudoElement); |
1190 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.NodeRemoved,
{node: pseudoElement, parent: parent}); | 1190 this.dispatchEventToListeners(WebInspector.DOMModel.Events.NodeRemoved,
{node: pseudoElement, parent: parent}); |
1191 }, | 1191 }, |
1192 | 1192 |
1193 /** | 1193 /** |
1194 * @param {!WebInspector.DOMNode} node | 1194 * @param {!WebInspector.DOMNode} node |
1195 */ | 1195 */ |
1196 _unbind: function(node) | 1196 _unbind: function(node) |
1197 { | 1197 { |
1198 delete this._idToDOMNode[node.id]; | 1198 delete this._idToDOMNode[node.id]; |
1199 for (var i = 0; node._children && i < node._children.length; ++i) | 1199 for (var i = 0; node._children && i < node._children.length; ++i) |
1200 this._unbind(node._children[i]); | 1200 this._unbind(node._children[i]); |
(...skipping 27 matching lines...) Expand all Loading... |
1228 * @param {function(number)} searchCallback | 1228 * @param {function(number)} searchCallback |
1229 */ | 1229 */ |
1230 performSearch: function(query, searchCallback) | 1230 performSearch: function(query, searchCallback) |
1231 { | 1231 { |
1232 this.cancelSearch(); | 1232 this.cancelSearch(); |
1233 | 1233 |
1234 /** | 1234 /** |
1235 * @param {?Protocol.Error} error | 1235 * @param {?Protocol.Error} error |
1236 * @param {string} searchId | 1236 * @param {string} searchId |
1237 * @param {number} resultsCount | 1237 * @param {number} resultsCount |
1238 * @this {WebInspector.DOMAgent} | 1238 * @this {WebInspector.DOMModel} |
1239 */ | 1239 */ |
1240 function callback(error, searchId, resultsCount) | 1240 function callback(error, searchId, resultsCount) |
1241 { | 1241 { |
1242 this._searchId = searchId; | 1242 this._searchId = searchId; |
1243 searchCallback(resultsCount); | 1243 searchCallback(resultsCount); |
1244 } | 1244 } |
1245 DOMAgent.performSearch(query, callback.bind(this)); | 1245 DOMAgent.performSearch(query, callback.bind(this)); |
1246 }, | 1246 }, |
1247 | 1247 |
1248 /** | 1248 /** |
1249 * @param {number} index | 1249 * @param {number} index |
1250 * @param {?function(?WebInspector.DOMNode)} callback | 1250 * @param {?function(?WebInspector.DOMNode)} callback |
1251 */ | 1251 */ |
1252 searchResult: function(index, callback) | 1252 searchResult: function(index, callback) |
1253 { | 1253 { |
1254 if (this._searchId) | 1254 if (this._searchId) |
1255 DOMAgent.getSearchResults(this._searchId, index, index + 1, searchRe
sultsCallback.bind(this)); | 1255 DOMAgent.getSearchResults(this._searchId, index, index + 1, searchRe
sultsCallback.bind(this)); |
1256 else | 1256 else |
1257 callback(null); | 1257 callback(null); |
1258 | 1258 |
1259 /** | 1259 /** |
1260 * @param {?Protocol.Error} error | 1260 * @param {?Protocol.Error} error |
1261 * @param {!Array.<number>} nodeIds | 1261 * @param {!Array.<number>} nodeIds |
1262 * @this {WebInspector.DOMAgent} | 1262 * @this {WebInspector.DOMModel} |
1263 */ | 1263 */ |
1264 function searchResultsCallback(error, nodeIds) | 1264 function searchResultsCallback(error, nodeIds) |
1265 { | 1265 { |
1266 if (error) { | 1266 if (error) { |
1267 console.error(error); | 1267 console.error(error); |
1268 callback(null); | 1268 callback(null); |
1269 return; | 1269 return; |
1270 } | 1270 } |
1271 if (nodeIds.length != 1) | 1271 if (nodeIds.length != 1) |
1272 return; | 1272 return; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1332 }, | 1332 }, |
1333 | 1333 |
1334 /** | 1334 /** |
1335 * @param {boolean} enabled | 1335 * @param {boolean} enabled |
1336 * @param {boolean} inspectUAShadowDOM | 1336 * @param {boolean} inspectUAShadowDOM |
1337 * @param {function(?Protocol.Error)=} callback | 1337 * @param {function(?Protocol.Error)=} callback |
1338 */ | 1338 */ |
1339 setInspectModeEnabled: function(enabled, inspectUAShadowDOM, callback) | 1339 setInspectModeEnabled: function(enabled, inspectUAShadowDOM, callback) |
1340 { | 1340 { |
1341 /** | 1341 /** |
1342 * @this {WebInspector.DOMAgent} | 1342 * @this {WebInspector.DOMModel} |
1343 */ | 1343 */ |
1344 function onDocumentAvailable() | 1344 function onDocumentAvailable() |
1345 { | 1345 { |
1346 this._highlighter.setInspectModeEnabled(enabled, inspectUAShadowDOM,
this._buildHighlightConfig(), callback); | 1346 this._highlighter.setInspectModeEnabled(enabled, inspectUAShadowDOM,
this._buildHighlightConfig(), callback); |
1347 } | 1347 } |
1348 this.requestDocument(onDocumentAvailable.bind(this)); | 1348 this.requestDocument(onDocumentAvailable.bind(this)); |
1349 }, | 1349 }, |
1350 | 1350 |
1351 /** | 1351 /** |
1352 * @param {string=} mode | 1352 * @param {string=} mode |
(...skipping 24 matching lines...) Expand all Loading... |
1377 /** | 1377 /** |
1378 * @param {!WebInspector.DOMNode} node | 1378 * @param {!WebInspector.DOMNode} node |
1379 * @param {function(?Protocol.Error, !A=, !B=)=} callback | 1379 * @param {function(?Protocol.Error, !A=, !B=)=} callback |
1380 * @return {function(?Protocol.Error, !A=, !B=)} | 1380 * @return {function(?Protocol.Error, !A=, !B=)} |
1381 * @template A,B | 1381 * @template A,B |
1382 */ | 1382 */ |
1383 _markRevision: function(node, callback) | 1383 _markRevision: function(node, callback) |
1384 { | 1384 { |
1385 /** | 1385 /** |
1386 * @param {?Protocol.Error} error | 1386 * @param {?Protocol.Error} error |
1387 * @this {WebInspector.DOMAgent} | 1387 * @this {WebInspector.DOMModel} |
1388 */ | 1388 */ |
1389 function wrapperFunction(error) | 1389 function wrapperFunction(error) |
1390 { | 1390 { |
1391 if (!error) | 1391 if (!error) |
1392 this.markUndoableState(); | 1392 this.markUndoableState(); |
1393 | 1393 |
1394 if (callback) | 1394 if (callback) |
1395 callback.apply(this, arguments); | 1395 callback.apply(this, arguments); |
1396 } | 1396 } |
1397 return wrapperFunction.bind(this); | 1397 return wrapperFunction.bind(this); |
(...skipping 21 matching lines...) Expand all Loading... |
1419 } else { | 1419 } else { |
1420 if (typeof this._addTouchEventsScriptId !== "undefined") { | 1420 if (typeof this._addTouchEventsScriptId !== "undefined") { |
1421 PageAgent.removeScriptToEvaluateOnLoad(this._addTouchEventsScrip
tId); | 1421 PageAgent.removeScriptToEvaluateOnLoad(this._addTouchEventsScrip
tId); |
1422 delete this._addTouchEventsScriptId; | 1422 delete this._addTouchEventsScriptId; |
1423 } | 1423 } |
1424 } | 1424 } |
1425 | 1425 |
1426 /** | 1426 /** |
1427 * @param {?Protocol.Error} error | 1427 * @param {?Protocol.Error} error |
1428 * @param {string} scriptId | 1428 * @param {string} scriptId |
1429 * @this {WebInspector.DOMAgent} | 1429 * @this {WebInspector.DOMModel} |
1430 */ | 1430 */ |
1431 function scriptAddedCallback(error, scriptId) | 1431 function scriptAddedCallback(error, scriptId) |
1432 { | 1432 { |
1433 delete this._addTouchEventsScriptInjecting; | 1433 delete this._addTouchEventsScriptInjecting; |
1434 if (error) | 1434 if (error) |
1435 return; | 1435 return; |
1436 this._addTouchEventsScriptId = scriptId; | 1436 this._addTouchEventsScriptId = scriptId; |
1437 } | 1437 } |
1438 | 1438 |
1439 PageAgent.setTouchEmulationEnabled(emulationEnabled); | 1439 PageAgent.setTouchEmulationEnabled(emulationEnabled); |
1440 }, | 1440 }, |
1441 | 1441 |
1442 markUndoableState: function() | 1442 markUndoableState: function() |
1443 { | 1443 { |
1444 DOMAgent.markUndoableState(); | 1444 DOMAgent.markUndoableState(); |
1445 }, | 1445 }, |
1446 | 1446 |
1447 /** | 1447 /** |
1448 * @param {function(?Protocol.Error)=} callback | 1448 * @param {function(?Protocol.Error)=} callback |
1449 */ | 1449 */ |
1450 undo: function(callback) | 1450 undo: function(callback) |
1451 { | 1451 { |
1452 /** | 1452 /** |
1453 * @param {?Protocol.Error} error | 1453 * @param {?Protocol.Error} error |
1454 * @this {WebInspector.DOMAgent} | 1454 * @this {WebInspector.DOMModel} |
1455 */ | 1455 */ |
1456 function mycallback(error) | 1456 function mycallback(error) |
1457 { | 1457 { |
1458 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.UndoRedoC
ompleted); | 1458 this.dispatchEventToListeners(WebInspector.DOMModel.Events.UndoRedoC
ompleted); |
1459 callback(error); | 1459 callback(error); |
1460 } | 1460 } |
1461 | 1461 |
1462 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.UndoRedoReque
sted); | 1462 this.dispatchEventToListeners(WebInspector.DOMModel.Events.UndoRedoReque
sted); |
1463 DOMAgent.undo(callback); | 1463 DOMAgent.undo(callback); |
1464 }, | 1464 }, |
1465 | 1465 |
1466 /** | 1466 /** |
1467 * @param {function(?Protocol.Error)=} callback | 1467 * @param {function(?Protocol.Error)=} callback |
1468 */ | 1468 */ |
1469 redo: function(callback) | 1469 redo: function(callback) |
1470 { | 1470 { |
1471 /** | 1471 /** |
1472 * @param {?Protocol.Error} error | 1472 * @param {?Protocol.Error} error |
1473 * @this {WebInspector.DOMAgent} | 1473 * @this {WebInspector.DOMModel} |
1474 */ | 1474 */ |
1475 function mycallback(error) | 1475 function mycallback(error) |
1476 { | 1476 { |
1477 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.UndoRedoC
ompleted); | 1477 this.dispatchEventToListeners(WebInspector.DOMModel.Events.UndoRedoC
ompleted); |
1478 callback(error); | 1478 callback(error); |
1479 } | 1479 } |
1480 | 1480 |
1481 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.UndoRedoReque
sted); | 1481 this.dispatchEventToListeners(WebInspector.DOMModel.Events.UndoRedoReque
sted); |
1482 DOMAgent.redo(callback); | 1482 DOMAgent.redo(callback); |
1483 }, | 1483 }, |
1484 | 1484 |
1485 /** | 1485 /** |
1486 * @param {?WebInspector.DOMNodeHighlighter} highlighter | 1486 * @param {?WebInspector.DOMNodeHighlighter} highlighter |
1487 */ | 1487 */ |
1488 setHighlighter: function(highlighter) | 1488 setHighlighter: function(highlighter) |
1489 { | 1489 { |
1490 this._highlighter = highlighter || this._defaultHighlighter; | 1490 this._highlighter = highlighter || this._defaultHighlighter; |
1491 }, | 1491 }, |
1492 | 1492 |
1493 __proto__: WebInspector.Object.prototype | 1493 __proto__: WebInspector.Object.prototype |
1494 } | 1494 } |
1495 | 1495 |
1496 /** | 1496 /** |
1497 * @constructor | 1497 * @constructor |
1498 * @implements {DOMAgent.Dispatcher} | 1498 * @implements {DOMAgent.Dispatcher} |
1499 * @param {!WebInspector.DOMAgent} domAgent | 1499 * @param {!WebInspector.DOMModel} domModel |
1500 */ | 1500 */ |
1501 WebInspector.DOMDispatcher = function(domAgent) | 1501 WebInspector.DOMDispatcher = function(domModel) |
1502 { | 1502 { |
1503 this._domAgent = domAgent; | 1503 this._domModel = domModel; |
1504 } | 1504 } |
1505 | 1505 |
1506 WebInspector.DOMDispatcher.prototype = { | 1506 WebInspector.DOMDispatcher.prototype = { |
1507 documentUpdated: function() | 1507 documentUpdated: function() |
1508 { | 1508 { |
1509 this._domAgent._documentUpdated(); | 1509 this._domModel._documentUpdated(); |
1510 }, | 1510 }, |
1511 | 1511 |
1512 /** | 1512 /** |
1513 * @param {!DOMAgent.NodeId} nodeId | 1513 * @param {!DOMAgent.NodeId} nodeId |
1514 */ | 1514 */ |
1515 inspectNodeRequested: function(nodeId) | 1515 inspectNodeRequested: function(nodeId) |
1516 { | 1516 { |
1517 this._domAgent._inspectNodeRequested(nodeId); | 1517 this._domModel._inspectNodeRequested(nodeId); |
1518 }, | 1518 }, |
1519 | 1519 |
1520 /** | 1520 /** |
1521 * @param {!DOMAgent.NodeId} nodeId | 1521 * @param {!DOMAgent.NodeId} nodeId |
1522 * @param {string} name | 1522 * @param {string} name |
1523 * @param {string} value | 1523 * @param {string} value |
1524 */ | 1524 */ |
1525 attributeModified: function(nodeId, name, value) | 1525 attributeModified: function(nodeId, name, value) |
1526 { | 1526 { |
1527 this._domAgent._attributeModified(nodeId, name, value); | 1527 this._domModel._attributeModified(nodeId, name, value); |
1528 }, | 1528 }, |
1529 | 1529 |
1530 /** | 1530 /** |
1531 * @param {!DOMAgent.NodeId} nodeId | 1531 * @param {!DOMAgent.NodeId} nodeId |
1532 * @param {string} name | 1532 * @param {string} name |
1533 */ | 1533 */ |
1534 attributeRemoved: function(nodeId, name) | 1534 attributeRemoved: function(nodeId, name) |
1535 { | 1535 { |
1536 this._domAgent._attributeRemoved(nodeId, name); | 1536 this._domModel._attributeRemoved(nodeId, name); |
1537 }, | 1537 }, |
1538 | 1538 |
1539 /** | 1539 /** |
1540 * @param {!Array.<!DOMAgent.NodeId>} nodeIds | 1540 * @param {!Array.<!DOMAgent.NodeId>} nodeIds |
1541 */ | 1541 */ |
1542 inlineStyleInvalidated: function(nodeIds) | 1542 inlineStyleInvalidated: function(nodeIds) |
1543 { | 1543 { |
1544 this._domAgent._inlineStyleInvalidated(nodeIds); | 1544 this._domModel._inlineStyleInvalidated(nodeIds); |
1545 }, | 1545 }, |
1546 | 1546 |
1547 /** | 1547 /** |
1548 * @param {!DOMAgent.NodeId} nodeId | 1548 * @param {!DOMAgent.NodeId} nodeId |
1549 * @param {string} characterData | 1549 * @param {string} characterData |
1550 */ | 1550 */ |
1551 characterDataModified: function(nodeId, characterData) | 1551 characterDataModified: function(nodeId, characterData) |
1552 { | 1552 { |
1553 this._domAgent._characterDataModified(nodeId, characterData); | 1553 this._domModel._characterDataModified(nodeId, characterData); |
1554 }, | 1554 }, |
1555 | 1555 |
1556 /** | 1556 /** |
1557 * @param {!DOMAgent.NodeId} parentId | 1557 * @param {!DOMAgent.NodeId} parentId |
1558 * @param {!Array.<!DOMAgent.Node>} payloads | 1558 * @param {!Array.<!DOMAgent.Node>} payloads |
1559 */ | 1559 */ |
1560 setChildNodes: function(parentId, payloads) | 1560 setChildNodes: function(parentId, payloads) |
1561 { | 1561 { |
1562 this._domAgent._setChildNodes(parentId, payloads); | 1562 this._domModel._setChildNodes(parentId, payloads); |
1563 }, | 1563 }, |
1564 | 1564 |
1565 /** | 1565 /** |
1566 * @param {!DOMAgent.NodeId} nodeId | 1566 * @param {!DOMAgent.NodeId} nodeId |
1567 * @param {number} childNodeCount | 1567 * @param {number} childNodeCount |
1568 */ | 1568 */ |
1569 childNodeCountUpdated: function(nodeId, childNodeCount) | 1569 childNodeCountUpdated: function(nodeId, childNodeCount) |
1570 { | 1570 { |
1571 this._domAgent._childNodeCountUpdated(nodeId, childNodeCount); | 1571 this._domModel._childNodeCountUpdated(nodeId, childNodeCount); |
1572 }, | 1572 }, |
1573 | 1573 |
1574 /** | 1574 /** |
1575 * @param {!DOMAgent.NodeId} parentNodeId | 1575 * @param {!DOMAgent.NodeId} parentNodeId |
1576 * @param {!DOMAgent.NodeId} previousNodeId | 1576 * @param {!DOMAgent.NodeId} previousNodeId |
1577 * @param {!DOMAgent.Node} payload | 1577 * @param {!DOMAgent.Node} payload |
1578 */ | 1578 */ |
1579 childNodeInserted: function(parentNodeId, previousNodeId, payload) | 1579 childNodeInserted: function(parentNodeId, previousNodeId, payload) |
1580 { | 1580 { |
1581 this._domAgent._childNodeInserted(parentNodeId, previousNodeId, payload)
; | 1581 this._domModel._childNodeInserted(parentNodeId, previousNodeId, payload)
; |
1582 }, | 1582 }, |
1583 | 1583 |
1584 /** | 1584 /** |
1585 * @param {!DOMAgent.NodeId} parentNodeId | 1585 * @param {!DOMAgent.NodeId} parentNodeId |
1586 * @param {!DOMAgent.NodeId} nodeId | 1586 * @param {!DOMAgent.NodeId} nodeId |
1587 */ | 1587 */ |
1588 childNodeRemoved: function(parentNodeId, nodeId) | 1588 childNodeRemoved: function(parentNodeId, nodeId) |
1589 { | 1589 { |
1590 this._domAgent._childNodeRemoved(parentNodeId, nodeId); | 1590 this._domModel._childNodeRemoved(parentNodeId, nodeId); |
1591 }, | 1591 }, |
1592 | 1592 |
1593 /** | 1593 /** |
1594 * @param {!DOMAgent.NodeId} hostId | 1594 * @param {!DOMAgent.NodeId} hostId |
1595 * @param {!DOMAgent.Node} root | 1595 * @param {!DOMAgent.Node} root |
1596 */ | 1596 */ |
1597 shadowRootPushed: function(hostId, root) | 1597 shadowRootPushed: function(hostId, root) |
1598 { | 1598 { |
1599 this._domAgent._shadowRootPushed(hostId, root); | 1599 this._domModel._shadowRootPushed(hostId, root); |
1600 }, | 1600 }, |
1601 | 1601 |
1602 /** | 1602 /** |
1603 * @param {!DOMAgent.NodeId} hostId | 1603 * @param {!DOMAgent.NodeId} hostId |
1604 * @param {!DOMAgent.NodeId} rootId | 1604 * @param {!DOMAgent.NodeId} rootId |
1605 */ | 1605 */ |
1606 shadowRootPopped: function(hostId, rootId) | 1606 shadowRootPopped: function(hostId, rootId) |
1607 { | 1607 { |
1608 this._domAgent._shadowRootPopped(hostId, rootId); | 1608 this._domModel._shadowRootPopped(hostId, rootId); |
1609 }, | 1609 }, |
1610 | 1610 |
1611 /** | 1611 /** |
1612 * @param {!DOMAgent.NodeId} parentId | 1612 * @param {!DOMAgent.NodeId} parentId |
1613 * @param {!DOMAgent.Node} pseudoElement | 1613 * @param {!DOMAgent.Node} pseudoElement |
1614 */ | 1614 */ |
1615 pseudoElementAdded: function(parentId, pseudoElement) | 1615 pseudoElementAdded: function(parentId, pseudoElement) |
1616 { | 1616 { |
1617 this._domAgent._pseudoElementAdded(parentId, pseudoElement); | 1617 this._domModel._pseudoElementAdded(parentId, pseudoElement); |
1618 }, | 1618 }, |
1619 | 1619 |
1620 /** | 1620 /** |
1621 * @param {!DOMAgent.NodeId} parentId | 1621 * @param {!DOMAgent.NodeId} parentId |
1622 * @param {!DOMAgent.NodeId} pseudoElementId | 1622 * @param {!DOMAgent.NodeId} pseudoElementId |
1623 */ | 1623 */ |
1624 pseudoElementRemoved: function(parentId, pseudoElementId) | 1624 pseudoElementRemoved: function(parentId, pseudoElementId) |
1625 { | 1625 { |
1626 this._domAgent._pseudoElementRemoved(parentId, pseudoElementId); | 1626 this._domModel._pseudoElementRemoved(parentId, pseudoElementId); |
1627 } | 1627 } |
1628 } | 1628 } |
1629 | 1629 |
1630 /** | 1630 /** |
1631 * @interface | 1631 * @interface |
1632 */ | 1632 */ |
1633 WebInspector.DOMNodeHighlighter = function() { | 1633 WebInspector.DOMNodeHighlighter = function() { |
1634 } | 1634 } |
1635 | 1635 |
1636 WebInspector.DOMNodeHighlighter.prototype = { | 1636 WebInspector.DOMNodeHighlighter.prototype = { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1677 * @param {!DOMAgent.HighlightConfig} config | 1677 * @param {!DOMAgent.HighlightConfig} config |
1678 * @param {function(?Protocol.Error)=} callback | 1678 * @param {function(?Protocol.Error)=} callback |
1679 */ | 1679 */ |
1680 setInspectModeEnabled: function(enabled, inspectUAShadowDOM, config, callbac
k) | 1680 setInspectModeEnabled: function(enabled, inspectUAShadowDOM, config, callbac
k) |
1681 { | 1681 { |
1682 DOMAgent.setInspectModeEnabled(enabled, inspectUAShadowDOM, config, call
back); | 1682 DOMAgent.setInspectModeEnabled(enabled, inspectUAShadowDOM, config, call
back); |
1683 } | 1683 } |
1684 } | 1684 } |
1685 | 1685 |
1686 /** | 1686 /** |
1687 * @type {!WebInspector.DOMAgent} | 1687 * @type {!WebInspector.DOMModel} |
1688 */ | 1688 */ |
1689 WebInspector.domAgent; | 1689 WebInspector.domModel; |
OLD | NEW |