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 22 matching lines...) Expand all Loading... |
33 * @constructor | 33 * @constructor |
34 * @extends {WebInspector.TargetAware} | 34 * @extends {WebInspector.TargetAware} |
35 * @param {!WebInspector.DOMModel} domModel | 35 * @param {!WebInspector.DOMModel} domModel |
36 * @param {?WebInspector.DOMDocument} doc | 36 * @param {?WebInspector.DOMDocument} doc |
37 * @param {boolean} isInShadowTree | 37 * @param {boolean} isInShadowTree |
38 * @param {!DOMAgent.Node} payload | 38 * @param {!DOMAgent.Node} payload |
39 */ | 39 */ |
40 WebInspector.DOMNode = function(domModel, doc, isInShadowTree, payload) { | 40 WebInspector.DOMNode = function(domModel, doc, isInShadowTree, payload) { |
41 WebInspector.TargetAware.call(this, domModel._target); | 41 WebInspector.TargetAware.call(this, domModel._target); |
42 this._domModel = domModel; | 42 this._domModel = domModel; |
| 43 this._agent = domModel._agent; |
43 this.ownerDocument = doc; | 44 this.ownerDocument = doc; |
44 this._isInShadowTree = isInShadowTree; | 45 this._isInShadowTree = isInShadowTree; |
45 | 46 |
46 this.id = payload.nodeId; | 47 this.id = payload.nodeId; |
47 domModel._idToDOMNode[this.id] = this; | 48 domModel._idToDOMNode[this.id] = this; |
48 this._nodeType = payload.nodeType; | 49 this._nodeType = payload.nodeType; |
49 this._nodeName = payload.nodeName; | 50 this._nodeName = payload.nodeName; |
50 this._localName = payload.localName; | 51 this._localName = payload.localName; |
51 this._nodeValue = payload.nodeValue; | 52 this._nodeValue = payload.nodeValue; |
52 this._pseudoType = payload.pseudoType; | 53 this._pseudoType = payload.pseudoType; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 /** | 130 /** |
130 * @enum {string} | 131 * @enum {string} |
131 */ | 132 */ |
132 WebInspector.DOMNode.ShadowRootTypes = { | 133 WebInspector.DOMNode.ShadowRootTypes = { |
133 UserAgent: "user-agent", | 134 UserAgent: "user-agent", |
134 Author: "author" | 135 Author: "author" |
135 } | 136 } |
136 | 137 |
137 WebInspector.DOMNode.prototype = { | 138 WebInspector.DOMNode.prototype = { |
138 /** | 139 /** |
| 140 * @return {!WebInspector.DOMModel} |
| 141 */ |
| 142 domModel: function() |
| 143 { |
| 144 return this._domModel; |
| 145 }, |
| 146 |
| 147 /** |
139 * @return {?Array.<!WebInspector.DOMNode>} | 148 * @return {?Array.<!WebInspector.DOMNode>} |
140 */ | 149 */ |
141 children: function() | 150 children: function() |
142 { | 151 { |
143 return this._children ? this._children.slice() : null; | 152 return this._children ? this._children.slice() : null; |
144 }, | 153 }, |
145 | 154 |
146 /** | 155 /** |
147 * @return {boolean} | 156 * @return {boolean} |
148 */ | 157 */ |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 return "#shadow-root" + (shadowRootType === WebInspector.DOMNode.Sha
dowRootTypes.UserAgent ? " (user-agent)" : ""); | 288 return "#shadow-root" + (shadowRootType === WebInspector.DOMNode.Sha
dowRootTypes.UserAgent ? " (user-agent)" : ""); |
280 return this.isXMLNode() ? this.nodeName() : this.nodeName().toLowerCase(
); | 289 return this.isXMLNode() ? this.nodeName() : this.nodeName().toLowerCase(
); |
281 }, | 290 }, |
282 | 291 |
283 /** | 292 /** |
284 * @param {string} name | 293 * @param {string} name |
285 * @param {function(?Protocol.Error)=} callback | 294 * @param {function(?Protocol.Error)=} callback |
286 */ | 295 */ |
287 setNodeName: function(name, callback) | 296 setNodeName: function(name, callback) |
288 { | 297 { |
289 DOMAgent.setNodeName(this.id, name, WebInspector.domModel._markRevision(
this, callback)); | 298 this._agent.setNodeName(this.id, name, this._domModel._markRevision(this
, callback)); |
290 }, | 299 }, |
291 | 300 |
292 /** | 301 /** |
293 * @return {string} | 302 * @return {string} |
294 */ | 303 */ |
295 localName: function() | 304 localName: function() |
296 { | 305 { |
297 return this._localName; | 306 return this._localName; |
298 }, | 307 }, |
299 | 308 |
300 /** | 309 /** |
301 * @return {string} | 310 * @return {string} |
302 */ | 311 */ |
303 nodeValue: function() | 312 nodeValue: function() |
304 { | 313 { |
305 return this._nodeValue; | 314 return this._nodeValue; |
306 }, | 315 }, |
307 | 316 |
308 /** | 317 /** |
309 * @param {string} value | 318 * @param {string} value |
310 * @param {function(?Protocol.Error)=} callback | 319 * @param {function(?Protocol.Error)=} callback |
311 */ | 320 */ |
312 setNodeValue: function(value, callback) | 321 setNodeValue: function(value, callback) |
313 { | 322 { |
314 DOMAgent.setNodeValue(this.id, value, WebInspector.domModel._markRevisio
n(this, callback)); | 323 this._agent.setNodeValue(this.id, value, this._domModel._markRevision(th
is, callback)); |
315 }, | 324 }, |
316 | 325 |
317 /** | 326 /** |
318 * @param {string} name | 327 * @param {string} name |
319 * @return {string} | 328 * @return {string} |
320 */ | 329 */ |
321 getAttribute: function(name) | 330 getAttribute: function(name) |
322 { | 331 { |
323 var attr = this._attributesMap[name]; | 332 var attr = this._attributesMap[name]; |
324 return attr ? attr.value : undefined; | 333 return attr ? attr.value : undefined; |
325 }, | 334 }, |
326 | 335 |
327 /** | 336 /** |
328 * @param {string} name | 337 * @param {string} name |
329 * @param {string} text | 338 * @param {string} text |
330 * @param {function(?Protocol.Error)=} callback | 339 * @param {function(?Protocol.Error)=} callback |
331 */ | 340 */ |
332 setAttribute: function(name, text, callback) | 341 setAttribute: function(name, text, callback) |
333 { | 342 { |
334 DOMAgent.setAttributesAsText(this.id, text, name, WebInspector.domModel.
_markRevision(this, callback)); | 343 this._agent.setAttributesAsText(this.id, text, name, this._domModel._mar
kRevision(this, callback)); |
335 }, | 344 }, |
336 | 345 |
337 /** | 346 /** |
338 * @param {string} name | 347 * @param {string} name |
339 * @param {string} value | 348 * @param {string} value |
340 * @param {function(?Protocol.Error)=} callback | 349 * @param {function(?Protocol.Error)=} callback |
341 */ | 350 */ |
342 setAttributeValue: function(name, value, callback) | 351 setAttributeValue: function(name, value, callback) |
343 { | 352 { |
344 DOMAgent.setAttributeValue(this.id, name, value, WebInspector.domModel._
markRevision(this, callback)); | 353 this._agent.setAttributeValue(this.id, name, value, this._domModel._mark
Revision(this, callback)); |
345 }, | 354 }, |
346 | 355 |
347 /** | 356 /** |
348 * @return {!Object} | 357 * @return {!Object} |
349 */ | 358 */ |
350 attributes: function() | 359 attributes: function() |
351 { | 360 { |
352 return this._attributes; | 361 return this._attributes; |
353 }, | 362 }, |
354 | 363 |
(...skipping 12 matching lines...) Expand all Loading... |
367 if (!error) { | 376 if (!error) { |
368 delete this._attributesMap[name]; | 377 delete this._attributesMap[name]; |
369 for (var i = 0; i < this._attributes.length; ++i) { | 378 for (var i = 0; i < this._attributes.length; ++i) { |
370 if (this._attributes[i].name === name) { | 379 if (this._attributes[i].name === name) { |
371 this._attributes.splice(i, 1); | 380 this._attributes.splice(i, 1); |
372 break; | 381 break; |
373 } | 382 } |
374 } | 383 } |
375 } | 384 } |
376 | 385 |
377 WebInspector.domModel._markRevision(this, callback)(error); | 386 this._domModel._markRevision(this, callback)(error); |
378 } | 387 } |
379 DOMAgent.removeAttribute(this.id, name, mycallback.bind(this)); | 388 this._agent.removeAttribute(this.id, name, mycallback.bind(this)); |
380 }, | 389 }, |
381 | 390 |
382 /** | 391 /** |
383 * @param {function(?Array.<!WebInspector.DOMNode>)=} callback | 392 * @param {function(?Array.<!WebInspector.DOMNode>)=} callback |
384 */ | 393 */ |
385 getChildNodes: function(callback) | 394 getChildNodes: function(callback) |
386 { | 395 { |
387 if (this._children) { | 396 if (this._children) { |
388 if (callback) | 397 if (callback) |
389 callback(this.children()); | 398 callback(this.children()); |
390 return; | 399 return; |
391 } | 400 } |
392 | 401 |
393 /** | 402 /** |
394 * @this {WebInspector.DOMNode} | 403 * @this {WebInspector.DOMNode} |
395 * @param {?Protocol.Error} error | 404 * @param {?Protocol.Error} error |
396 */ | 405 */ |
397 function mycallback(error) | 406 function mycallback(error) |
398 { | 407 { |
399 if (callback) | 408 if (callback) |
400 callback(error ? null : this.children()); | 409 callback(error ? null : this.children()); |
401 } | 410 } |
402 | 411 |
403 DOMAgent.requestChildNodes(this.id, undefined, mycallback.bind(this)); | 412 this._agent.requestChildNodes(this.id, undefined, mycallback.bind(this))
; |
404 }, | 413 }, |
405 | 414 |
406 /** | 415 /** |
407 * @param {number} depth | 416 * @param {number} depth |
408 * @param {function(?Array.<!WebInspector.DOMNode>)=} callback | 417 * @param {function(?Array.<!WebInspector.DOMNode>)=} callback |
409 */ | 418 */ |
410 getSubtree: function(depth, callback) | 419 getSubtree: function(depth, callback) |
411 { | 420 { |
412 /** | 421 /** |
413 * @this {WebInspector.DOMNode} | 422 * @this {WebInspector.DOMNode} |
414 * @param {?Protocol.Error} error | 423 * @param {?Protocol.Error} error |
415 */ | 424 */ |
416 function mycallback(error) | 425 function mycallback(error) |
417 { | 426 { |
418 if (callback) | 427 if (callback) |
419 callback(error ? null : this._children); | 428 callback(error ? null : this._children); |
420 } | 429 } |
421 | 430 |
422 DOMAgent.requestChildNodes(this.id, depth, mycallback.bind(this)); | 431 this._agent.requestChildNodes(this.id, depth, mycallback.bind(this)); |
423 }, | 432 }, |
424 | 433 |
425 /** | 434 /** |
426 * @param {function(?Protocol.Error)=} callback | 435 * @param {function(?Protocol.Error)=} callback |
427 */ | 436 */ |
428 getOuterHTML: function(callback) | 437 getOuterHTML: function(callback) |
429 { | 438 { |
430 DOMAgent.getOuterHTML(this.id, callback); | 439 this._agent.getOuterHTML(this.id, callback); |
431 }, | 440 }, |
432 | 441 |
433 /** | 442 /** |
434 * @param {string} html | 443 * @param {string} html |
435 * @param {function(?Protocol.Error)=} callback | 444 * @param {function(?Protocol.Error)=} callback |
436 */ | 445 */ |
437 setOuterHTML: function(html, callback) | 446 setOuterHTML: function(html, callback) |
438 { | 447 { |
439 DOMAgent.setOuterHTML(this.id, html, WebInspector.domModel._markRevision
(this, callback)); | 448 this._agent.setOuterHTML(this.id, html, this._domModel._markRevision(thi
s, callback)); |
440 }, | 449 }, |
441 | 450 |
442 /** | 451 /** |
443 * @param {function(?Protocol.Error, !DOMAgent.NodeId=)=} callback | 452 * @param {function(?Protocol.Error, !DOMAgent.NodeId=)=} callback |
444 */ | 453 */ |
445 removeNode: function(callback) | 454 removeNode: function(callback) |
446 { | 455 { |
447 DOMAgent.removeNode(this.id, WebInspector.domModel._markRevision(this, c
allback)); | 456 this._agent.removeNode(this.id, this._domModel._markRevision(this, callb
ack)); |
448 }, | 457 }, |
449 | 458 |
450 copyNode: function() | 459 copyNode: function() |
451 { | 460 { |
452 function copy(error, text) | 461 function copy(error, text) |
453 { | 462 { |
454 if (!error) | 463 if (!error) |
455 InspectorFrontendHost.copyText(text); | 464 InspectorFrontendHost.copyText(text); |
456 } | 465 } |
457 DOMAgent.getOuterHTML(this.id, copy); | 466 this._agent.getOuterHTML(this.id, copy); |
458 }, | 467 }, |
459 | 468 |
460 /** | 469 /** |
461 * @param {string} objectGroupId | 470 * @param {string} objectGroupId |
462 * @param {function(?Protocol.Error, !Array.<!DOMAgent.EventListener>)=} cal
lback | 471 * @param {function(?Protocol.Error, !Array.<!DOMAgent.EventListener>)=} cal
lback |
463 */ | 472 */ |
464 eventListeners: function(objectGroupId, callback) | 473 eventListeners: function(objectGroupId, callback) |
465 { | 474 { |
466 DOMAgent.getEventListenersForNode(this.id, objectGroupId, callback); | 475 this._agent.getEventListenersForNode(this.id, objectGroupId, callback); |
467 }, | 476 }, |
468 | 477 |
469 /** | 478 /** |
470 * @return {string} | 479 * @return {string} |
471 */ | 480 */ |
472 path: function() | 481 path: function() |
473 { | 482 { |
474 /** | 483 /** |
475 * @param {?WebInspector.DOMNode} node | 484 * @param {?WebInspector.DOMNode} node |
476 */ | 485 */ |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 } | 688 } |
680 }, | 689 }, |
681 | 690 |
682 /** | 691 /** |
683 * @param {!WebInspector.DOMNode} targetNode | 692 * @param {!WebInspector.DOMNode} targetNode |
684 * @param {?WebInspector.DOMNode} anchorNode | 693 * @param {?WebInspector.DOMNode} anchorNode |
685 * @param {function(?Protocol.Error, !DOMAgent.NodeId=)=} callback | 694 * @param {function(?Protocol.Error, !DOMAgent.NodeId=)=} callback |
686 */ | 695 */ |
687 moveTo: function(targetNode, anchorNode, callback) | 696 moveTo: function(targetNode, anchorNode, callback) |
688 { | 697 { |
689 DOMAgent.moveTo(this.id, targetNode.id, anchorNode ? anchorNode.id : und
efined, WebInspector.domModel._markRevision(this, callback)); | 698 this._agent.moveTo(this.id, targetNode.id, anchorNode ? anchorNode.id :
undefined, this._domModel._markRevision(this, callback)); |
690 }, | 699 }, |
691 | 700 |
692 /** | 701 /** |
693 * @return {boolean} | 702 * @return {boolean} |
694 */ | 703 */ |
695 isXMLNode: function() | 704 isXMLNode: function() |
696 { | 705 { |
697 return !!this.ownerDocument && !!this.ownerDocument.xmlVersion; | 706 return !!this.ownerDocument && !!this.ownerDocument.xmlVersion; |
698 }, | 707 }, |
699 | 708 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 { | 786 { |
778 if (!url) | 787 if (!url) |
779 return url; | 788 return url; |
780 for (var frameOwnerCandidate = this; frameOwnerCandidate; frameOwnerCand
idate = frameOwnerCandidate.parentNode) { | 789 for (var frameOwnerCandidate = this; frameOwnerCandidate; frameOwnerCand
idate = frameOwnerCandidate.parentNode) { |
781 if (frameOwnerCandidate.baseURL) | 790 if (frameOwnerCandidate.baseURL) |
782 return WebInspector.ParsedURL.completeURL(frameOwnerCandidate.ba
seURL, url); | 791 return WebInspector.ParsedURL.completeURL(frameOwnerCandidate.ba
seURL, url); |
783 } | 792 } |
784 return null; | 793 return null; |
785 }, | 794 }, |
786 | 795 |
| 796 /** |
| 797 * @param {string=} mode |
| 798 * @param {!RuntimeAgent.RemoteObjectId=} objectId |
| 799 */ |
| 800 highlight: function(mode, objectId) |
| 801 { |
| 802 this._domModel.highlightDOMNode(this.id, mode, objectId); |
| 803 }, |
| 804 |
| 805 highlightForTwoSeconds: function() |
| 806 { |
| 807 this._domModel.highlightDOMNodeForTwoSeconds(this.id); |
| 808 }, |
| 809 |
| 810 reveal: function() |
| 811 { |
| 812 WebInspector.Revealer.reveal(this); |
| 813 }, |
| 814 |
| 815 /** |
| 816 * @param {string=} objectGroup |
| 817 * @param {function(?WebInspector.RemoteObject)=} callback |
| 818 */ |
| 819 resolveToObject: function(objectGroup, callback) |
| 820 { |
| 821 this._agent.resolveNode(this.id, objectGroup, mycallback.bind(this)); |
| 822 |
| 823 /** |
| 824 * @param {?Protocol.Error} error |
| 825 * @param {!RuntimeAgent.RemoteObject} object |
| 826 * @this {WebInspector.DOMNode} |
| 827 */ |
| 828 function mycallback(error, object) |
| 829 { |
| 830 if (!callback) |
| 831 return; |
| 832 |
| 833 if (error || !object) |
| 834 callback(null); |
| 835 else |
| 836 callback(this.target().runtimeModel.createRemoteObject(object)); |
| 837 } |
| 838 }, |
| 839 |
787 __proto__: WebInspector.TargetAware.prototype | 840 __proto__: WebInspector.TargetAware.prototype |
788 } | 841 } |
789 | 842 |
790 /** | 843 /** |
791 * @extends {WebInspector.DOMNode} | 844 * @extends {WebInspector.DOMNode} |
792 * @constructor | 845 * @constructor |
793 * @param {!WebInspector.DOMModel} domModel | 846 * @param {!WebInspector.DOMModel} domModel |
794 * @param {!DOMAgent.Node} payload | 847 * @param {!DOMAgent.Node} payload |
795 */ | 848 */ |
796 WebInspector.DOMDocument = function(domModel, payload) | 849 WebInspector.DOMDocument = function(domModel, payload) |
797 { | 850 { |
798 WebInspector.DOMNode.call(this, domModel, this, false, payload); | 851 WebInspector.DOMNode.call(this, domModel, this, false, payload); |
799 this.documentURL = payload.documentURL || ""; | 852 this.documentURL = payload.documentURL || ""; |
800 this.baseURL = payload.baseURL || ""; | 853 this.baseURL = payload.baseURL || ""; |
801 this.xmlVersion = payload.xmlVersion; | 854 this.xmlVersion = payload.xmlVersion; |
802 this._listeners = {}; | 855 this._listeners = {}; |
803 } | 856 } |
804 | 857 |
805 WebInspector.DOMDocument.prototype = { | 858 WebInspector.DOMDocument.prototype = { |
806 __proto__: WebInspector.DOMNode.prototype | 859 __proto__: WebInspector.DOMNode.prototype |
807 } | 860 } |
808 | 861 |
809 /** | 862 /** |
810 * @extends {WebInspector.Object} | 863 * @extends {WebInspector.Object} |
811 * @constructor | 864 * @constructor |
812 * @param {!WebInspector.Target} target | 865 * @param {!WebInspector.Target} target |
813 */ | 866 */ |
814 WebInspector.DOMModel = function(target) { | 867 WebInspector.DOMModel = function(target) { |
815 this._target = target; | 868 this._target = target; |
| 869 this._agent = target.domAgent(); |
| 870 |
816 /** @type {!Object.<number, !WebInspector.DOMNode>} */ | 871 /** @type {!Object.<number, !WebInspector.DOMNode>} */ |
817 this._idToDOMNode = {}; | 872 this._idToDOMNode = {}; |
818 /** @type {?WebInspector.DOMDocument} */ | 873 /** @type {?WebInspector.DOMDocument} */ |
819 this._document = null; | 874 this._document = null; |
820 /** @type {!Object.<number, boolean>} */ | 875 /** @type {!Object.<number, boolean>} */ |
821 this._attributeLoadNodeIds = {}; | 876 this._attributeLoadNodeIds = {}; |
822 InspectorBackend.registerDOMDispatcher(new WebInspector.DOMDispatcher(this))
; | 877 InspectorBackend.registerDOMDispatcher(new WebInspector.DOMDispatcher(this))
; |
823 | 878 |
824 this._defaultHighlighter = new WebInspector.DefaultDOMNodeHighlighter(); | 879 this._defaultHighlighter = new WebInspector.DefaultDOMNodeHighlighter(this._
agent); |
825 this._highlighter = this._defaultHighlighter; | 880 this._highlighter = this._defaultHighlighter; |
826 } | 881 } |
827 | 882 |
828 WebInspector.DOMModel.Events = { | 883 WebInspector.DOMModel.Events = { |
829 AttrModified: "AttrModified", | 884 AttrModified: "AttrModified", |
830 AttrRemoved: "AttrRemoved", | 885 AttrRemoved: "AttrRemoved", |
831 CharacterDataModified: "CharacterDataModified", | 886 CharacterDataModified: "CharacterDataModified", |
832 NodeInserted: "NodeInserted", | 887 NodeInserted: "NodeInserted", |
833 NodeRemoved: "NodeRemoved", | 888 NodeRemoved: "NodeRemoved", |
834 DocumentUpdated: "DocumentUpdated", | 889 DocumentUpdated: "DocumentUpdated", |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 this._setDocument(root); | 922 this._setDocument(root); |
868 | 923 |
869 for (var i = 0; i < this._pendingDocumentRequestCallbacks.length; ++
i) { | 924 for (var i = 0; i < this._pendingDocumentRequestCallbacks.length; ++
i) { |
870 var callback = this._pendingDocumentRequestCallbacks[i]; | 925 var callback = this._pendingDocumentRequestCallbacks[i]; |
871 if (callback) | 926 if (callback) |
872 callback(this._document); | 927 callback(this._document); |
873 } | 928 } |
874 delete this._pendingDocumentRequestCallbacks; | 929 delete this._pendingDocumentRequestCallbacks; |
875 } | 930 } |
876 | 931 |
877 DOMAgent.getDocument(onDocumentAvailable.bind(this)); | 932 this._agent.getDocument(onDocumentAvailable.bind(this)); |
878 }, | 933 }, |
879 | 934 |
880 /** | 935 /** |
881 * @return {?WebInspector.DOMDocument} | 936 * @return {?WebInspector.DOMDocument} |
882 */ | 937 */ |
883 existingDocument: function() | 938 existingDocument: function() |
884 { | 939 { |
885 return this._document; | 940 return this._document; |
886 }, | 941 }, |
887 | 942 |
888 /** | 943 /** |
889 * @param {!RuntimeAgent.RemoteObjectId} objectId | 944 * @param {!RuntimeAgent.RemoteObjectId} objectId |
890 * @param {function(?DOMAgent.NodeId)=} callback | 945 * @param {function(?DOMAgent.NodeId)=} callback |
891 */ | 946 */ |
892 pushNodeToFrontend: function(objectId, callback) | 947 pushNodeToFrontend: function(objectId, callback) |
893 { | 948 { |
894 this._dispatchWhenDocumentAvailable(DOMAgent.requestNode.bind(DOMAgent,
objectId), callback); | 949 this._dispatchWhenDocumentAvailable(this._agent.requestNode.bind(this._a
gent, objectId), callback); |
895 }, | 950 }, |
896 | 951 |
897 /** | 952 /** |
898 * @param {string} path | 953 * @param {string} path |
899 * @param {function(?number)=} callback | 954 * @param {function(?number)=} callback |
900 */ | 955 */ |
901 pushNodeByPathToFrontend: function(path, callback) | 956 pushNodeByPathToFrontend: function(path, callback) |
902 { | 957 { |
903 this._dispatchWhenDocumentAvailable(DOMAgent.pushNodeByPathToFrontend.bi
nd(DOMAgent, path), callback); | 958 this._dispatchWhenDocumentAvailable(this._agent.pushNodeByPathToFrontend
.bind(this._agent, path), callback); |
904 }, | 959 }, |
905 | 960 |
906 /** | 961 /** |
907 * @param {!Array.<number>} backendNodeIds | 962 * @param {!Array.<number>} backendNodeIds |
908 * @param {function(?Array.<number>)=} callback | 963 * @param {function(?Array.<number>)=} callback |
909 */ | 964 */ |
910 pushNodesByBackendIdsToFrontend: function(backendNodeIds, callback) | 965 pushNodesByBackendIdsToFrontend: function(backendNodeIds, callback) |
911 { | 966 { |
912 this._dispatchWhenDocumentAvailable(DOMAgent.pushNodesByBackendIdsToFron
tend.bind(DOMAgent, backendNodeIds), callback); | 967 this._dispatchWhenDocumentAvailable(this._agent.pushNodesByBackendIdsToF
rontend.bind(this._agent, backendNodeIds), callback); |
913 }, | 968 }, |
914 | 969 |
915 /** | 970 /** |
916 * @param {function(!T)=} callback | 971 * @param {function(!T)=} callback |
917 * @return {function(?Protocol.Error, !T=)|undefined} | 972 * @return {function(?Protocol.Error, !T=)|undefined} |
918 * @template T | 973 * @template T |
919 */ | 974 */ |
920 _wrapClientCallback: function(callback) | 975 _wrapClientCallback: function(callback) |
921 { | 976 { |
922 if (!callback) | 977 if (!callback) |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 if (node) { | 1070 if (node) { |
1016 if (node._setAttributesPayload(attributes)) | 1071 if (node._setAttributesPayload(attributes)) |
1017 this.dispatchEventToListeners(WebInspector.DOMModel.Events.A
ttrModified, { node: node, name: "style" }); | 1072 this.dispatchEventToListeners(WebInspector.DOMModel.Events.A
ttrModified, { node: node, name: "style" }); |
1018 } | 1073 } |
1019 } | 1074 } |
1020 | 1075 |
1021 delete this._loadNodeAttributesTimeout; | 1076 delete this._loadNodeAttributesTimeout; |
1022 | 1077 |
1023 for (var nodeId in this._attributeLoadNodeIds) { | 1078 for (var nodeId in this._attributeLoadNodeIds) { |
1024 var nodeIdAsNumber = parseInt(nodeId, 10); | 1079 var nodeIdAsNumber = parseInt(nodeId, 10); |
1025 DOMAgent.getAttributes(nodeIdAsNumber, callback.bind(this, nodeIdAsN
umber)); | 1080 this._agent.getAttributes(nodeIdAsNumber, callback.bind(this, nodeId
AsNumber)); |
1026 } | 1081 } |
1027 this._attributeLoadNodeIds = {}; | 1082 this._attributeLoadNodeIds = {}; |
1028 }, | 1083 }, |
1029 | 1084 |
1030 /** | 1085 /** |
1031 * @param {!DOMAgent.NodeId} nodeId | 1086 * @param {!DOMAgent.NodeId} nodeId |
1032 * @param {string} newValue | 1087 * @param {string} newValue |
1033 */ | 1088 */ |
1034 _characterDataModified: function(nodeId, newValue) | 1089 _characterDataModified: function(nodeId, newValue) |
1035 { | 1090 { |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 * @param {?Protocol.Error} error | 1296 * @param {?Protocol.Error} error |
1242 * @param {string} searchId | 1297 * @param {string} searchId |
1243 * @param {number} resultsCount | 1298 * @param {number} resultsCount |
1244 * @this {WebInspector.DOMModel} | 1299 * @this {WebInspector.DOMModel} |
1245 */ | 1300 */ |
1246 function callback(error, searchId, resultsCount) | 1301 function callback(error, searchId, resultsCount) |
1247 { | 1302 { |
1248 this._searchId = searchId; | 1303 this._searchId = searchId; |
1249 searchCallback(resultsCount); | 1304 searchCallback(resultsCount); |
1250 } | 1305 } |
1251 DOMAgent.performSearch(query, callback.bind(this)); | 1306 this._agent.performSearch(query, callback.bind(this)); |
1252 }, | 1307 }, |
1253 | 1308 |
1254 /** | 1309 /** |
1255 * @param {number} index | 1310 * @param {number} index |
1256 * @param {?function(?WebInspector.DOMNode)} callback | 1311 * @param {?function(?WebInspector.DOMNode)} callback |
1257 */ | 1312 */ |
1258 searchResult: function(index, callback) | 1313 searchResult: function(index, callback) |
1259 { | 1314 { |
1260 if (this._searchId) | 1315 if (this._searchId) |
1261 DOMAgent.getSearchResults(this._searchId, index, index + 1, searchRe
sultsCallback.bind(this)); | 1316 this._agent.getSearchResults(this._searchId, index, index + 1, searc
hResultsCallback.bind(this)); |
1262 else | 1317 else |
1263 callback(null); | 1318 callback(null); |
1264 | 1319 |
1265 /** | 1320 /** |
1266 * @param {?Protocol.Error} error | 1321 * @param {?Protocol.Error} error |
1267 * @param {!Array.<number>} nodeIds | 1322 * @param {!Array.<number>} nodeIds |
1268 * @this {WebInspector.DOMModel} | 1323 * @this {WebInspector.DOMModel} |
1269 */ | 1324 */ |
1270 function searchResultsCallback(error, nodeIds) | 1325 function searchResultsCallback(error, nodeIds) |
1271 { | 1326 { |
1272 if (error) { | 1327 if (error) { |
1273 console.error(error); | 1328 console.error(error); |
1274 callback(null); | 1329 callback(null); |
1275 return; | 1330 return; |
1276 } | 1331 } |
1277 if (nodeIds.length != 1) | 1332 if (nodeIds.length != 1) |
1278 return; | 1333 return; |
1279 | 1334 |
1280 callback(this.nodeForId(nodeIds[0])); | 1335 callback(this.nodeForId(nodeIds[0])); |
1281 } | 1336 } |
1282 }, | 1337 }, |
1283 | 1338 |
1284 cancelSearch: function() | 1339 cancelSearch: function() |
1285 { | 1340 { |
1286 if (this._searchId) { | 1341 if (this._searchId) { |
1287 DOMAgent.discardSearchResults(this._searchId); | 1342 this._agent.discardSearchResults(this._searchId); |
1288 delete this._searchId; | 1343 delete this._searchId; |
1289 } | 1344 } |
1290 }, | 1345 }, |
1291 | 1346 |
1292 /** | 1347 /** |
1293 * @param {!DOMAgent.NodeId} nodeId | 1348 * @param {!DOMAgent.NodeId} nodeId |
1294 * @param {string} selectors | 1349 * @param {string} selectors |
1295 * @param {function(?DOMAgent.NodeId)=} callback | 1350 * @param {function(?DOMAgent.NodeId)=} callback |
1296 */ | 1351 */ |
1297 querySelector: function(nodeId, selectors, callback) | 1352 querySelector: function(nodeId, selectors, callback) |
1298 { | 1353 { |
1299 DOMAgent.querySelector(nodeId, selectors, this._wrapClientCallback(callb
ack)); | 1354 this._agent.querySelector(nodeId, selectors, this._wrapClientCallback(ca
llback)); |
1300 }, | 1355 }, |
1301 | 1356 |
1302 /** | 1357 /** |
1303 * @param {!DOMAgent.NodeId} nodeId | 1358 * @param {!DOMAgent.NodeId} nodeId |
1304 * @param {string} selectors | 1359 * @param {string} selectors |
1305 * @param {function(!Array.<!DOMAgent.NodeId>=)=} callback | 1360 * @param {function(!Array.<!DOMAgent.NodeId>=)=} callback |
1306 */ | 1361 */ |
1307 querySelectorAll: function(nodeId, selectors, callback) | 1362 querySelectorAll: function(nodeId, selectors, callback) |
1308 { | 1363 { |
1309 DOMAgent.querySelectorAll(nodeId, selectors, this._wrapClientCallback(ca
llback)); | 1364 this._agent.querySelectorAll(nodeId, selectors, this._wrapClientCallback
(callback)); |
1310 }, | 1365 }, |
1311 | 1366 |
1312 /** | 1367 /** |
1313 * @param {!DOMAgent.NodeId=} nodeId | 1368 * @param {!DOMAgent.NodeId=} nodeId |
1314 * @param {string=} mode | 1369 * @param {string=} mode |
1315 * @param {!RuntimeAgent.RemoteObjectId=} objectId | 1370 * @param {!RuntimeAgent.RemoteObjectId=} objectId |
1316 */ | 1371 */ |
1317 highlightDOMNode: function(nodeId, mode, objectId) | 1372 highlightDOMNode: function(nodeId, mode, objectId) |
1318 { | 1373 { |
1319 if (this._hideDOMNodeHighlightTimeout) { | 1374 if (this._hideDOMNodeHighlightTimeout) { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1440 if (error) | 1495 if (error) |
1441 return; | 1496 return; |
1442 this._addTouchEventsScriptId = scriptId; | 1497 this._addTouchEventsScriptId = scriptId; |
1443 } | 1498 } |
1444 | 1499 |
1445 PageAgent.setTouchEmulationEnabled(emulationEnabled); | 1500 PageAgent.setTouchEmulationEnabled(emulationEnabled); |
1446 }, | 1501 }, |
1447 | 1502 |
1448 markUndoableState: function() | 1503 markUndoableState: function() |
1449 { | 1504 { |
1450 DOMAgent.markUndoableState(); | 1505 this._agent.markUndoableState(); |
1451 }, | 1506 }, |
1452 | 1507 |
1453 /** | 1508 /** |
1454 * @param {function(?Protocol.Error)=} callback | 1509 * @param {function(?Protocol.Error)=} callback |
1455 */ | 1510 */ |
1456 undo: function(callback) | 1511 undo: function(callback) |
1457 { | 1512 { |
1458 /** | 1513 /** |
1459 * @param {?Protocol.Error} error | 1514 * @param {?Protocol.Error} error |
1460 * @this {WebInspector.DOMModel} | 1515 * @this {WebInspector.DOMModel} |
1461 */ | 1516 */ |
1462 function mycallback(error) | 1517 function mycallback(error) |
1463 { | 1518 { |
1464 this.dispatchEventToListeners(WebInspector.DOMModel.Events.UndoRedoC
ompleted); | 1519 this.dispatchEventToListeners(WebInspector.DOMModel.Events.UndoRedoC
ompleted); |
1465 callback(error); | 1520 callback(error); |
1466 } | 1521 } |
1467 | 1522 |
1468 this.dispatchEventToListeners(WebInspector.DOMModel.Events.UndoRedoReque
sted); | 1523 this.dispatchEventToListeners(WebInspector.DOMModel.Events.UndoRedoReque
sted); |
1469 DOMAgent.undo(callback); | 1524 this._agent.undo(callback); |
1470 }, | 1525 }, |
1471 | 1526 |
1472 /** | 1527 /** |
1473 * @param {function(?Protocol.Error)=} callback | 1528 * @param {function(?Protocol.Error)=} callback |
1474 */ | 1529 */ |
1475 redo: function(callback) | 1530 redo: function(callback) |
1476 { | 1531 { |
1477 /** | 1532 /** |
1478 * @param {?Protocol.Error} error | 1533 * @param {?Protocol.Error} error |
1479 * @this {WebInspector.DOMModel} | 1534 * @this {WebInspector.DOMModel} |
1480 */ | 1535 */ |
1481 function mycallback(error) | 1536 function mycallback(error) |
1482 { | 1537 { |
1483 this.dispatchEventToListeners(WebInspector.DOMModel.Events.UndoRedoC
ompleted); | 1538 this.dispatchEventToListeners(WebInspector.DOMModel.Events.UndoRedoC
ompleted); |
1484 callback(error); | 1539 callback(error); |
1485 } | 1540 } |
1486 | 1541 |
1487 this.dispatchEventToListeners(WebInspector.DOMModel.Events.UndoRedoReque
sted); | 1542 this.dispatchEventToListeners(WebInspector.DOMModel.Events.UndoRedoReque
sted); |
1488 DOMAgent.redo(callback); | 1543 this._agent.redo(callback); |
1489 }, | 1544 }, |
1490 | 1545 |
1491 /** | 1546 /** |
1492 * @param {?WebInspector.DOMNodeHighlighter} highlighter | 1547 * @param {?WebInspector.DOMNodeHighlighter} highlighter |
1493 */ | 1548 */ |
1494 setHighlighter: function(highlighter) | 1549 setHighlighter: function(highlighter) |
1495 { | 1550 { |
1496 this._highlighter = highlighter || this._defaultHighlighter; | 1551 this._highlighter = highlighter || this._defaultHighlighter; |
1497 }, | 1552 }, |
1498 | 1553 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1652 * @param {boolean} inspectUAShadowDOM | 1707 * @param {boolean} inspectUAShadowDOM |
1653 * @param {!DOMAgent.HighlightConfig} config | 1708 * @param {!DOMAgent.HighlightConfig} config |
1654 * @param {function(?Protocol.Error)=} callback | 1709 * @param {function(?Protocol.Error)=} callback |
1655 */ | 1710 */ |
1656 setInspectModeEnabled: function(enabled, inspectUAShadowDOM, config, callbac
k) {} | 1711 setInspectModeEnabled: function(enabled, inspectUAShadowDOM, config, callbac
k) {} |
1657 } | 1712 } |
1658 | 1713 |
1659 /** | 1714 /** |
1660 * @constructor | 1715 * @constructor |
1661 * @implements {WebInspector.DOMNodeHighlighter} | 1716 * @implements {WebInspector.DOMNodeHighlighter} |
| 1717 * @param {!Protocol.DOMAgent} agent |
1662 */ | 1718 */ |
1663 WebInspector.DefaultDOMNodeHighlighter = function() { | 1719 WebInspector.DefaultDOMNodeHighlighter = function(agent) |
| 1720 { |
| 1721 this._agent = agent; |
1664 } | 1722 } |
1665 | 1723 |
1666 WebInspector.DefaultDOMNodeHighlighter.prototype = { | 1724 WebInspector.DefaultDOMNodeHighlighter.prototype = { |
1667 /** | 1725 /** |
1668 * @param {!DOMAgent.NodeId} nodeId | 1726 * @param {!DOMAgent.NodeId} nodeId |
1669 * @param {!DOMAgent.HighlightConfig} config | 1727 * @param {!DOMAgent.HighlightConfig} config |
1670 * @param {!RuntimeAgent.RemoteObjectId=} objectId | 1728 * @param {!RuntimeAgent.RemoteObjectId=} objectId |
1671 */ | 1729 */ |
1672 highlightDOMNode: function(nodeId, config, objectId) | 1730 highlightDOMNode: function(nodeId, config, objectId) |
1673 { | 1731 { |
1674 if (objectId || nodeId) | 1732 if (objectId || nodeId) |
1675 DOMAgent.highlightNode(config, objectId ? undefined : nodeId, object
Id); | 1733 this._agent.highlightNode(config, objectId ? undefined : nodeId, obj
ectId); |
1676 else | 1734 else |
1677 DOMAgent.hideHighlight(); | 1735 this._agent.hideHighlight(); |
1678 }, | 1736 }, |
1679 | 1737 |
1680 /** | 1738 /** |
1681 * @param {boolean} enabled | 1739 * @param {boolean} enabled |
1682 * @param {boolean} inspectUAShadowDOM | 1740 * @param {boolean} inspectUAShadowDOM |
1683 * @param {!DOMAgent.HighlightConfig} config | 1741 * @param {!DOMAgent.HighlightConfig} config |
1684 * @param {function(?Protocol.Error)=} callback | 1742 * @param {function(?Protocol.Error)=} callback |
1685 */ | 1743 */ |
1686 setInspectModeEnabled: function(enabled, inspectUAShadowDOM, config, callbac
k) | 1744 setInspectModeEnabled: function(enabled, inspectUAShadowDOM, config, callbac
k) |
1687 { | 1745 { |
1688 DOMAgent.setInspectModeEnabled(enabled, inspectUAShadowDOM, config, call
back); | 1746 this._agent.setInspectModeEnabled(enabled, inspectUAShadowDOM, config, c
allback); |
1689 } | 1747 } |
1690 } | 1748 } |
1691 | 1749 |
1692 /** | 1750 /** |
1693 * @type {!WebInspector.DOMModel} | 1751 * @type {!WebInspector.DOMModel} |
1694 */ | 1752 */ |
1695 WebInspector.domModel; | 1753 WebInspector.domModel; |
OLD | NEW |