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

Side by Side Diff: Source/devtools/front_end/ElementsTreeOutline.js

Issue 16561003: DevTools: Inspect element mode does not select element in ShadowDOM (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
4 * Copyright (C) 2009 Joseph Pecoraro 4 * Copyright (C) 2009 Joseph Pecoraro
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 if (!node) 177 if (!node)
178 return false; 178 return false;
179 var treeElement = this.findTreeElement(node); 179 var treeElement = this.findTreeElement(node);
180 if (!treeElement) 180 if (!treeElement)
181 return false; 181 return false;
182 return treeElement._editing || false; 182 return treeElement._editing || false;
183 }, 183 },
184 184
185 update: function() 185 update: function()
186 { 186 {
187 var selectedNode = this.selectedTreeElement ? this.selectedTreeElement.r epresentedObject : null; 187 var selectedNode = this.selectedTreeElement ? this.selectedTreeElement._ node : null;
188 188
189 this.removeChildren(); 189 this.removeChildren();
190 190
191 if (!this.rootDOMNode) 191 if (!this.rootDOMNode)
192 return; 192 return;
193 193
194 var treeElement; 194 var treeElement;
195 if (this._includeRootDOMNode) { 195 if (this._includeRootDOMNode) {
196 treeElement = new WebInspector.ElementsTreeElement(this.rootDOMNode) ; 196 treeElement = new WebInspector.ElementsTreeElement(this.rootDOMNode) ;
197 treeElement.selectable = this._selectEnabled; 197 treeElement.selectable = this._selectEnabled;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 */ 267 */
268 createTreeElementFor: function(node) 268 createTreeElementFor: function(node)
269 { 269 {
270 var treeElement = this.findTreeElement(node); 270 var treeElement = this.findTreeElement(node);
271 if (treeElement) 271 if (treeElement)
272 return treeElement; 272 return treeElement;
273 if (!node.parentNode) 273 if (!node.parentNode)
274 return null; 274 return null;
275 275
276 treeElement = this.createTreeElementFor(node.parentNode); 276 treeElement = this.createTreeElementFor(node.parentNode);
277 if (treeElement && treeElement.showChild(node.index)) 277 return treeElement ? treeElement._showChild(node) : null;
vsevik 2013/06/07 08:41:00 .index is unused now
278 return treeElement.children[node.index];
279
280 return null;
281 }, 278 },
282 279
283 set suppressRevealAndSelect(x) 280 set suppressRevealAndSelect(x)
284 { 281 {
285 if (this._suppressRevealAndSelect === x) 282 if (this._suppressRevealAndSelect === x)
286 return; 283 return;
287 this._suppressRevealAndSelect = x; 284 this._suppressRevealAndSelect = x;
288 }, 285 },
289 286
290 _revealAndSelectNode: function(node, omitFocus) 287 _revealAndSelectNode: function(node, omitFocus)
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 if (this._previousHoveredElement) { 345 if (this._previousHoveredElement) {
349 this._previousHoveredElement.hovered = false; 346 this._previousHoveredElement.hovered = false;
350 delete this._previousHoveredElement; 347 delete this._previousHoveredElement;
351 } 348 }
352 349
353 if (element) { 350 if (element) {
354 element.hovered = true; 351 element.hovered = true;
355 this._previousHoveredElement = element; 352 this._previousHoveredElement = element;
356 } 353 }
357 354
358 WebInspector.domAgent.highlightDOMNode(element ? element.representedObje ct.id : 0); 355 WebInspector.domAgent.highlightDOMNode(element && element._node ? elemen t._node.id : 0);
359 }, 356 },
360 357
361 _onmouseout: function(event) 358 _onmouseout: function(event)
362 { 359 {
363 var nodeUnderMouse = document.elementFromPoint(event.pageX, event.pageY) ; 360 var nodeUnderMouse = document.elementFromPoint(event.pageX, event.pageY) ;
364 if (nodeUnderMouse && nodeUnderMouse.isDescendant(this.element)) 361 if (nodeUnderMouse && nodeUnderMouse.isDescendant(this.element))
365 return; 362 return;
366 363
367 if (this._previousHoveredElement) { 364 if (this._previousHoveredElement) {
368 this._previousHoveredElement.hovered = false; 365 this._previousHoveredElement.hovered = false;
(...skipping 10 matching lines...) Expand all
379 if (event.target.nodeName === "A") 376 if (event.target.nodeName === "A")
380 return false; 377 return false;
381 378
382 var treeElement = this._treeElementFromEvent(event); 379 var treeElement = this._treeElementFromEvent(event);
383 if (!treeElement) 380 if (!treeElement)
384 return false; 381 return false;
385 382
386 if (!this._isValidDragSourceOrTarget(treeElement)) 383 if (!this._isValidDragSourceOrTarget(treeElement))
387 return false; 384 return false;
388 385
389 if (treeElement.representedObject.nodeName() === "BODY" || treeElement.r epresentedObject.nodeName() === "HEAD") 386 if (treeElement._node.nodeName() === "BODY" || treeElement._node.nodeNam e() === "HEAD")
390 return false; 387 return false;
391 388
392 event.dataTransfer.setData("text/plain", treeElement.listItemElement.tex tContent); 389 event.dataTransfer.setData("text/plain", treeElement.listItemElement.tex tContent);
393 event.dataTransfer.effectAllowed = "copyMove"; 390 event.dataTransfer.effectAllowed = "copyMove";
394 this._treeElementBeingDragged = treeElement; 391 this._treeElementBeingDragged = treeElement;
395 392
396 WebInspector.domAgent.hideDOMNodeHighlight(); 393 WebInspector.domAgent.hideDOMNodeHighlight();
397 394
398 return true; 395 return true;
399 }, 396 },
400 397
401 _ondragover: function(event) 398 _ondragover: function(event)
402 { 399 {
403 if (!this._treeElementBeingDragged) 400 if (!this._treeElementBeingDragged)
404 return false; 401 return false;
405 402
406 var treeElement = this._treeElementFromEvent(event); 403 var treeElement = this._treeElementFromEvent(event);
407 if (!this._isValidDragSourceOrTarget(treeElement)) 404 if (!this._isValidDragSourceOrTarget(treeElement))
408 return false; 405 return false;
409 406
410 var node = treeElement.representedObject; 407 var node = treeElement._node;
411 while (node) { 408 while (node) {
412 if (node === this._treeElementBeingDragged.representedObject) 409 if (node === this._treeElementBeingDragged._node)
413 return false; 410 return false;
414 node = node.parentNode; 411 node = node.parentNode;
415 } 412 }
416 413
417 treeElement.updateSelection(); 414 treeElement.updateSelection();
418 treeElement.listItemElement.addStyleClass("elements-drag-over"); 415 treeElement.listItemElement.addStyleClass("elements-drag-over");
419 this._dragOverTreeElement = treeElement; 416 this._dragOverTreeElement = treeElement;
420 event.preventDefault(); 417 event.preventDefault();
421 event.dataTransfer.dropEffect = 'move'; 418 event.dataTransfer.dropEffect = 'move';
422 return false; 419 return false;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 _doMove: function(treeElement) 452 _doMove: function(treeElement)
456 { 453 {
457 if (!this._treeElementBeingDragged) 454 if (!this._treeElementBeingDragged)
458 return; 455 return;
459 456
460 var parentNode; 457 var parentNode;
461 var anchorNode; 458 var anchorNode;
462 459
463 if (treeElement._elementCloseTag) { 460 if (treeElement._elementCloseTag) {
464 // Drop onto closing tag -> insert as last child. 461 // Drop onto closing tag -> insert as last child.
465 parentNode = treeElement.representedObject; 462 parentNode = treeElement._node;
466 } else { 463 } else {
467 var dragTargetNode = treeElement.representedObject; 464 var dragTargetNode = treeElement._node;
468 parentNode = dragTargetNode.parentNode; 465 parentNode = dragTargetNode.parentNode;
469 anchorNode = dragTargetNode; 466 anchorNode = dragTargetNode;
470 } 467 }
471 468
472 var wasExpanded = this._treeElementBeingDragged.expanded; 469 var wasExpanded = this._treeElementBeingDragged.expanded;
473 this._treeElementBeingDragged.representedObject.moveTo(parentNode, ancho rNode, this._selectNodeAfterEdit.bind(this, null, wasExpanded)); 470 this._treeElementBeingDragged._node.moveTo(parentNode, anchorNode, this. _selectNodeAfterEdit.bind(this, null, wasExpanded));
474 471
475 delete this._treeElementBeingDragged; 472 delete this._treeElementBeingDragged;
476 }, 473 },
477 474
478 _ondragend: function(event) 475 _ondragend: function(event)
479 { 476 {
480 event.preventDefault(); 477 event.preventDefault();
481 this._clearDragOverTreeElementMarker(); 478 this._clearDragOverTreeElementMarker();
482 delete this._treeElementBeingDragged; 479 delete this._treeElementBeingDragged;
483 }, 480 },
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 return; 512 return;
516 513
517 var treeElement = this._treeElementFromEvent(event); 514 var treeElement = this._treeElementFromEvent(event);
518 if (!treeElement) 515 if (!treeElement)
519 return; 516 return;
520 517
521 function focusElement() 518 function focusElement()
522 { 519 {
523 // Force elements module load. 520 // Force elements module load.
524 WebInspector.showPanel("elements"); 521 WebInspector.showPanel("elements");
525 WebInspector.domAgent.inspectElement(treeElement.representedObject.i d); 522 WebInspector.domAgent.inspectElement(treeElement._node.id);
526 } 523 }
527 var contextMenu = new WebInspector.ContextMenu(event); 524 var contextMenu = new WebInspector.ContextMenu(event);
528 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Reveal in Elements panel" : "Reveal in Elements Panel"), focusElem ent.bind(this)); 525 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Reveal in Elements panel" : "Reveal in Elements Panel"), focusElem ent.bind(this));
529 contextMenu.show(); 526 contextMenu.show();
530 }, 527 },
531 528
532 populateContextMenu: function(contextMenu, event) 529 populateContextMenu: function(contextMenu, event)
533 { 530 {
534 var treeElement = this._treeElementFromEvent(event); 531 var treeElement = this._treeElementFromEvent(event);
535 if (!treeElement) 532 if (!treeElement)
536 return; 533 return;
537 534
538 var isTag = treeElement.representedObject.nodeType() === Node.ELEMENT_NO DE; 535 var isTag = treeElement._node.nodeType() === Node.ELEMENT_NODE;
539 var textNode = event.target.enclosingNodeOrSelfWithClass("webkit-html-te xt-node"); 536 var textNode = event.target.enclosingNodeOrSelfWithClass("webkit-html-te xt-node");
540 if (textNode && textNode.hasStyleClass("bogus")) 537 if (textNode && textNode.hasStyleClass("bogus"))
541 textNode = null; 538 textNode = null;
542 var commentNode = event.target.enclosingNodeOrSelfWithClass("webkit-html -comment"); 539 var commentNode = event.target.enclosingNodeOrSelfWithClass("webkit-html -comment");
543 contextMenu.appendApplicableItems(event.target); 540 contextMenu.appendApplicableItems(event.target);
544 if (textNode) { 541 if (textNode) {
545 contextMenu.appendSeparator(); 542 contextMenu.appendSeparator();
546 treeElement._populateTextContextMenu(contextMenu, textNode); 543 treeElement._populateTextContextMenu(contextMenu, textNode);
547 } else if (isTag) { 544 } else if (isTag) {
548 contextMenu.appendSeparator(); 545 contextMenu.appendSeparator();
549 treeElement._populateTagContextMenu(contextMenu, event); 546 treeElement._populateTagContextMenu(contextMenu, event);
550 } else if (commentNode) { 547 } else if (commentNode) {
551 contextMenu.appendSeparator(); 548 contextMenu.appendSeparator();
552 treeElement._populateNodeContextMenu(contextMenu, textNode); 549 treeElement._populateNodeContextMenu(contextMenu, textNode);
553 } 550 }
554 }, 551 },
555 552
556 adjustCollapsedRange: function()
557 {
558 },
559
560 _updateModifiedNodes: function() 553 _updateModifiedNodes: function()
561 { 554 {
562 if (this._elementsTreeUpdater) 555 if (this._elementsTreeUpdater)
563 this._elementsTreeUpdater._updateModifiedNodes(); 556 this._elementsTreeUpdater._updateModifiedNodes();
564 }, 557 },
565 558
566 _populateContextMenu: function(contextMenu, node) 559 _populateContextMenu: function(contextMenu, node)
567 { 560 {
568 if (this._contextMenuCallback) 561 if (this._contextMenuCallback)
569 this._contextMenuCallback(contextMenu, node); 562 this._contextMenuCallback(contextMenu, node);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 __proto__: WebInspector.ElementsTreeOutline.ElementDecorator.prototype 729 __proto__: WebInspector.ElementsTreeOutline.ElementDecorator.prototype
737 } 730 }
738 731
739 /** 732 /**
740 * @constructor 733 * @constructor
741 * @extends {TreeElement} 734 * @extends {TreeElement}
742 * @param {boolean=} elementCloseTag 735 * @param {boolean=} elementCloseTag
743 */ 736 */
744 WebInspector.ElementsTreeElement = function(node, elementCloseTag) 737 WebInspector.ElementsTreeElement = function(node, elementCloseTag)
745 { 738 {
739 // The title will be updated in onattach.
740 TreeElement.call(this, "", node);
741 this._node = node;
742
746 this._elementCloseTag = elementCloseTag; 743 this._elementCloseTag = elementCloseTag;
747 var hasChildrenOverride = !elementCloseTag && node.hasChildNodes() && !this. _showInlineText(node); 744 this._updateHasChildren();
748 745
749 // The title will be updated in onattach. 746 if (this._node.nodeType() == Node.ELEMENT_NODE && !elementCloseTag)
750 TreeElement.call(this, "", node, hasChildrenOverride);
751
752 if (this.representedObject.nodeType() == Node.ELEMENT_NODE && !elementCloseT ag)
753 this._canAddAttributes = true; 747 this._canAddAttributes = true;
754 this._searchQuery = null; 748 this._searchQuery = null;
755 this._expandedChildrenLimit = WebInspector.ElementsTreeElement.InitialChildr enLimit; 749 this._expandedChildrenLimit = WebInspector.ElementsTreeElement.InitialChildr enLimit;
756 } 750 }
757 751
758 WebInspector.ElementsTreeElement.InitialChildrenLimit = 500; 752 WebInspector.ElementsTreeElement.InitialChildrenLimit = 500;
759 753
760 // A union of HTML4 and HTML5-Draft elements that explicitly 754 // A union of HTML4 and HTML5-Draft elements that explicitly
761 // or implicitly (for HTML5) forbid the closing tag. 755 // or implicitly (for HTML5) forbid the closing tag.
762 // FIXME: Revise once HTML5 Final is published. 756 // FIXME: Revise once HTML5 Final is published.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 get expandedChildCount() 863 get expandedChildCount()
870 { 864 {
871 var count = this.children.length; 865 var count = this.children.length;
872 if (count && this.children[count - 1]._elementCloseTag) 866 if (count && this.children[count - 1]._elementCloseTag)
873 count--; 867 count--;
874 if (count && this.children[count - 1].expandAllButton) 868 if (count && this.children[count - 1].expandAllButton)
875 count--; 869 count--;
876 return count; 870 return count;
877 }, 871 },
878 872
879 showChild: function(index) 873 /**
874 * @param {WebInspector.DOMNode} child
875 * @return {?WebInspector.ElementsTreeElement}
876 */
877 _showChild: function(child)
880 { 878 {
881 if (this._elementCloseTag) 879 if (this._elementCloseTag)
882 return; 880 return null;
881
882 var index = this._visibleChildren().indexOf(child);
883 if (index == -1)
apavlov 2013/06/06 16:18:59 ===
pfeldman 2013/06/07 08:53:49 Done.
884 return null;
883 885
884 if (index >= this.expandedChildrenLimit) { 886 if (index >= this.expandedChildrenLimit) {
885 this._expandedChildrenLimit = index + 1; 887 this._expandedChildrenLimit = index + 1;
886 this._updateChildren(true); 888 this._updateChildren(true);
887 } 889 }
888 890
889 // Whether index-th child is visible in the children tree 891 // Whether index-th child is visible in the children tree
890 return this.expandedChildCount > index; 892 return this.expandedChildCount > index ? this.children[index] : null;
891 }, 893 },
892 894
893 updateSelection: function() 895 updateSelection: function()
894 { 896 {
895 var listItemElement = this.listItemElement; 897 var listItemElement = this.listItemElement;
896 if (!listItemElement) 898 if (!listItemElement)
897 return; 899 return;
898 900
899 if (!this._readyToUpdateSelection) { 901 if (!this._readyToUpdateSelection) {
900 if (document.body.offsetWidth > 0) 902 if (document.body.offsetWidth > 0)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 var links = this.listItemElement.querySelectorAll("li > .webkit-html-tag > .webkit-html-attribute > .webkit-html-external-link, li > .webkit-html-tag > .webkit-html-attribute > .webkit-html-resource-link"); 934 var links = this.listItemElement.querySelectorAll("li > .webkit-html-tag > .webkit-html-attribute > .webkit-html-external-link, li > .webkit-html-tag > .webkit-html-attribute > .webkit-html-resource-link");
933 if (!links) 935 if (!links)
934 return; 936 return;
935 937
936 for (var i = 0; i < links.length; ++i) 938 for (var i = 0; i < links.length; ++i)
937 links[i].preventFollowOnDoubleClick = true; 939 links[i].preventFollowOnDoubleClick = true;
938 }, 940 },
939 941
940 onpopulate: function() 942 onpopulate: function()
941 { 943 {
942 if (this.children.length || this._showInlineText(this.representedObject) || this._elementCloseTag) 944 if (this.children.length || this._showInlineText() || this._elementClose Tag)
943 return; 945 return;
944 946
945 this.updateChildren(); 947 this.updateChildren();
946 }, 948 },
947 949
948 /** 950 /**
949 * @param {boolean=} fullRefresh 951 * @param {boolean=} fullRefresh
950 */ 952 */
951 updateChildren: function(fullRefresh) 953 updateChildren: function(fullRefresh)
952 { 954 {
953 if (this._elementCloseTag) 955 if (this._elementCloseTag)
954 return; 956 return;
955 this.representedObject.getChildNodes(this._updateChildren.bind(this, ful lRefresh)); 957 this._node.getChildNodes(this._updateChildren.bind(this, fullRefresh));
956 }, 958 },
957 959
958 /** 960 /**
959 * @param {boolean=} closingTag 961 * @param {boolean=} closingTag
960 */ 962 */
961 insertChildElement: function(child, index, closingTag) 963 insertChildElement: function(child, index, closingTag)
962 { 964 {
963 var newElement = new WebInspector.ElementsTreeElement(child, closingTag) ; 965 var newElement = new WebInspector.ElementsTreeElement(child, closingTag) ;
964 newElement.selectable = this.treeOutline._selectEnabled; 966 newElement.selectable = this.treeOutline._selectEnabled;
965 this.insertChild(newElement, index); 967 this.insertChild(newElement, index);
(...skipping 26 matching lines...) Expand all
992 var selectedTreeElement = this.treeOutline.selectedTreeElement; 994 var selectedTreeElement = this.treeOutline.selectedTreeElement;
993 if (selectedTreeElement && selectedTreeElement.hasAncestor(this)) 995 if (selectedTreeElement && selectedTreeElement.hasAncestor(this))
994 this.select(); 996 this.select();
995 this.removeChildren(); 997 this.removeChildren();
996 } 998 }
997 999
998 var treeElement = this; 1000 var treeElement = this;
999 var treeChildIndex = 0; 1001 var treeChildIndex = 0;
1000 var elementToSelect; 1002 var elementToSelect;
1001 1003
1002 function updateChildrenOfNode(node) 1004 function updateChildrenOfNode()
1003 { 1005 {
1004 var treeOutline = treeElement.treeOutline; 1006 var treeOutline = treeElement.treeOutline;
1005 var child = node.firstChild; 1007 var visibleChildren = this._visibleChildren();
vsevik 2013/06/07 08:41:00 unused now
pfeldman 2013/06/07 08:53:49 Still is, sorry
1006 while (child) { 1008
1009 for (var i = 0; i < visibleChildren.length; ++i) {
1010 var child = visibleChildren[i];
1007 var currentTreeElement = treeElement.children[treeChildIndex]; 1011 var currentTreeElement = treeElement.children[treeChildIndex];
1008 if (!currentTreeElement || currentTreeElement.representedObject !== child) { 1012 if (!currentTreeElement || currentTreeElement._node !== child) {
1009 // Find any existing element that is later in the children l ist. 1013 // Find any existing element that is later in the children l ist.
1010 var existingTreeElement = null; 1014 var existingTreeElement = null;
1011 for (var i = (treeChildIndex + 1), size = treeElement.expand edChildCount; i < size; ++i) { 1015 for (var j = (treeChildIndex + 1), size = treeElement.expand edChildCount; j < size; ++j) {
1012 if (treeElement.children[i].representedObject === child) { 1016 if (treeElement.children[j]._node === child) {
1013 existingTreeElement = treeElement.children[i]; 1017 existingTreeElement = treeElement.children[j];
1014 break; 1018 break;
1015 } 1019 }
1016 } 1020 }
1017 1021
1018 if (existingTreeElement && existingTreeElement.parent === tr eeElement) { 1022 if (existingTreeElement && existingTreeElement.parent === tr eeElement) {
1019 // If an existing element was found and it has the same parent, just move it. 1023 // If an existing element was found and it has the same parent, just move it.
1020 treeElement.moveChild(existingTreeElement, treeChildInde x); 1024 treeElement.moveChild(existingTreeElement, treeChildInde x);
1021 } else { 1025 } else {
1022 // No existing element found, insert a new element. 1026 // No existing element found, insert a new element.
1023 if (treeChildIndex < treeElement.expandedChildrenLimit) { 1027 if (treeChildIndex < treeElement.expandedChildrenLimit) {
1024 var newElement = treeElement.insertChildElement(chil d, treeChildIndex); 1028 var newElement = treeElement.insertChildElement(chil d, treeChildIndex);
1025 if (child === selectedNode) 1029 if (child === selectedNode)
1026 elementToSelect = newElement; 1030 elementToSelect = newElement;
1027 if (treeElement.expandedChildCount > treeElement.exp andedChildrenLimit) 1031 if (treeElement.expandedChildCount > treeElement.exp andedChildrenLimit)
1028 treeElement.expandedChildrenLimit++; 1032 treeElement.expandedChildrenLimit++;
1029 } 1033 }
1030 } 1034 }
1031 } 1035 }
1032 1036
1033 child = child.nextSibling;
vsevik 2013/06/07 08:41:00 unused now
1034 ++treeChildIndex; 1037 ++treeChildIndex;
1035 } 1038 }
1036 } 1039 }
1037 1040
1038 // Remove any tree elements that no longer have this node (or this node' s contentDocument) as their parent. 1041 // Remove any tree elements that no longer have this node (or this node' s contentDocument) as their parent.
1039 for (var i = (this.children.length - 1); i >= 0; --i) { 1042 for (var i = (this.children.length - 1); i >= 0; --i) {
1040 var currentChild = this.children[i]; 1043 var currentChild = this.children[i];
1041 var currentNode = currentChild.representedObject; 1044 var currentNode = currentChild._node;
1045 if (!currentNode)
1046 continue;
1042 var currentParentNode = currentNode.parentNode; 1047 var currentParentNode = currentNode.parentNode;
1043 1048
1044 if (currentParentNode === this.representedObject) 1049 if (currentParentNode === this._node)
1045 continue; 1050 continue;
1046 1051
1047 var selectedTreeElement = this.treeOutline.selectedTreeElement; 1052 var selectedTreeElement = this.treeOutline.selectedTreeElement;
1048 if (selectedTreeElement && (selectedTreeElement === currentChild || selectedTreeElement.hasAncestor(currentChild))) 1053 if (selectedTreeElement && (selectedTreeElement === currentChild || selectedTreeElement.hasAncestor(currentChild)))
1049 this.select(); 1054 this.select();
1050 1055
1051 this.removeChildAtIndex(i); 1056 this.removeChildAtIndex(i);
1052 } 1057 }
1053 1058
1054 updateChildrenOfNode(this.representedObject); 1059 updateChildrenOfNode.call(this);
1055 this.adjustCollapsedRange(); 1060 this._adjustCollapsedRange();
1056 1061
1057 var lastChild = this.children[this.children.length - 1]; 1062 var lastChild = this.children[this.children.length - 1];
1058 if (this.representedObject.nodeType() == Node.ELEMENT_NODE && (!lastChil d || !lastChild._elementCloseTag)) 1063 if (this._node.nodeType() == Node.ELEMENT_NODE && (!lastChild || !lastCh ild._elementCloseTag))
1059 this.insertChildElement(this.representedObject, this.children.length , true); 1064 this.insertChildElement(this._node, this.children.length, true);
1060 1065
1061 // We want to restore the original selection and tree scroll position af ter a full refresh, if possible. 1066 // We want to restore the original selection and tree scroll position af ter a full refresh, if possible.
1062 if (fullRefresh && elementToSelect) { 1067 if (fullRefresh && elementToSelect) {
1063 elementToSelect.select(); 1068 elementToSelect.select();
1064 if (treeOutlineContainerElement && originalScrollTop <= treeOutlineC ontainerElement.scrollHeight) 1069 if (treeOutlineContainerElement && originalScrollTop <= treeOutlineC ontainerElement.scrollHeight)
1065 treeOutlineContainerElement.scrollTop = originalScrollTop; 1070 treeOutlineContainerElement.scrollTop = originalScrollTop;
1066 } 1071 }
1067 1072
1068 delete this._updateChildrenInProgress; 1073 delete this._updateChildrenInProgress;
1069 }, 1074 },
1070 1075
1071 adjustCollapsedRange: function() 1076 _adjustCollapsedRange: function()
1072 { 1077 {
1078 var visibleChildren = this._visibleChildren();
1073 // Ensure precondition: only the tree elements for node children are fou nd in the tree 1079 // Ensure precondition: only the tree elements for node children are fou nd in the tree
1074 // (not the Expand All button or the closing tag). 1080 // (not the Expand All button or the closing tag).
1075 if (this.expandAllButtonElement && this.expandAllButtonElement.__treeEle ment.parent) 1081 if (this.expandAllButtonElement && this.expandAllButtonElement.__treeEle ment.parent)
1076 this.removeChild(this.expandAllButtonElement.__treeElement); 1082 this.removeChild(this.expandAllButtonElement.__treeElement);
1077 1083
1078 const node = this.representedObject; 1084 const childNodeCount = visibleChildren.length;
1079 if (!node.children)
1080 return;
1081 const childNodeCount = node.children.length;
1082 1085
1083 // In case some nodes from the expanded range were removed, pull some no des from the collapsed range into the expanded range at the bottom. 1086 // In case some nodes from the expanded range were removed, pull some no des from the collapsed range into the expanded range at the bottom.
1084 for (var i = this.expandedChildCount, limit = Math.min(this.expandedChil drenLimit, childNodeCount); i < limit; ++i) 1087 for (var i = this.expandedChildCount, limit = Math.min(this.expandedChil drenLimit, childNodeCount); i < limit; ++i)
1085 this.insertChildElement(node.children[i], i); 1088 this.insertChildElement(visibleChildren[i], i);
1086 1089
1087 const expandedChildCount = this.expandedChildCount; 1090 const expandedChildCount = this.expandedChildCount;
1088 if (childNodeCount > this.expandedChildCount) { 1091 if (childNodeCount > this.expandedChildCount) {
1089 var targetButtonIndex = expandedChildCount; 1092 var targetButtonIndex = expandedChildCount;
1090 if (!this.expandAllButtonElement) { 1093 if (!this.expandAllButtonElement) {
1091 var button = document.createElement("button"); 1094 var button = document.createElement("button");
1092 button.className = "show-all-nodes"; 1095 button.className = "show-all-nodes";
1093 button.value = ""; 1096 button.value = "";
1094 var item = new TreeElement(button, null, false); 1097 var item = new TreeElement(button, null, false);
1095 item.selectable = false; 1098 item.selectable = false;
1096 item.expandAllButton = true; 1099 item.expandAllButton = true;
1097 this.insertChild(item, targetButtonIndex); 1100 this.insertChild(item, targetButtonIndex);
1098 this.expandAllButtonElement = item.listItemElement.firstChild; 1101 this.expandAllButtonElement = item.listItemElement.firstChild;
1099 this.expandAllButtonElement.__treeElement = item; 1102 this.expandAllButtonElement.__treeElement = item;
1100 this.expandAllButtonElement.addEventListener("click", this.handl eLoadAllChildren.bind(this), false); 1103 this.expandAllButtonElement.addEventListener("click", this.handl eLoadAllChildren.bind(this), false);
1101 } else if (!this.expandAllButtonElement.__treeElement.parent) 1104 } else if (!this.expandAllButtonElement.__treeElement.parent)
1102 this.insertChild(this.expandAllButtonElement.__treeElement, targ etButtonIndex); 1105 this.insertChild(this.expandAllButtonElement.__treeElement, targ etButtonIndex);
1103 this.expandAllButtonElement.textContent = WebInspector.UIString("Sho w All Nodes (%d More)", childNodeCount - expandedChildCount); 1106 this.expandAllButtonElement.textContent = WebInspector.UIString("Sho w All Nodes (%d More)", childNodeCount - expandedChildCount);
1104 } else if (this.expandAllButtonElement) 1107 } else if (this.expandAllButtonElement)
1105 delete this.expandAllButtonElement; 1108 delete this.expandAllButtonElement;
1106 }, 1109 },
1107 1110
1108 handleLoadAllChildren: function() 1111 handleLoadAllChildren: function()
1109 { 1112 {
1110 this.expandedChildrenLimit = Math.max(this.representedObject._childNodeC ount, this.expandedChildrenLimit + WebInspector.ElementsTreeElement.InitialChild renLimit); 1113 this.expandedChildrenLimit = Math.max(this._visibleChildCount(), this.ex pandedChildrenLimit + WebInspector.ElementsTreeElement.InitialChildrenLimit);
1111 }, 1114 },
1112 1115
1113 expandRecursively: function() 1116 expandRecursively: function()
1114 { 1117 {
1115 function callback() 1118 function callback()
1116 { 1119 {
1117 TreeElement.prototype.expandRecursively.call(this, Number.MAX_VALUE) ; 1120 TreeElement.prototype.expandRecursively.call(this, Number.MAX_VALUE) ;
1118 } 1121 }
1119 1122
1120 this.representedObject.getSubtree(-1, callback.bind(this)); 1123 this._node.getSubtree(-1, callback.bind(this));
1121 }, 1124 },
1122 1125
1123 onexpand: function() 1126 onexpand: function()
1124 { 1127 {
1125 if (this._elementCloseTag) 1128 if (this._elementCloseTag)
1126 return; 1129 return;
1127 1130
1128 this.updateTitle(); 1131 this.updateTitle();
1129 this.treeOutline.updateSelection(); 1132 this.treeOutline.updateSelection();
1130 }, 1133 },
(...skipping 14 matching lines...) Expand all
1145 if (tagSpans.length) 1148 if (tagSpans.length)
1146 tagSpans[0].scrollIntoViewIfNeeded(false); 1149 tagSpans[0].scrollIntoViewIfNeeded(false);
1147 else 1150 else
1148 this.listItemElement.scrollIntoViewIfNeeded(false); 1151 this.listItemElement.scrollIntoViewIfNeeded(false);
1149 } 1152 }
1150 }, 1153 },
1151 1154
1152 onselect: function(selectedByUser) 1155 onselect: function(selectedByUser)
1153 { 1156 {
1154 this.treeOutline.suppressRevealAndSelect = true; 1157 this.treeOutline.suppressRevealAndSelect = true;
1155 this.treeOutline.selectDOMNode(this.representedObject, selectedByUser); 1158 this.treeOutline.selectDOMNode(this._node, selectedByUser);
1156 if (selectedByUser) 1159 if (selectedByUser)
1157 WebInspector.domAgent.highlightDOMNode(this.representedObject.id); 1160 WebInspector.domAgent.highlightDOMNode(this._node.id);
1158 this.updateSelection(); 1161 this.updateSelection();
1159 this.treeOutline.suppressRevealAndSelect = false; 1162 this.treeOutline.suppressRevealAndSelect = false;
1160 return true; 1163 return true;
1161 }, 1164 },
1162 1165
1163 ondelete: function() 1166 ondelete: function()
1164 { 1167 {
1165 var startTagTreeElement = this.treeOutline.findTreeElement(this.represen tedObject); 1168 var startTagTreeElement = this.treeOutline.findTreeElement(this._node);
1166 startTagTreeElement ? startTagTreeElement.remove() : this.remove(); 1169 startTagTreeElement ? startTagTreeElement.remove() : this.remove();
1167 return true; 1170 return true;
1168 }, 1171 },
1169 1172
1170 onenter: function() 1173 onenter: function()
1171 { 1174 {
1172 // On Enter or Return start editing the first attribute 1175 // On Enter or Return start editing the first attribute
1173 // or create a new attribute on the selected element. 1176 // or create a new attribute on the selected element.
1174 if (this._editing) 1177 if (this._editing)
1175 return false; 1178 return false;
1176 1179
1177 this._startEditing(); 1180 this._startEditing();
1178 1181
1179 // prevent a newline from being immediately inserted 1182 // prevent a newline from being immediately inserted
1180 return true; 1183 return true;
1181 }, 1184 },
1182 1185
1183 selectOnMouseDown: function(event) 1186 selectOnMouseDown: function(event)
1184 { 1187 {
1185 TreeElement.prototype.selectOnMouseDown.call(this, event); 1188 TreeElement.prototype.selectOnMouseDown.call(this, event);
1186 1189
1187 if (this._editing) 1190 if (this._editing)
1188 return; 1191 return;
1189 1192
1190 if (this.treeOutline._showInElementsPanelEnabled) { 1193 if (this.treeOutline._showInElementsPanelEnabled) {
1191 WebInspector.showPanel("elements"); 1194 WebInspector.showPanel("elements");
1192 this.treeOutline.selectDOMNode(this.representedObject, true); 1195 this.treeOutline.selectDOMNode(this._node, true);
1193 } 1196 }
1194 1197
1195 // Prevent selecting the nearest word on double click. 1198 // Prevent selecting the nearest word on double click.
1196 if (event.detail >= 2) 1199 if (event.detail >= 2)
1197 event.preventDefault(); 1200 event.preventDefault();
1198 }, 1201 },
1199 1202
1200 ondblclick: function(event) 1203 ondblclick: function(event)
1201 { 1204 {
1202 if (this._editing || this._elementCloseTag) 1205 if (this._editing || this._elementCloseTag)
(...skipping 16 matching lines...) Expand all
1219 tag.appendChild(document.createTextNode('<'+nodeName)); 1222 tag.appendChild(document.createTextNode('<'+nodeName));
1220 tag.appendChild(node); 1223 tag.appendChild(node);
1221 tag.appendChild(document.createTextNode('>')); 1224 tag.appendChild(document.createTextNode('>'));
1222 } 1225 }
1223 1226
1224 this.updateSelection(); 1227 this.updateSelection();
1225 }, 1228 },
1226 1229
1227 _startEditingTarget: function(eventTarget) 1230 _startEditingTarget: function(eventTarget)
1228 { 1231 {
1229 if (this.treeOutline.selectedDOMNode() != this.representedObject) 1232 if (this.treeOutline.selectedDOMNode() != this._node)
1230 return; 1233 return;
1231 1234
1232 if (this.representedObject.nodeType() != Node.ELEMENT_NODE && this.repre sentedObject.nodeType() != Node.TEXT_NODE) 1235 if (this._node.nodeType() != Node.ELEMENT_NODE && this._node.nodeType() != Node.TEXT_NODE)
1233 return false; 1236 return false;
1234 1237
1235 var textNode = eventTarget.enclosingNodeOrSelfWithClass("webkit-html-tex t-node"); 1238 var textNode = eventTarget.enclosingNodeOrSelfWithClass("webkit-html-tex t-node");
1236 if (textNode) 1239 if (textNode)
1237 return this._startEditingTextNode(textNode); 1240 return this._startEditingTextNode(textNode);
1238 1241
1239 var attribute = eventTarget.enclosingNodeOrSelfWithClass("webkit-html-at tribute"); 1242 var attribute = eventTarget.enclosingNodeOrSelfWithClass("webkit-html-at tribute");
1240 if (attribute) 1243 if (attribute)
1241 return this._startEditingAttribute(attribute, eventTarget); 1244 return this._startEditingAttribute(attribute, eventTarget);
1242 1245
1243 var tagName = eventTarget.enclosingNodeOrSelfWithClass("webkit-html-tag- name"); 1246 var tagName = eventTarget.enclosingNodeOrSelfWithClass("webkit-html-tag- name");
1244 if (tagName) 1247 if (tagName)
1245 return this._startEditingTagName(tagName); 1248 return this._startEditingTagName(tagName);
1246 1249
1247 var newAttribute = eventTarget.enclosingNodeOrSelfWithClass("add-attribu te"); 1250 var newAttribute = eventTarget.enclosingNodeOrSelfWithClass("add-attribu te");
1248 if (newAttribute) 1251 if (newAttribute)
1249 return this._addNewAttribute(); 1252 return this._addNewAttribute();
1250 1253
1251 return false; 1254 return false;
1252 }, 1255 },
1253 1256
1254 _populateTagContextMenu: function(contextMenu, event) 1257 _populateTagContextMenu: function(contextMenu, event)
1255 { 1258 {
1256 var attribute = event.target.enclosingNodeOrSelfWithClass("webkit-html-a ttribute"); 1259 var attribute = event.target.enclosingNodeOrSelfWithClass("webkit-html-a ttribute");
1257 var newAttribute = event.target.enclosingNodeOrSelfWithClass("add-attrib ute"); 1260 var newAttribute = event.target.enclosingNodeOrSelfWithClass("add-attrib ute");
1258 1261
1259 // Add attribute-related actions. 1262 // Add attribute-related actions.
1260 var treeElement = this._elementCloseTag ? this.treeOutline.findTreeEleme nt(this.representedObject) : this; 1263 var treeElement = this._elementCloseTag ? this.treeOutline.findTreeEleme nt(this._node) : this;
1261 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Add attribute" : "Add Attribute"), this._addNewAttribute.bind(tree Element)); 1264 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Add attribute" : "Add Attribute"), this._addNewAttribute.bind(tree Element));
1262 if (attribute && !newAttribute) 1265 if (attribute && !newAttribute)
1263 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCa seMenuTitles() ? "Edit attribute" : "Edit Attribute"), this._startEditingAttribu te.bind(this, attribute, event.target)); 1266 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCa seMenuTitles() ? "Edit attribute" : "Edit Attribute"), this._startEditingAttribu te.bind(this, attribute, event.target));
1264 contextMenu.appendSeparator(); 1267 contextMenu.appendSeparator();
1265 if (this.treeOutline._setPseudoClassCallback) { 1268 if (this.treeOutline._setPseudoClassCallback) {
1266 var pseudoSubMenu = contextMenu.appendSubMenuItem(WebInspector.UIStr ing(WebInspector.useLowerCaseMenuTitles() ? "Force element state" : "Force Eleme nt State")); 1269 var pseudoSubMenu = contextMenu.appendSubMenuItem(WebInspector.UIStr ing(WebInspector.useLowerCaseMenuTitles() ? "Force element state" : "Force Eleme nt State"));
1267 this._populateForcedPseudoStateItems(pseudoSubMenu); 1270 this._populateForcedPseudoStateItems(pseudoSubMenu);
1268 contextMenu.appendSeparator(); 1271 contextMenu.appendSeparator();
1269 } 1272 }
1270 1273
1271 this._populateNodeContextMenu(contextMenu); 1274 this._populateNodeContextMenu(contextMenu);
1272 this.treeOutline._populateContextMenu(contextMenu, this.representedObjec t); 1275 this.treeOutline._populateContextMenu(contextMenu, this._node);
1273 1276
1274 contextMenu.appendSeparator(); 1277 contextMenu.appendSeparator();
1275 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Scroll into view" : "Scroll into View"), this._scrollIntoView.bind (this)); 1278 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Scroll into view" : "Scroll into View"), this._scrollIntoView.bind (this));
1276 }, 1279 },
1277 1280
1278 _populateForcedPseudoStateItems: function(subMenu) 1281 _populateForcedPseudoStateItems: function(subMenu)
1279 { 1282 {
1280 const pseudoClasses = ["active", "hover", "focus", "visited"]; 1283 const pseudoClasses = ["active", "hover", "focus", "visited"];
1281 var node = this.representedObject; 1284 var node = this._node;
1282 var forcedPseudoState = (node ? node.getUserProperty("pseudoState") : nu ll) || []; 1285 var forcedPseudoState = (node ? node.getUserProperty("pseudoState") : nu ll) || [];
1283 for (var i = 0; i < pseudoClasses.length; ++i) { 1286 for (var i = 0; i < pseudoClasses.length; ++i) {
1284 var pseudoClassForced = forcedPseudoState.indexOf(pseudoClasses[i]) >= 0; 1287 var pseudoClassForced = forcedPseudoState.indexOf(pseudoClasses[i]) >= 0;
1285 subMenu.appendCheckboxItem(":" + pseudoClasses[i], this.treeOutline. _setPseudoClassCallback.bind(null, node.id, pseudoClasses[i], !pseudoClassForced ), pseudoClassForced, false); 1288 subMenu.appendCheckboxItem(":" + pseudoClasses[i], this.treeOutline. _setPseudoClassCallback.bind(null, node.id, pseudoClasses[i], !pseudoClassForced ), pseudoClassForced, false);
1286 } 1289 }
1287 }, 1290 },
1288 1291
1289 _populateTextContextMenu: function(contextMenu, textNode) 1292 _populateTextContextMenu: function(contextMenu, textNode)
1290 { 1293 {
1291 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Edit text" : "Edit Text"), this._startEditingTextNode.bind(this, t extNode)); 1294 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Edit text" : "Edit Text"), this._startEditingTextNode.bind(this, t extNode));
1292 this._populateNodeContextMenu(contextMenu); 1295 this._populateNodeContextMenu(contextMenu);
1293 }, 1296 },
1294 1297
1295 _populateNodeContextMenu: function(contextMenu) 1298 _populateNodeContextMenu: function(contextMenu)
1296 { 1299 {
1297 // Add free-form node-related actions. 1300 // Add free-form node-related actions.
1298 contextMenu.appendItem(WebInspector.UIString("Edit as HTML"), this._edit AsHTML.bind(this)); 1301 contextMenu.appendItem(WebInspector.UIString("Edit as HTML"), this._edit AsHTML.bind(this));
1299 contextMenu.appendItem(WebInspector.UIString("Copy as HTML"), this._copy HTML.bind(this)); 1302 contextMenu.appendItem(WebInspector.UIString("Copy as HTML"), this._copy HTML.bind(this));
1300 contextMenu.appendItem(WebInspector.UIString("Copy XPath"), this._copyXP ath.bind(this)); 1303 contextMenu.appendItem(WebInspector.UIString("Copy XPath"), this._copyXP ath.bind(this));
1301 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Delete node" : "Delete Node"), this.remove.bind(this)); 1304 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Delete node" : "Delete Node"), this.remove.bind(this));
1302 }, 1305 },
1303 1306
1304 _startEditing: function() 1307 _startEditing: function()
1305 { 1308 {
1306 if (this.treeOutline.selectedDOMNode() !== this.representedObject) 1309 if (this.treeOutline.selectedDOMNode() !== this._node)
1307 return; 1310 return;
1308 1311
1309 var listItem = this._listItemNode; 1312 var listItem = this._listItemNode;
1310 1313
1311 if (this._canAddAttributes) { 1314 if (this._canAddAttributes) {
1312 var attribute = listItem.getElementsByClassName("webkit-html-attribu te")[0]; 1315 var attribute = listItem.getElementsByClassName("webkit-html-attribu te")[0];
1313 if (attribute) 1316 if (attribute)
1314 return this._startEditingAttribute(attribute, attribute.getEleme ntsByClassName("webkit-html-attribute-value")[0]); 1317 return this._startEditingAttribute(attribute, attribute.getEleme ntsByClassName("webkit-html-attribute-value")[0]);
1315 1318
1316 return this._addNewAttribute(); 1319 return this._addNewAttribute();
1317 } 1320 }
1318 1321
1319 if (this.representedObject.nodeType() === Node.TEXT_NODE) { 1322 if (this._node.nodeType() === Node.TEXT_NODE) {
1320 var textNode = listItem.getElementsByClassName("webkit-html-text-nod e")[0]; 1323 var textNode = listItem.getElementsByClassName("webkit-html-text-nod e")[0];
1321 if (textNode) 1324 if (textNode)
1322 return this._startEditingTextNode(textNode); 1325 return this._startEditingTextNode(textNode);
1323 return; 1326 return;
1324 } 1327 }
1325 }, 1328 },
1326 1329
1327 _addNewAttribute: function() 1330 _addNewAttribute: function()
1328 { 1331 {
1329 // Cannot just convert the textual html into an element without 1332 // Cannot just convert the textual html into an element without
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 }, 1416 },
1414 1417
1415 /** 1418 /**
1416 * @param {Element} textNodeElement 1419 * @param {Element} textNodeElement
1417 */ 1420 */
1418 _startEditingTextNode: function(textNodeElement) 1421 _startEditingTextNode: function(textNodeElement)
1419 { 1422 {
1420 if (WebInspector.isBeingEdited(textNodeElement)) 1423 if (WebInspector.isBeingEdited(textNodeElement))
1421 return true; 1424 return true;
1422 1425
1423 var textNode = this.representedObject; 1426 var textNode = this._node;
1424 // We only show text nodes inline in elements if the element only 1427 // We only show text nodes inline in elements if the element only
1425 // has a single child, and that child is a text node. 1428 // has a single child, and that child is a text node.
1426 if (textNode.nodeType() === Node.ELEMENT_NODE && textNode.firstChild) 1429 if (textNode.nodeType() === Node.ELEMENT_NODE && textNode.firstChild)
1427 textNode = textNode.firstChild; 1430 textNode = textNode.firstChild;
1428 1431
1429 var container = textNodeElement.enclosingNodeOrSelfWithClass("webkit-htm l-text-node"); 1432 var container = textNodeElement.enclosingNodeOrSelfWithClass("webkit-htm l-text-node");
1430 if (container) 1433 if (container)
1431 container.textContent = textNode.nodeValue(); // Strip the CSS or JS highlighting if present. 1434 container.textContent = textNode.nodeValue(); // Strip the CSS or JS highlighting if present.
1432 var config = new WebInspector.EditingConfig(this._textNodeEditingCommitt ed.bind(this, textNode), this._editingCancelled.bind(this)); 1435 var config = new WebInspector.EditingConfig(this._textNodeEditingCommitt ed.bind(this, textNode), this._editingCancelled.bind(this));
1433 this._editing = WebInspector.startEditing(textNodeElement, config); 1436 this._editing = WebInspector.startEditing(textNodeElement, config);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1563 { 1566 {
1564 if (error) 1567 if (error)
1565 this._editingCancelled(element, attributeName); 1568 this._editingCancelled(element, attributeName);
1566 1569
1567 if (!moveDirection) 1570 if (!moveDirection)
1568 return; 1571 return;
1569 1572
1570 treeOutline._updateModifiedNodes(); 1573 treeOutline._updateModifiedNodes();
1571 1574
1572 // Search for the attribute's position, and then decide where to mov e to. 1575 // Search for the attribute's position, and then decide where to mov e to.
1573 var attributes = this.representedObject.attributes(); 1576 var attributes = this._node.attributes();
1574 for (var i = 0; i < attributes.length; ++i) { 1577 for (var i = 0; i < attributes.length; ++i) {
1575 if (attributes[i].name !== attributeName) 1578 if (attributes[i].name !== attributeName)
1576 continue; 1579 continue;
1577 1580
1578 if (moveDirection === "backward") { 1581 if (moveDirection === "backward") {
1579 if (i === 0) 1582 if (i === 0)
1580 this._startEditingTagName(); 1583 this._startEditingTagName();
1581 else 1584 else
1582 this._triggerEditAttribute(attributes[i - 1].name); 1585 this._triggerEditAttribute(attributes[i - 1].name);
1583 } else { 1586 } else {
(...skipping 24 matching lines...) Expand all
1608 } 1611 }
1609 } 1612 }
1610 1613
1611 if (!attributeName.trim() && !newText.trim()) { 1614 if (!attributeName.trim() && !newText.trim()) {
1612 element.removeSelf(); 1615 element.removeSelf();
1613 moveToNextAttributeIfNeeded.call(this); 1616 moveToNextAttributeIfNeeded.call(this);
1614 return; 1617 return;
1615 } 1618 }
1616 1619
1617 if (oldText !== newText) { 1620 if (oldText !== newText) {
1618 this.representedObject.setAttribute(attributeName, newText, moveToNe xtAttributeIfNeeded.bind(this)); 1621 this._node.setAttribute(attributeName, newText, moveToNextAttributeI fNeeded.bind(this));
1619 return; 1622 return;
1620 } 1623 }
1621 1624
1622 moveToNextAttributeIfNeeded.call(this); 1625 moveToNextAttributeIfNeeded.call(this);
1623 }, 1626 },
1624 1627
1625 _tagNameEditingCommitted: function(element, newText, oldText, tagName, moveD irection) 1628 _tagNameEditingCommitted: function(element, newText, oldText, tagName, moveD irection)
1626 { 1629 {
1627 delete this._editing; 1630 delete this._editing;
1628 var self = this; 1631 var self = this;
1629 1632
1630 function cancel() 1633 function cancel()
1631 { 1634 {
1632 var closingTagElement = self._distinctClosingTagElement(); 1635 var closingTagElement = self._distinctClosingTagElement();
1633 if (closingTagElement) 1636 if (closingTagElement)
1634 closingTagElement.textContent = "</" + tagName + ">"; 1637 closingTagElement.textContent = "</" + tagName + ">";
1635 1638
1636 self._editingCancelled(element, tagName); 1639 self._editingCancelled(element, tagName);
1637 moveToNextAttributeIfNeeded.call(self); 1640 moveToNextAttributeIfNeeded.call(self);
1638 } 1641 }
1639 1642
1640 function moveToNextAttributeIfNeeded() 1643 function moveToNextAttributeIfNeeded()
1641 { 1644 {
1642 if (moveDirection !== "forward") { 1645 if (moveDirection !== "forward") {
1643 this._addNewAttribute(); 1646 this._addNewAttribute();
1644 return; 1647 return;
1645 } 1648 }
1646 1649
1647 var attributes = this.representedObject.attributes(); 1650 var attributes = this._node.attributes();
1648 if (attributes.length > 0) 1651 if (attributes.length > 0)
1649 this._triggerEditAttribute(attributes[0].name); 1652 this._triggerEditAttribute(attributes[0].name);
1650 else 1653 else
1651 this._addNewAttribute(); 1654 this._addNewAttribute();
1652 } 1655 }
1653 1656
1654 newText = newText.trim(); 1657 newText = newText.trim();
1655 if (newText === oldText) { 1658 if (newText === oldText) {
1656 cancel(); 1659 cancel();
1657 return; 1660 return;
1658 } 1661 }
1659 1662
1660 var treeOutline = this.treeOutline; 1663 var treeOutline = this.treeOutline;
1661 var wasExpanded = this.expanded; 1664 var wasExpanded = this.expanded;
1662 1665
1663 function changeTagNameCallback(error, nodeId) 1666 function changeTagNameCallback(error, nodeId)
1664 { 1667 {
1665 if (error || !nodeId) { 1668 if (error || !nodeId) {
1666 cancel(); 1669 cancel();
1667 return; 1670 return;
1668 } 1671 }
1669 var newTreeItem = treeOutline._selectNodeAfterEdit(null, wasExpanded , error, nodeId); 1672 var newTreeItem = treeOutline._selectNodeAfterEdit(null, wasExpanded , error, nodeId);
1670 moveToNextAttributeIfNeeded.call(newTreeItem); 1673 moveToNextAttributeIfNeeded.call(newTreeItem);
1671 } 1674 }
1672 1675
1673 this.representedObject.setNodeName(newText, changeTagNameCallback); 1676 this._node.setNodeName(newText, changeTagNameCallback);
1674 }, 1677 },
1675 1678
1676 /** 1679 /**
1677 * @param {WebInspector.DOMNode} textNode 1680 * @param {WebInspector.DOMNode} textNode
1678 * @param {Element} element 1681 * @param {Element} element
1679 * @param {string} newText 1682 * @param {string} newText
1680 */ 1683 */
1681 _textNodeEditingCommitted: function(textNode, element, newText) 1684 _textNodeEditingCommitted: function(textNode, element, newText)
1682 { 1685 {
1683 delete this._editing; 1686 delete this._editing;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1743 1746
1744 delete this.selectionElement; 1747 delete this.selectionElement;
1745 if (this.selected) 1748 if (this.selected)
1746 this.updateSelection(); 1749 this.updateSelection();
1747 this._preventFollowingLinksOnDoubleClick(); 1750 this._preventFollowingLinksOnDoubleClick();
1748 this._highlightSearchResults(); 1751 this._highlightSearchResults();
1749 }, 1752 },
1750 1753
1751 _createDecoratorElement: function() 1754 _createDecoratorElement: function()
1752 { 1755 {
1753 var node = this.representedObject; 1756 var node = this._node;
1754 var decoratorMessages = []; 1757 var decoratorMessages = [];
1755 var parentDecoratorMessages = []; 1758 var parentDecoratorMessages = [];
1756 for (var i = 0; i < this.treeOutline._nodeDecorators.length; ++i) { 1759 for (var i = 0; i < this.treeOutline._nodeDecorators.length; ++i) {
1757 var decorator = this.treeOutline._nodeDecorators[i]; 1760 var decorator = this.treeOutline._nodeDecorators[i];
1758 var message = decorator.decorate(node); 1761 var message = decorator.decorate(node);
1759 if (message) { 1762 if (message) {
1760 decoratorMessages.push(message); 1763 decoratorMessages.push(message);
1761 continue; 1764 continue;
1762 } 1765 }
1763 1766
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1821 1824
1822 if (hasText) 1825 if (hasText)
1823 attrSpanElement.appendChild(document.createTextNode("\"")); 1826 attrSpanElement.appendChild(document.createTextNode("\""));
1824 }, 1827 },
1825 1828
1826 /** 1829 /**
1827 * @param {function(string, string, string, boolean=, string=)=} linkify 1830 * @param {function(string, string, string, boolean=, string=)=} linkify
1828 */ 1831 */
1829 _buildTagDOM: function(parentElement, tagName, isClosingTag, isDistinctTreeE lement, linkify) 1832 _buildTagDOM: function(parentElement, tagName, isClosingTag, isDistinctTreeE lement, linkify)
1830 { 1833 {
1831 var node = /** @type WebInspector.DOMNode */ (this.representedObject); 1834 var node = this._node;
1832 var classes = [ "webkit-html-tag" ]; 1835 var classes = [ "webkit-html-tag" ];
1833 if (isClosingTag && isDistinctTreeElement) 1836 if (isClosingTag && isDistinctTreeElement)
1834 classes.push("close"); 1837 classes.push("close");
1835 if (node.isInShadowTree()) 1838 if (node.isInShadowTree())
1836 classes.push("shadow"); 1839 classes.push("shadow");
1837 var tagElement = parentElement.createChild("span", classes.join(" ")); 1840 var tagElement = parentElement.createChild("span", classes.join(" "));
1838 tagElement.appendChild(document.createTextNode("<")); 1841 tagElement.appendChild(document.createTextNode("<"));
1839 var tagNameElement = tagElement.createChild("span", isClosingTag ? "" : "webkit-html-tag-name"); 1842 var tagNameElement = tagElement.createChild("span", isClosingTag ? "" : "webkit-html-tag-name");
1840 tagNameElement.textContent = (isClosingTag ? "/" : "") + tagName; 1843 tagNameElement.textContent = (isClosingTag ? "/" : "") + tagName;
1841 if (!isClosingTag && node.hasAttributes()) { 1844 if (!isClosingTag && node.hasAttributes()) {
(...skipping 22 matching lines...) Expand all
1864 } 1867 }
1865 if (result) { 1868 if (result) {
1866 result += text.substring(lastIndexAfterEntity); 1869 result += text.substring(lastIndexAfterEntity);
1867 return result; 1870 return result;
1868 } 1871 }
1869 return text; 1872 return text;
1870 }, 1873 },
1871 1874
1872 _nodeTitleInfo: function(linkify) 1875 _nodeTitleInfo: function(linkify)
1873 { 1876 {
1874 var node = this.representedObject; 1877 var node = this._node;
1875 var info = {titleDOM: document.createDocumentFragment(), hasChildren: th is.hasChildren}; 1878 var info = {titleDOM: document.createDocumentFragment(), hasChildren: th is.hasChildren};
1876 1879
1877 switch (node.nodeType()) { 1880 switch (node.nodeType()) {
1878 case Node.ATTRIBUTE_NODE: 1881 case Node.ATTRIBUTE_NODE:
1879 var value = node.value || "\u200B"; // Zero width space to force showing an empty value. 1882 var value = node.value || "\u200B"; // Zero width space to force showing an empty value.
1880 this._buildAttributeDOM(info.titleDOM, node.name, value); 1883 this._buildAttributeDOM(info.titleDOM, node.name, value);
1881 break; 1884 break;
1882 1885
1883 case Node.ELEMENT_NODE: 1886 case Node.ELEMENT_NODE:
1884 var tagName = node.nodeNameInCorrectCase(); 1887 var tagName = node.nodeNameInCorrectCase();
1885 if (this._elementCloseTag) { 1888 if (this._elementCloseTag) {
1886 this._buildTagDOM(info.titleDOM, tagName, true, true); 1889 this._buildTagDOM(info.titleDOM, tagName, true, true);
1887 info.hasChildren = false; 1890 info.hasChildren = false;
1888 break; 1891 break;
1889 } 1892 }
1890 1893
1891 this._buildTagDOM(info.titleDOM, tagName, false, false, linkify) ; 1894 this._buildTagDOM(info.titleDOM, tagName, false, false, linkify) ;
1892 1895
1893 var textChild = this._singleTextChild(node); 1896 var showInlineText = this._showInlineText() && !this.hasChildren ;
1894 var showInlineText = textChild && textChild.nodeValue().length < Preferences.maxInlineTextChildLength && !this.hasChildren;
1895
1896 if (!this.expanded && (!showInlineText && (this.treeOutline.isXM LMimeType || !WebInspector.ElementsTreeElement.ForbiddenClosingTagElements[tagNa me]))) { 1897 if (!this.expanded && (!showInlineText && (this.treeOutline.isXM LMimeType || !WebInspector.ElementsTreeElement.ForbiddenClosingTagElements[tagNa me]))) {
1897 if (this.hasChildren) { 1898 if (this.hasChildren) {
1898 var textNodeElement = info.titleDOM.createChild("span", "webkit-html-text-node bogus"); 1899 var textNodeElement = info.titleDOM.createChild("span", "webkit-html-text-node bogus");
1899 textNodeElement.textContent = "\u2026"; 1900 textNodeElement.textContent = "\u2026";
1900 info.titleDOM.appendChild(document.createTextNode("\u200 B")); 1901 info.titleDOM.appendChild(document.createTextNode("\u200 B"));
1901 } 1902 }
1902 this._buildTagDOM(info.titleDOM, tagName, true, false); 1903 this._buildTagDOM(info.titleDOM, tagName, true, false);
1903 } 1904 }
1904 1905
1905 // If this element only has a single child that is a text node, 1906 // If this element only has a single child that is a text node,
1906 // just show that text and the closing tag inline rather than 1907 // just show that text and the closing tag inline rather than
1907 // create a subtree for them 1908 // create a subtree for them
1908 if (showInlineText) { 1909 if (showInlineText) {
1909 var textNodeElement = info.titleDOM.createChild("span", "web kit-html-text-node"); 1910 var textNodeElement = info.titleDOM.createChild("span", "web kit-html-text-node");
1910 textNodeElement.textContent = this._convertWhitespaceToEntit ies(textChild.nodeValue()); 1911 textNodeElement.textContent = this._convertWhitespaceToEntit ies(node.firstChild.nodeValue());
1911 info.titleDOM.appendChild(document.createTextNode("\u200B")) ; 1912 info.titleDOM.appendChild(document.createTextNode("\u200B")) ;
1912 this._buildTagDOM(info.titleDOM, tagName, true, false); 1913 this._buildTagDOM(info.titleDOM, tagName, true, false);
1913 info.hasChildren = false; 1914 info.hasChildren = false;
1914 } 1915 }
1915 break; 1916 break;
1916 1917
1917 case Node.TEXT_NODE: 1918 case Node.TEXT_NODE:
1918 if (node.parentNode && node.parentNode.nodeName().toLowerCase() === "script") { 1919 if (node.parentNode && node.parentNode.nodeName().toLowerCase() === "script") {
1919 var newNode = info.titleDOM.createChild("span", "webkit-html -text-node webkit-html-js-node"); 1920 var newNode = info.titleDOM.createChild("span", "webkit-html -text-node webkit-html-js-node");
1920 newNode.textContent = node.nodeValue(); 1921 newNode.textContent = node.nodeValue();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1965 fragmentElement.textContent = node.nodeNameInCorrectCase().colla pseWhitespace(); 1966 fragmentElement.textContent = node.nodeNameInCorrectCase().colla pseWhitespace();
1966 if (node.isInShadowTree()) 1967 if (node.isInShadowTree())
1967 fragmentElement.addStyleClass("shadow"); 1968 fragmentElement.addStyleClass("shadow");
1968 break; 1969 break;
1969 default: 1970 default:
1970 info.titleDOM.appendChild(document.createTextNode(node.nodeNameI nCorrectCase().collapseWhitespace())); 1971 info.titleDOM.appendChild(document.createTextNode(node.nodeNameI nCorrectCase().collapseWhitespace()));
1971 } 1972 }
1972 return info; 1973 return info;
1973 }, 1974 },
1974 1975
1975 _singleTextChild: function(node) 1976 _showInlineText: function()
1976 { 1977 {
1977 if (!node) 1978 if (this._node.templateContent() || (WebInspector.settings.showShadowDOM .get() && this._node.hasShadowRoots()))
1978 return null; 1979 return false;
1979 1980 if (this._node.nodeType() !== Node.ELEMENT_NODE)
1980 var firstChild = node.firstChild; 1981 return false;
1981 if (!firstChild || firstChild.nodeType() !== Node.TEXT_NODE) 1982 if (!this._node.firstChild || this._node.firstChild !== this._node.lastC hild || this._node.firstChild.nodeType() !== Node.TEXT_NODE)
1982 return null; 1983 return false;
1983 1984 var textChild = this._node.firstChild;
1984 if (node.hasShadowRoots()) 1985 if (textChild.nodeValue().length < Preferences.maxInlineTextChildLength)
1985 return null; 1986 return true;
1986
1987 var sibling = firstChild.nextSibling;
1988 return sibling ? null : firstChild;
1989 },
1990
1991 _showInlineText: function(node)
1992 {
1993 if (node.nodeType() === Node.ELEMENT_NODE) {
1994 var textChild = this._singleTextChild(node);
1995 if (textChild && textChild.nodeValue().length < Preferences.maxInlin eTextChildLength)
1996 return true;
1997 }
1998 return false; 1987 return false;
1999 }, 1988 },
2000 1989
2001 remove: function() 1990 remove: function()
2002 { 1991 {
2003 var parentElement = this.parent; 1992 var parentElement = this.parent;
2004 if (!parentElement) 1993 if (!parentElement)
2005 return; 1994 return;
2006 1995
2007 var self = this; 1996 var self = this;
2008 function removeNodeCallback(error, removedNodeId) 1997 function removeNodeCallback(error, removedNodeId)
2009 { 1998 {
2010 if (error) 1999 if (error)
2011 return; 2000 return;
2012 2001
2013 parentElement.removeChild(self); 2002 parentElement.removeChild(self);
2014 parentElement.adjustCollapsedRange(); 2003 parentElement._adjustCollapsedRange();
2015 } 2004 }
2016 2005
2017 if (!this.representedObject.parentNode || this.representedObject.parentN ode.nodeType() === Node.DOCUMENT_NODE) 2006 if (!this._node.parentNode || this._node.parentNode.nodeType() === Node. DOCUMENT_NODE)
2018 return; 2007 return;
2019 this.representedObject.removeNode(removeNodeCallback); 2008 this._node.removeNode(removeNodeCallback);
2020 }, 2009 },
2021 2010
2022 _editAsHTML: function() 2011 _editAsHTML: function()
2023 { 2012 {
2024 var treeOutline = this.treeOutline; 2013 var treeOutline = this.treeOutline;
2025 var node = this.representedObject; 2014 var node = this._node;
2026 var parentNode = node.parentNode; 2015 var parentNode = node.parentNode;
2027 var index = node.index; 2016 var index = node.index;
2028 var wasExpanded = this.expanded; 2017 var wasExpanded = this.expanded;
2029 2018
2030 function selectNode(error, nodeId) 2019 function selectNode(error, nodeId)
2031 { 2020 {
2032 if (error) 2021 if (error)
2033 return; 2022 return;
2034 2023
2035 // Select it and expand if necessary. We force tree update so that i t processes dom events and is up to date. 2024 // Select it and expand if necessary. We force tree update so that i t processes dom events and is up to date.
2036 treeOutline._updateModifiedNodes(); 2025 treeOutline._updateModifiedNodes();
2037 2026
2038 var newNode = parentNode ? parentNode.children[index] || parentNode : null; 2027 var newNode = parentNode ? parentNode.children()[index] || parentNod e : null;
vsevik 2013/06/07 08:41:00 ...Or index is used.....???
2039 if (!newNode) 2028 if (!newNode)
2040 return; 2029 return;
2041 2030
2042 treeOutline.selectDOMNode(newNode, true); 2031 treeOutline.selectDOMNode(newNode, true);
2043 2032
2044 if (wasExpanded) { 2033 if (wasExpanded) {
2045 var newTreeItem = treeOutline.findTreeElement(newNode); 2034 var newTreeItem = treeOutline.findTreeElement(newNode);
2046 if (newTreeItem) 2035 if (newTreeItem)
2047 newTreeItem.expand(); 2036 newTreeItem.expand();
2048 } 2037 }
2049 } 2038 }
2050 2039
2051 function commitChange(initialValue, value) 2040 function commitChange(initialValue, value)
2052 { 2041 {
2053 if (initialValue !== value) 2042 if (initialValue !== value)
2054 node.setOuterHTML(value, selectNode); 2043 node.setOuterHTML(value, selectNode);
2055 else 2044 else
2056 return; 2045 return;
2057 } 2046 }
2058 2047
2059 node.getOuterHTML(this._startEditingAsHTML.bind(this, commitChange)); 2048 node.getOuterHTML(this._startEditingAsHTML.bind(this, commitChange));
2060 }, 2049 },
2061 2050
2062 _copyHTML: function() 2051 _copyHTML: function()
2063 { 2052 {
2064 this.representedObject.copyNode(); 2053 this._node.copyNode();
2065 }, 2054 },
2066 2055
2067 _copyXPath: function() 2056 _copyXPath: function()
2068 { 2057 {
2069 this.representedObject.copyXPath(true); 2058 this._node.copyXPath(true);
2070 }, 2059 },
2071 2060
2072 _highlightSearchResults: function() 2061 _highlightSearchResults: function()
2073 { 2062 {
2074 if (!this._searchQuery || !this._searchHighlightsVisible) 2063 if (!this._searchQuery || !this._searchHighlightsVisible)
2075 return; 2064 return;
2076 if (this._highlightResult) { 2065 if (this._highlightResult) {
2077 this._updateSearchHighlight(true); 2066 this._updateSearchHighlight(true);
2078 return; 2067 return;
2079 } 2068 }
(...skipping 23 matching lines...) Expand all
2103 { 2092 {
2104 function scrollIntoView() 2093 function scrollIntoView()
2105 { 2094 {
2106 this.scrollIntoViewIfNeeded(true); 2095 this.scrollIntoViewIfNeeded(true);
2107 } 2096 }
2108 2097
2109 if (object) 2098 if (object)
2110 object.callFunction(scrollIntoView); 2099 object.callFunction(scrollIntoView);
2111 } 2100 }
2112 2101
2113 var node = /** @type {WebInspector.DOMNode} */ (this.representedObject); 2102 WebInspector.RemoteObject.resolveNode(this._node, "", scrollIntoViewCall back);
2114 WebInspector.RemoteObject.resolveNode(node, "", scrollIntoViewCallback); 2103 },
2104
2105 /**
2106 * @return {Array.<WebInspector.DOMNode>} visibleChildren
2107 */
2108 _visibleChildren: function()
2109 {
2110 var visibleChildren = WebInspector.settings.showShadowDOM.get() ? this._ node.shadowRoots() : [];
2111 if (this._node.templateContent())
2112 visibleChildren.push(this._node.templateContent());
2113 if (this._node.childNodeCount())
2114 visibleChildren = visibleChildren.concat(this._node.children());
apavlov 2013/06/06 16:18:59 Alternatively, visibleChildren.push.apply(visibleC
pfeldman 2013/06/07 08:53:49 Done.
2115 return visibleChildren;
2116 },
2117
2118 /**
2119 * @return {Array.<WebInspector.DOMNode>} visibleChildren
2120 */
2121 _visibleChildCount: function()
2122 {
2123 var childCount = this._node.childNodeCount();
2124 if (this._node.templateContent())
2125 childCount++;
2126 if (WebInspector.settings.showShadowDOM.get())
2127 childCount += this._node.shadowRoots().length;
2128 return childCount;
2129 },
2130
2131 _updateHasChildren: function()
2132 {
2133 this.hasChildren = !this._elementCloseTag && !this._showInlineText() && this._visibleChildCount() > 0;
2115 }, 2134 },
2116 2135
2117 __proto__: TreeElement.prototype 2136 __proto__: TreeElement.prototype
2118 } 2137 }
2119 2138
2120 /** 2139 /**
2121 * @constructor 2140 * @constructor
2122 */ 2141 */
2123 WebInspector.ElementsTreeUpdater = function(treeOutline) 2142 WebInspector.ElementsTreeUpdater = function(treeOutline)
2124 { 2143 {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2187 2206
2188 _nodeRemoved: function(event) 2207 _nodeRemoved: function(event)
2189 { 2208 {
2190 this._nodeModified(event.data.node, false, event.data.parent); 2209 this._nodeModified(event.data.node, false, event.data.parent);
2191 }, 2210 },
2192 2211
2193 _childNodeCountUpdated: function(event) 2212 _childNodeCountUpdated: function(event)
2194 { 2213 {
2195 var treeElement = this._treeOutline.findTreeElement(event.data); 2214 var treeElement = this._treeOutline.findTreeElement(event.data);
2196 if (treeElement) 2215 if (treeElement)
2197 treeElement.hasChildren = event.data.hasChildNodes(); 2216 treeElement._updateHasChildren();
2198 }, 2217 },
2199 2218
2200 _updateModifiedNodesSoon: function() 2219 _updateModifiedNodesSoon: function()
2201 { 2220 {
2202 if (this._updateModifiedNodesTimeout) 2221 if (this._updateModifiedNodesTimeout)
2203 return; 2222 return;
2204 this._updateModifiedNodesTimeout = setTimeout(this._updateModifiedNodes. bind(this), 50); 2223 this._updateModifiedNodesTimeout = setTimeout(this._updateModifiedNodes. bind(this), 50);
2205 }, 2224 },
2206 2225
2207 _updateModifiedNodes: function() 2226 _updateModifiedNodes: function()
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2275 * @constructor 2294 * @constructor
2276 * @param {boolean} isUpdated 2295 * @param {boolean} isUpdated
2277 * @param {WebInspector.DOMNode=} parent 2296 * @param {WebInspector.DOMNode=} parent
2278 */ 2297 */
2279 WebInspector.ElementsTreeUpdater.UpdateEntry = function(isUpdated, parent) 2298 WebInspector.ElementsTreeUpdater.UpdateEntry = function(isUpdated, parent)
2280 { 2299 {
2281 this.isUpdated = isUpdated; 2300 this.isUpdated = isUpdated;
2282 if (parent) 2301 if (parent)
2283 this.parent = parent; 2302 this.parent = parent;
2284 } 2303 }
OLDNEW
« Source/devtools/front_end/DOMAgent.js ('K') | « Source/devtools/front_end/ElementsPanel.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698