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

Side by Side Diff: Source/WebCore/inspector/front-end/DOMAgent.js

Issue 7147011: Merge 88331 - 2011-06-07 Andrey Kosyakov <caseq@chromium.org> (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/782/
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved.
3 * Copyright (C) 2009 Joseph Pecoraro 3 * Copyright (C) 2009 Joseph Pecoraro
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 this._matchedCSSRules = []; 60 this._matchedCSSRules = [];
61 61
62 if (this._nodeType === Node.ELEMENT_NODE) { 62 if (this._nodeType === Node.ELEMENT_NODE) {
63 // HTML and BODY from internal iframes should not overwrite top-level on es. 63 // HTML and BODY from internal iframes should not overwrite top-level on es.
64 if (!this.ownerDocument.documentElement && this._nodeName === "HTML") 64 if (!this.ownerDocument.documentElement && this._nodeName === "HTML")
65 this.ownerDocument.documentElement = this; 65 this.ownerDocument.documentElement = this;
66 if (!this.ownerDocument.body && this._nodeName === "BODY") 66 if (!this.ownerDocument.body && this._nodeName === "BODY")
67 this.ownerDocument.body = this; 67 this.ownerDocument.body = this;
68 if (payload.documentURL) 68 if (payload.documentURL)
69 this.documentURL = payload.documentURL; 69 this.documentURL = payload.documentURL;
70 if (payload.shadowRoot)
71 this._setShadowRootPayload(payload.shadowRoot);
72 } else if (this._nodeType === Node.DOCUMENT_TYPE_NODE) { 70 } else if (this._nodeType === Node.DOCUMENT_TYPE_NODE) {
73 this.publicId = payload.publicId; 71 this.publicId = payload.publicId;
74 this.systemId = payload.systemId; 72 this.systemId = payload.systemId;
75 this.internalSubset = payload.internalSubset; 73 this.internalSubset = payload.internalSubset;
76 } else if (this._nodeType === Node.DOCUMENT_NODE) { 74 } else if (this._nodeType === Node.DOCUMENT_NODE) {
77 this.documentURL = payload.documentURL; 75 this.documentURL = payload.documentURL;
78 this.xmlVersion = payload.xmlVersion; 76 this.xmlVersion = payload.xmlVersion;
79 } else if (this._nodeType === Node.ATTRIBUTE_NODE) { 77 } else if (this._nodeType === Node.ATTRIBUTE_NODE) {
80 this.name = payload.name; 78 this.name = payload.name;
81 this.value = payload.value; 79 this.value = payload.value;
82 } 80 }
83 } 81 }
84 82
85 WebInspector.DOMNode.prototype = { 83 WebInspector.DOMNode.prototype = {
86 hasAttributes: function() 84 hasAttributes: function()
87 { 85 {
88 return this._attributes.length > 0; 86 return this._attributes.length > 0;
89 }, 87 },
90 88
91 hasChildNodes: function() 89 hasChildNodes: function()
92 { 90 {
93 return this._childNodeCount > 0; 91 return this._childNodeCount > 0;
94 }, 92 },
95 93
96 nodeType: function() 94 nodeType: function()
97 { 95 {
98 return this._nodeType; 96 return this._nodeType;
99 }, 97 },
100 98
101 inShadowTree: function()
102 {
103 return this._inShadowTree;
104 },
105
106 nodeName: function() 99 nodeName: function()
107 { 100 {
108 return this._nodeName; 101 return this._nodeName;
109 }, 102 },
110 103
111 setNodeName: function(name, callback) 104 setNodeName: function(name, callback)
112 { 105 {
113 DOMAgent.setNodeName(this.id, name, callback); 106 DOMAgent.setNodeName(this.id, name, callback);
114 }, 107 },
115 108
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 { 265 {
273 this.children = []; 266 this.children = [];
274 for (var i = 0; i < payloads.length; ++i) { 267 for (var i = 0; i < payloads.length; ++i) {
275 var payload = payloads[i]; 268 var payload = payloads[i];
276 var node = new WebInspector.DOMNode(this.ownerDocument, payload); 269 var node = new WebInspector.DOMNode(this.ownerDocument, payload);
277 this.children.push(node); 270 this.children.push(node);
278 } 271 }
279 this._renumber(); 272 this._renumber();
280 }, 273 },
281 274
282 _setShadowRootPayload: function(payload)
283 {
284 if (!payload) {
285 this.shadowRoot = null;
286 return;
287 }
288 this.shadowRoot = new WebInspector.DOMNode(this.ownerDocument, payload);
289 this.shadowRoot.parentNode = this;
290 this.shadowRoot._inShadowTree = true;
291 },
292
293 _renumber: function() 275 _renumber: function()
294 { 276 {
295 this._childNodeCount = this.children.length; 277 this._childNodeCount = this.children.length;
296 if (this._childNodeCount == 0) { 278 if (this._childNodeCount == 0) {
297 this.firstChild = null; 279 this.firstChild = null;
298 this.lastChild = null; 280 this.lastChild = null;
299 return; 281 return;
300 } 282 }
301 this.firstChild = this.children[0]; 283 this.firstChild = this.children[0];
302 this.lastChild = this.children[this._childNodeCount - 1]; 284 this.lastChild = this.children[this._childNodeCount - 1];
303 for (var i = 0; i < this._childNodeCount; ++i) { 285 for (var i = 0; i < this._childNodeCount; ++i) {
304 var child = this.children[i]; 286 var child = this.children[i];
305 child.index = i; 287 child.index = i;
306 child.nextSibling = i + 1 < this._childNodeCount ? this.children[i + 1] : null; 288 child.nextSibling = i + 1 < this._childNodeCount ? this.children[i + 1] : null;
307 child.prevSibling = i - 1 >= 0 ? this.children[i - 1] : null; 289 child.prevSibling = i - 1 >= 0 ? this.children[i - 1] : null;
308 child.parentNode = this; 290 child.parentNode = this;
309 child._inShadowTree = this._inShadowTree;
310 } 291 }
311 }, 292 },
312 293
313 _addAttribute: function(name, value) 294 _addAttribute: function(name, value)
314 { 295 {
315 var attr = { 296 var attr = {
316 "name": name, 297 "name": name,
317 "value": value, 298 "value": value,
318 "_node": this 299 "_node": this
319 }; 300 };
(...skipping 26 matching lines...) Expand all
346 this._document = null; 327 this._document = null;
347 InspectorBackend.registerDomainDispatcher("DOM", new WebInspector.DOMDispatc her(this)); 328 InspectorBackend.registerDomainDispatcher("DOM", new WebInspector.DOMDispatc her(this));
348 } 329 }
349 330
350 WebInspector.DOMAgent.Events = { 331 WebInspector.DOMAgent.Events = {
351 AttrModified: "AttrModified", 332 AttrModified: "AttrModified",
352 CharacterDataModified: "CharacterDataModified", 333 CharacterDataModified: "CharacterDataModified",
353 NodeInserted: "NodeInserted", 334 NodeInserted: "NodeInserted",
354 NodeRemoved: "NodeRemoved", 335 NodeRemoved: "NodeRemoved",
355 DocumentUpdated: "DocumentUpdated", 336 DocumentUpdated: "DocumentUpdated",
356 ChildNodeCountUpdated: "ChildNodeCountUpdated", 337 ChildNodeCountUpdated: "ChildNodeCountUpdated"
357 ShadowRootUpdated: "ShadowRootUpdated"
358 } 338 }
359 339
360 WebInspector.DOMAgent.prototype = { 340 WebInspector.DOMAgent.prototype = {
361 requestDocument: function(callback) 341 requestDocument: function(callback)
362 { 342 {
363 if (this._document) { 343 if (this._document) {
364 if (callback) 344 if (callback)
365 callback(this._document); 345 callback(this._document);
366 return; 346 return;
367 } 347 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 var parent = this._idToDOMNode[parentId]; 467 var parent = this._idToDOMNode[parentId];
488 parent._setChildrenPayload(payloads); 468 parent._setChildrenPayload(payloads);
489 this._bindNodes(parent.children); 469 this._bindNodes(parent.children);
490 }, 470 },
491 471
492 _bindNodes: function(children) 472 _bindNodes: function(children)
493 { 473 {
494 for (var i = 0; i < children.length; ++i) { 474 for (var i = 0; i < children.length; ++i) {
495 var child = children[i]; 475 var child = children[i];
496 this._idToDOMNode[child.id] = child; 476 this._idToDOMNode[child.id] = child;
497 if (child.shadowRoot)
498 this._idToDOMNode[child.shadowRoot.id] = child.shadowRoot;
499
500 if (child.children) 477 if (child.children)
501 this._bindNodes(child.children); 478 this._bindNodes(child.children);
502 } 479 }
503 }, 480 },
504 481
505 _childNodeCountUpdated: function(nodeId, newValue) 482 _childNodeCountUpdated: function(nodeId, newValue)
506 { 483 {
507 var node = this._idToDOMNode[nodeId]; 484 var node = this._idToDOMNode[nodeId];
508 node._childNodeCount = newValue; 485 node._childNodeCount = newValue;
509 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.ChildNodeCoun tUpdated, node); 486 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.ChildNodeCoun tUpdated, node);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 }, 519 },
543 520
544 querySelector: function(nodeId, selectors, callback) 521 querySelector: function(nodeId, selectors, callback)
545 { 522 {
546 DOMAgent.querySelector(nodeId, selectors, this._wrapClientCallback(callb ack)); 523 DOMAgent.querySelector(nodeId, selectors, this._wrapClientCallback(callb ack));
547 }, 524 },
548 525
549 querySelectorAll: function(nodeId, selectors, callback) 526 querySelectorAll: function(nodeId, selectors, callback)
550 { 527 {
551 DOMAgent.querySelectorAll(nodeId, selectors, this._wrapClientCallback(ca llback)); 528 DOMAgent.querySelectorAll(nodeId, selectors, this._wrapClientCallback(ca llback));
552 },
553
554 _shadowRootUpdated: function(hostId, payload)
555 {
556 var host = this._idToDOMNode[hostId];
557 if (host.shadowRoot && !payload)
558 delete this._idToDOMNode[host.shadowRoot.id];
559 host._setShadowRootPayload(payload);
560 if (host.shadowRoot)
561 this._idToDOMNode[host.shadowRoot.id] = host.shadowRoot;
562 this.dispatchEventToListeners(WebInspector.DOMAgent.Events.ShadowRootUpd ated, host);
563 } 529 }
564 } 530 }
565 531
566 WebInspector.DOMAgent.prototype.__proto__ = WebInspector.Object.prototype; 532 WebInspector.DOMAgent.prototype.__proto__ = WebInspector.Object.prototype;
567 533
568 WebInspector.DOMDispatcher = function(domAgent) 534 WebInspector.DOMDispatcher = function(domAgent)
569 { 535 {
570 this._domAgent = domAgent; 536 this._domAgent = domAgent;
571 } 537 }
572 538
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 574
609 inspectElementRequested: function(nodeId) 575 inspectElementRequested: function(nodeId)
610 { 576 {
611 WebInspector.updateFocusedNode(nodeId); 577 WebInspector.updateFocusedNode(nodeId);
612 }, 578 },
613 579
614 searchResults: function(nodeIds) 580 searchResults: function(nodeIds)
615 { 581 {
616 if (this._domAgent._searchResultCollector) 582 if (this._domAgent._searchResultCollector)
617 this._domAgent._searchResultCollector(nodeIds); 583 this._domAgent._searchResultCollector(nodeIds);
618 },
619
620 shadowRootUpdated: function(hostId, shadowRoot)
621 {
622 this._domAgent._shadowRootUpdated(hostId, shadowRoot);
623 } 584 }
624 } 585 }
OLDNEW
« no previous file with comments | « Source/WebCore/inspector/InspectorDOMAgent.cpp ('k') | Source/WebCore/inspector/front-end/ElementsPanel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698