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

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: For landing 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;
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)
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();
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;
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 var openTagElement = this.treeOutline.getCachedTreeElement(this.represen tedObject) || this; 1301 var openTagElement = this.treeOutline.getCachedTreeElement(this.represen tedObject) || this;
1299 contextMenu.appendItem(WebInspector.UIString("Edit as HTML"), openTagEle ment._editAsHTML.bind(openTagElement)); 1302 contextMenu.appendItem(WebInspector.UIString("Edit as HTML"), openTagEle ment._editAsHTML.bind(openTagElement));
1300 contextMenu.appendItem(WebInspector.UIString("Copy as HTML"), this._copy HTML.bind(this)); 1303 contextMenu.appendItem(WebInspector.UIString("Copy as HTML"), this._copy HTML.bind(this));
1301 contextMenu.appendItem(WebInspector.UIString("Copy XPath"), this._copyXP ath.bind(this)); 1304 contextMenu.appendItem(WebInspector.UIString("Copy XPath"), this._copyXP ath.bind(this));
1302 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Delete node" : "Delete Node"), this.remove.bind(this)); 1305 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe nuTitles() ? "Delete node" : "Delete Node"), this.remove.bind(this));
1303 }, 1306 },
1304 1307
1305 _startEditing: function() 1308 _startEditing: function()
1306 { 1309 {
1307 if (this.treeOutline.selectedDOMNode() !== this.representedObject) 1310 if (this.treeOutline.selectedDOMNode() !== this._node)
1308 return; 1311 return;
1309 1312
1310 var listItem = this._listItemNode; 1313 var listItem = this._listItemNode;
1311 1314
1312 if (this._canAddAttributes) { 1315 if (this._canAddAttributes) {
1313 var attribute = listItem.getElementsByClassName("webkit-html-attribu te")[0]; 1316 var attribute = listItem.getElementsByClassName("webkit-html-attribu te")[0];
1314 if (attribute) 1317 if (attribute)
1315 return this._startEditingAttribute(attribute, attribute.getEleme ntsByClassName("webkit-html-attribute-value")[0]); 1318 return this._startEditingAttribute(attribute, attribute.getEleme ntsByClassName("webkit-html-attribute-value")[0]);
1316 1319
1317 return this._addNewAttribute(); 1320 return this._addNewAttribute();
1318 } 1321 }
1319 1322
1320 if (this.representedObject.nodeType() === Node.TEXT_NODE) { 1323 if (this._node.nodeType() === Node.TEXT_NODE) {
1321 var textNode = listItem.getElementsByClassName("webkit-html-text-nod e")[0]; 1324 var textNode = listItem.getElementsByClassName("webkit-html-text-nod e")[0];
1322 if (textNode) 1325 if (textNode)
1323 return this._startEditingTextNode(textNode); 1326 return this._startEditingTextNode(textNode);
1324 return; 1327 return;
1325 } 1328 }
1326 }, 1329 },
1327 1330
1328 _addNewAttribute: function() 1331 _addNewAttribute: function()
1329 { 1332 {
1330 // Cannot just convert the textual html into an element without 1333 // Cannot just convert the textual html into an element without
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 }, 1417 },
1415 1418
1416 /** 1419 /**
1417 * @param {Element} textNodeElement 1420 * @param {Element} textNodeElement
1418 */ 1421 */
1419 _startEditingTextNode: function(textNodeElement) 1422 _startEditingTextNode: function(textNodeElement)
1420 { 1423 {
1421 if (WebInspector.isBeingEdited(textNodeElement)) 1424 if (WebInspector.isBeingEdited(textNodeElement))
1422 return true; 1425 return true;
1423 1426
1424 var textNode = this.representedObject; 1427 var textNode = this._node;
1425 // We only show text nodes inline in elements if the element only 1428 // We only show text nodes inline in elements if the element only
1426 // has a single child, and that child is a text node. 1429 // has a single child, and that child is a text node.
1427 if (textNode.nodeType() === Node.ELEMENT_NODE && textNode.firstChild) 1430 if (textNode.nodeType() === Node.ELEMENT_NODE && textNode.firstChild)
1428 textNode = textNode.firstChild; 1431 textNode = textNode.firstChild;
1429 1432
1430 var container = textNodeElement.enclosingNodeOrSelfWithClass("webkit-htm l-text-node"); 1433 var container = textNodeElement.enclosingNodeOrSelfWithClass("webkit-htm l-text-node");
1431 if (container) 1434 if (container)
1432 container.textContent = textNode.nodeValue(); // Strip the CSS or JS highlighting if present. 1435 container.textContent = textNode.nodeValue(); // Strip the CSS or JS highlighting if present.
1433 var config = new WebInspector.EditingConfig(this._textNodeEditingCommitt ed.bind(this, textNode), this._editingCancelled.bind(this)); 1436 var config = new WebInspector.EditingConfig(this._textNodeEditingCommitt ed.bind(this, textNode), this._editingCancelled.bind(this));
1434 this._editing = WebInspector.startEditing(textNodeElement, config); 1437 this._editing = WebInspector.startEditing(textNodeElement, config);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 { 1567 {
1565 if (error) 1568 if (error)
1566 this._editingCancelled(element, attributeName); 1569 this._editingCancelled(element, attributeName);
1567 1570
1568 if (!moveDirection) 1571 if (!moveDirection)
1569 return; 1572 return;
1570 1573
1571 treeOutline._updateModifiedNodes(); 1574 treeOutline._updateModifiedNodes();
1572 1575
1573 // Search for the attribute's position, and then decide where to mov e to. 1576 // Search for the attribute's position, and then decide where to mov e to.
1574 var attributes = this.representedObject.attributes(); 1577 var attributes = this._node.attributes();
1575 for (var i = 0; i < attributes.length; ++i) { 1578 for (var i = 0; i < attributes.length; ++i) {
1576 if (attributes[i].name !== attributeName) 1579 if (attributes[i].name !== attributeName)
1577 continue; 1580 continue;
1578 1581
1579 if (moveDirection === "backward") { 1582 if (moveDirection === "backward") {
1580 if (i === 0) 1583 if (i === 0)
1581 this._startEditingTagName(); 1584 this._startEditingTagName();
1582 else 1585 else
1583 this._triggerEditAttribute(attributes[i - 1].name); 1586 this._triggerEditAttribute(attributes[i - 1].name);
1584 } else { 1587 } else {
(...skipping 24 matching lines...) Expand all
1609 } 1612 }
1610 } 1613 }
1611 1614
1612 if (!attributeName.trim() && !newText.trim()) { 1615 if (!attributeName.trim() && !newText.trim()) {
1613 element.removeSelf(); 1616 element.removeSelf();
1614 moveToNextAttributeIfNeeded.call(this); 1617 moveToNextAttributeIfNeeded.call(this);
1615 return; 1618 return;
1616 } 1619 }
1617 1620
1618 if (oldText !== newText) { 1621 if (oldText !== newText) {
1619 this.representedObject.setAttribute(attributeName, newText, moveToNe xtAttributeIfNeeded.bind(this)); 1622 this._node.setAttribute(attributeName, newText, moveToNextAttributeI fNeeded.bind(this));
1620 return; 1623 return;
1621 } 1624 }
1622 1625
1623 moveToNextAttributeIfNeeded.call(this); 1626 moveToNextAttributeIfNeeded.call(this);
1624 }, 1627 },
1625 1628
1626 _tagNameEditingCommitted: function(element, newText, oldText, tagName, moveD irection) 1629 _tagNameEditingCommitted: function(element, newText, oldText, tagName, moveD irection)
1627 { 1630 {
1628 delete this._editing; 1631 delete this._editing;
1629 var self = this; 1632 var self = this;
1630 1633
1631 function cancel() 1634 function cancel()
1632 { 1635 {
1633 var closingTagElement = self._distinctClosingTagElement(); 1636 var closingTagElement = self._distinctClosingTagElement();
1634 if (closingTagElement) 1637 if (closingTagElement)
1635 closingTagElement.textContent = "</" + tagName + ">"; 1638 closingTagElement.textContent = "</" + tagName + ">";
1636 1639
1637 self._editingCancelled(element, tagName); 1640 self._editingCancelled(element, tagName);
1638 moveToNextAttributeIfNeeded.call(self); 1641 moveToNextAttributeIfNeeded.call(self);
1639 } 1642 }
1640 1643
1641 function moveToNextAttributeIfNeeded() 1644 function moveToNextAttributeIfNeeded()
1642 { 1645 {
1643 if (moveDirection !== "forward") { 1646 if (moveDirection !== "forward") {
1644 this._addNewAttribute(); 1647 this._addNewAttribute();
1645 return; 1648 return;
1646 } 1649 }
1647 1650
1648 var attributes = this.representedObject.attributes(); 1651 var attributes = this._node.attributes();
1649 if (attributes.length > 0) 1652 if (attributes.length > 0)
1650 this._triggerEditAttribute(attributes[0].name); 1653 this._triggerEditAttribute(attributes[0].name);
1651 else 1654 else
1652 this._addNewAttribute(); 1655 this._addNewAttribute();
1653 } 1656 }
1654 1657
1655 newText = newText.trim(); 1658 newText = newText.trim();
1656 if (newText === oldText) { 1659 if (newText === oldText) {
1657 cancel(); 1660 cancel();
1658 return; 1661 return;
1659 } 1662 }
1660 1663
1661 var treeOutline = this.treeOutline; 1664 var treeOutline = this.treeOutline;
1662 var wasExpanded = this.expanded; 1665 var wasExpanded = this.expanded;
1663 1666
1664 function changeTagNameCallback(error, nodeId) 1667 function changeTagNameCallback(error, nodeId)
1665 { 1668 {
1666 if (error || !nodeId) { 1669 if (error || !nodeId) {
1667 cancel(); 1670 cancel();
1668 return; 1671 return;
1669 } 1672 }
1670 var newTreeItem = treeOutline._selectNodeAfterEdit(null, wasExpanded , error, nodeId); 1673 var newTreeItem = treeOutline._selectNodeAfterEdit(null, wasExpanded , error, nodeId);
1671 moveToNextAttributeIfNeeded.call(newTreeItem); 1674 moveToNextAttributeIfNeeded.call(newTreeItem);
1672 } 1675 }
1673 1676
1674 this.representedObject.setNodeName(newText, changeTagNameCallback); 1677 this._node.setNodeName(newText, changeTagNameCallback);
1675 }, 1678 },
1676 1679
1677 /** 1680 /**
1678 * @param {WebInspector.DOMNode} textNode 1681 * @param {WebInspector.DOMNode} textNode
1679 * @param {Element} element 1682 * @param {Element} element
1680 * @param {string} newText 1683 * @param {string} newText
1681 */ 1684 */
1682 _textNodeEditingCommitted: function(textNode, element, newText) 1685 _textNodeEditingCommitted: function(textNode, element, newText)
1683 { 1686 {
1684 delete this._editing; 1687 delete this._editing;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 1747
1745 delete this.selectionElement; 1748 delete this.selectionElement;
1746 if (this.selected) 1749 if (this.selected)
1747 this.updateSelection(); 1750 this.updateSelection();
1748 this._preventFollowingLinksOnDoubleClick(); 1751 this._preventFollowingLinksOnDoubleClick();
1749 this._highlightSearchResults(); 1752 this._highlightSearchResults();
1750 }, 1753 },
1751 1754
1752 _createDecoratorElement: function() 1755 _createDecoratorElement: function()
1753 { 1756 {
1754 var node = this.representedObject; 1757 var node = this._node;
1755 var decoratorMessages = []; 1758 var decoratorMessages = [];
1756 var parentDecoratorMessages = []; 1759 var parentDecoratorMessages = [];
1757 for (var i = 0; i < this.treeOutline._nodeDecorators.length; ++i) { 1760 for (var i = 0; i < this.treeOutline._nodeDecorators.length; ++i) {
1758 var decorator = this.treeOutline._nodeDecorators[i]; 1761 var decorator = this.treeOutline._nodeDecorators[i];
1759 var message = decorator.decorate(node); 1762 var message = decorator.decorate(node);
1760 if (message) { 1763 if (message) {
1761 decoratorMessages.push(message); 1764 decoratorMessages.push(message);
1762 continue; 1765 continue;
1763 } 1766 }
1764 1767
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1822 1825
1823 if (hasText) 1826 if (hasText)
1824 attrSpanElement.appendChild(document.createTextNode("\"")); 1827 attrSpanElement.appendChild(document.createTextNode("\""));
1825 }, 1828 },
1826 1829
1827 /** 1830 /**
1828 * @param {function(string, string, string, boolean=, string=)=} linkify 1831 * @param {function(string, string, string, boolean=, string=)=} linkify
1829 */ 1832 */
1830 _buildTagDOM: function(parentElement, tagName, isClosingTag, isDistinctTreeE lement, linkify) 1833 _buildTagDOM: function(parentElement, tagName, isClosingTag, isDistinctTreeE lement, linkify)
1831 { 1834 {
1832 var node = /** @type WebInspector.DOMNode */ (this.representedObject); 1835 var node = this._node;
1833 var classes = [ "webkit-html-tag" ]; 1836 var classes = [ "webkit-html-tag" ];
1834 if (isClosingTag && isDistinctTreeElement) 1837 if (isClosingTag && isDistinctTreeElement)
1835 classes.push("close"); 1838 classes.push("close");
1836 if (node.isInShadowTree()) 1839 if (node.isInShadowTree())
1837 classes.push("shadow"); 1840 classes.push("shadow");
1838 var tagElement = parentElement.createChild("span", classes.join(" ")); 1841 var tagElement = parentElement.createChild("span", classes.join(" "));
1839 tagElement.appendChild(document.createTextNode("<")); 1842 tagElement.appendChild(document.createTextNode("<"));
1840 var tagNameElement = tagElement.createChild("span", isClosingTag ? "" : "webkit-html-tag-name"); 1843 var tagNameElement = tagElement.createChild("span", isClosingTag ? "" : "webkit-html-tag-name");
1841 tagNameElement.textContent = (isClosingTag ? "/" : "") + tagName; 1844 tagNameElement.textContent = (isClosingTag ? "/" : "") + tagName;
1842 if (!isClosingTag && node.hasAttributes()) { 1845 if (!isClosingTag && node.hasAttributes()) {
(...skipping 22 matching lines...) Expand all
1865 } 1868 }
1866 if (result) { 1869 if (result) {
1867 result += text.substring(lastIndexAfterEntity); 1870 result += text.substring(lastIndexAfterEntity);
1868 return result; 1871 return result;
1869 } 1872 }
1870 return text; 1873 return text;
1871 }, 1874 },
1872 1875
1873 _nodeTitleInfo: function(linkify) 1876 _nodeTitleInfo: function(linkify)
1874 { 1877 {
1875 var node = this.representedObject; 1878 var node = this._node;
1876 var info = {titleDOM: document.createDocumentFragment(), hasChildren: th is.hasChildren}; 1879 var info = {titleDOM: document.createDocumentFragment(), hasChildren: th is.hasChildren};
1877 1880
1878 switch (node.nodeType()) { 1881 switch (node.nodeType()) {
1879 case Node.ATTRIBUTE_NODE: 1882 case Node.ATTRIBUTE_NODE:
1880 var value = node.value || "\u200B"; // Zero width space to force showing an empty value. 1883 var value = node.value || "\u200B"; // Zero width space to force showing an empty value.
1881 this._buildAttributeDOM(info.titleDOM, node.name, value); 1884 this._buildAttributeDOM(info.titleDOM, node.name, value);
1882 break; 1885 break;
1883 1886
1884 case Node.ELEMENT_NODE: 1887 case Node.ELEMENT_NODE:
1885 var tagName = node.nodeNameInCorrectCase(); 1888 var tagName = node.nodeNameInCorrectCase();
1886 if (this._elementCloseTag) { 1889 if (this._elementCloseTag) {
1887 this._buildTagDOM(info.titleDOM, tagName, true, true); 1890 this._buildTagDOM(info.titleDOM, tagName, true, true);
1888 info.hasChildren = false; 1891 info.hasChildren = false;
1889 break; 1892 break;
1890 } 1893 }
1891 1894
1892 this._buildTagDOM(info.titleDOM, tagName, false, false, linkify) ; 1895 this._buildTagDOM(info.titleDOM, tagName, false, false, linkify) ;
1893 1896
1894 var textChild = this._singleTextChild(node); 1897 var showInlineText = this._showInlineText() && !this.hasChildren ;
1895 var showInlineText = textChild && textChild.nodeValue().length < Preferences.maxInlineTextChildLength && !this.hasChildren;
1896
1897 if (!this.expanded && (!showInlineText && (this.treeOutline.isXM LMimeType || !WebInspector.ElementsTreeElement.ForbiddenClosingTagElements[tagNa me]))) { 1898 if (!this.expanded && (!showInlineText && (this.treeOutline.isXM LMimeType || !WebInspector.ElementsTreeElement.ForbiddenClosingTagElements[tagNa me]))) {
1898 if (this.hasChildren) { 1899 if (this.hasChildren) {
1899 var textNodeElement = info.titleDOM.createChild("span", "webkit-html-text-node bogus"); 1900 var textNodeElement = info.titleDOM.createChild("span", "webkit-html-text-node bogus");
1900 textNodeElement.textContent = "\u2026"; 1901 textNodeElement.textContent = "\u2026";
1901 info.titleDOM.appendChild(document.createTextNode("\u200 B")); 1902 info.titleDOM.appendChild(document.createTextNode("\u200 B"));
1902 } 1903 }
1903 this._buildTagDOM(info.titleDOM, tagName, true, false); 1904 this._buildTagDOM(info.titleDOM, tagName, true, false);
1904 } 1905 }
1905 1906
1906 // If this element only has a single child that is a text node, 1907 // If this element only has a single child that is a text node,
1907 // just show that text and the closing tag inline rather than 1908 // just show that text and the closing tag inline rather than
1908 // create a subtree for them 1909 // create a subtree for them
1909 if (showInlineText) { 1910 if (showInlineText) {
1910 var textNodeElement = info.titleDOM.createChild("span", "web kit-html-text-node"); 1911 var textNodeElement = info.titleDOM.createChild("span", "web kit-html-text-node");
1911 textNodeElement.textContent = this._convertWhitespaceToEntit ies(textChild.nodeValue()); 1912 textNodeElement.textContent = this._convertWhitespaceToEntit ies(node.firstChild.nodeValue());
1912 info.titleDOM.appendChild(document.createTextNode("\u200B")) ; 1913 info.titleDOM.appendChild(document.createTextNode("\u200B")) ;
1913 this._buildTagDOM(info.titleDOM, tagName, true, false); 1914 this._buildTagDOM(info.titleDOM, tagName, true, false);
1914 info.hasChildren = false; 1915 info.hasChildren = false;
1915 } 1916 }
1916 break; 1917 break;
1917 1918
1918 case Node.TEXT_NODE: 1919 case Node.TEXT_NODE:
1919 if (node.parentNode && node.parentNode.nodeName().toLowerCase() === "script") { 1920 if (node.parentNode && node.parentNode.nodeName().toLowerCase() === "script") {
1920 var newNode = info.titleDOM.createChild("span", "webkit-html -text-node webkit-html-js-node"); 1921 var newNode = info.titleDOM.createChild("span", "webkit-html -text-node webkit-html-js-node");
1921 newNode.textContent = node.nodeValue(); 1922 newNode.textContent = node.nodeValue();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1966 fragmentElement.textContent = node.nodeNameInCorrectCase().colla pseWhitespace(); 1967 fragmentElement.textContent = node.nodeNameInCorrectCase().colla pseWhitespace();
1967 if (node.isInShadowTree()) 1968 if (node.isInShadowTree())
1968 fragmentElement.addStyleClass("shadow"); 1969 fragmentElement.addStyleClass("shadow");
1969 break; 1970 break;
1970 default: 1971 default:
1971 info.titleDOM.appendChild(document.createTextNode(node.nodeNameI nCorrectCase().collapseWhitespace())); 1972 info.titleDOM.appendChild(document.createTextNode(node.nodeNameI nCorrectCase().collapseWhitespace()));
1972 } 1973 }
1973 return info; 1974 return info;
1974 }, 1975 },
1975 1976
1976 _singleTextChild: function(node) 1977 _showInlineText: function()
1977 { 1978 {
1978 if (!node) 1979 if (this._node.templateContent() || (WebInspector.settings.showShadowDOM .get() && this._node.hasShadowRoots()))
johnjbarton 2013/10/08 21:59:56 Here we throw an exception because this._node is n
1979 return null; 1980 return false;
1980 1981 if (this._node.nodeType() !== Node.ELEMENT_NODE)
1981 var firstChild = node.firstChild; 1982 return false;
1982 if (!firstChild || firstChild.nodeType() !== Node.TEXT_NODE) 1983 if (!this._node.firstChild || this._node.firstChild !== this._node.lastC hild || this._node.firstChild.nodeType() !== Node.TEXT_NODE)
1983 return null; 1984 return false;
1984 1985 var textChild = this._node.firstChild;
1985 if (node.hasShadowRoots()) 1986 if (textChild.nodeValue().length < Preferences.maxInlineTextChildLength)
1986 return null; 1987 return true;
1987
1988 var sibling = firstChild.nextSibling;
1989 return sibling ? null : firstChild;
1990 },
1991
1992 _showInlineText: function(node)
1993 {
1994 if (node.nodeType() === Node.ELEMENT_NODE) {
1995 var textChild = this._singleTextChild(node);
1996 if (textChild && textChild.nodeValue().length < Preferences.maxInlin eTextChildLength)
1997 return true;
1998 }
1999 return false; 1988 return false;
2000 }, 1989 },
2001 1990
2002 remove: function() 1991 remove: function()
2003 { 1992 {
2004 var parentElement = this.parent; 1993 var parentElement = this.parent;
2005 if (!parentElement) 1994 if (!parentElement)
2006 return; 1995 return;
2007 1996
2008 var self = this; 1997 var self = this;
2009 function removeNodeCallback(error, removedNodeId) 1998 function removeNodeCallback(error, removedNodeId)
2010 { 1999 {
2011 if (error) 2000 if (error)
2012 return; 2001 return;
2013 2002
2014 parentElement.removeChild(self); 2003 parentElement.removeChild(self);
2015 parentElement.adjustCollapsedRange(); 2004 parentElement._adjustCollapsedRange();
2016 } 2005 }
2017 2006
2018 if (!this.representedObject.parentNode || this.representedObject.parentN ode.nodeType() === Node.DOCUMENT_NODE) 2007 if (!this._node.parentNode || this._node.parentNode.nodeType() === Node. DOCUMENT_NODE)
2019 return; 2008 return;
2020 this.representedObject.removeNode(removeNodeCallback); 2009 this._node.removeNode(removeNodeCallback);
2021 }, 2010 },
2022 2011
2023 _editAsHTML: function() 2012 _editAsHTML: function()
2024 { 2013 {
2025 var treeOutline = this.treeOutline; 2014 var treeOutline = this.treeOutline;
2026 var node = this.representedObject; 2015 var node = this._node;
2027 var parentNode = node.parentNode; 2016 var parentNode = node.parentNode;
2028 var index = node.index; 2017 var index = node.index;
2029 var wasExpanded = this.expanded; 2018 var wasExpanded = this.expanded;
2030 2019
2031 function selectNode(error, nodeId) 2020 function selectNode(error, nodeId)
2032 { 2021 {
2033 if (error) 2022 if (error)
2034 return; 2023 return;
2035 2024
2036 // Select it and expand if necessary. We force tree update so that i t processes dom events and is up to date. 2025 // Select it and expand if necessary. We force tree update so that i t processes dom events and is up to date.
2037 treeOutline._updateModifiedNodes(); 2026 treeOutline._updateModifiedNodes();
2038 2027
2039 var newNode = parentNode ? parentNode.children[index] || parentNode : null; 2028 var newNode = parentNode ? parentNode.children()[index] || parentNod e : null;
2040 if (!newNode) 2029 if (!newNode)
2041 return; 2030 return;
2042 2031
2043 treeOutline.selectDOMNode(newNode, true); 2032 treeOutline.selectDOMNode(newNode, true);
2044 2033
2045 if (wasExpanded) { 2034 if (wasExpanded) {
2046 var newTreeItem = treeOutline.findTreeElement(newNode); 2035 var newTreeItem = treeOutline.findTreeElement(newNode);
2047 if (newTreeItem) 2036 if (newTreeItem)
2048 newTreeItem.expand(); 2037 newTreeItem.expand();
2049 } 2038 }
2050 } 2039 }
2051 2040
2052 function commitChange(initialValue, value) 2041 function commitChange(initialValue, value)
2053 { 2042 {
2054 if (initialValue !== value) 2043 if (initialValue !== value)
2055 node.setOuterHTML(value, selectNode); 2044 node.setOuterHTML(value, selectNode);
2056 else 2045 else
2057 return; 2046 return;
2058 } 2047 }
2059 2048
2060 node.getOuterHTML(this._startEditingAsHTML.bind(this, commitChange)); 2049 node.getOuterHTML(this._startEditingAsHTML.bind(this, commitChange));
2061 }, 2050 },
2062 2051
2063 _copyHTML: function() 2052 _copyHTML: function()
2064 { 2053 {
2065 this.representedObject.copyNode(); 2054 this._node.copyNode();
2066 }, 2055 },
2067 2056
2068 _copyXPath: function() 2057 _copyXPath: function()
2069 { 2058 {
2070 this.representedObject.copyXPath(true); 2059 this._node.copyXPath(true);
2071 }, 2060 },
2072 2061
2073 _highlightSearchResults: function() 2062 _highlightSearchResults: function()
2074 { 2063 {
2075 if (!this._searchQuery || !this._searchHighlightsVisible) 2064 if (!this._searchQuery || !this._searchHighlightsVisible)
2076 return; 2065 return;
2077 if (this._highlightResult) { 2066 if (this._highlightResult) {
2078 this._updateSearchHighlight(true); 2067 this._updateSearchHighlight(true);
2079 return; 2068 return;
2080 } 2069 }
(...skipping 23 matching lines...) Expand all
2104 { 2093 {
2105 function scrollIntoView() 2094 function scrollIntoView()
2106 { 2095 {
2107 this.scrollIntoViewIfNeeded(true); 2096 this.scrollIntoViewIfNeeded(true);
2108 } 2097 }
2109 2098
2110 if (object) 2099 if (object)
2111 object.callFunction(scrollIntoView); 2100 object.callFunction(scrollIntoView);
2112 } 2101 }
2113 2102
2114 var node = /** @type {WebInspector.DOMNode} */ (this.representedObject); 2103 WebInspector.RemoteObject.resolveNode(this._node, "", scrollIntoViewCall back);
2115 WebInspector.RemoteObject.resolveNode(node, "", scrollIntoViewCallback); 2104 },
2105
2106 /**
2107 * @return {Array.<WebInspector.DOMNode>} visibleChildren
2108 */
2109 _visibleChildren: function()
2110 {
2111 var visibleChildren = WebInspector.settings.showShadowDOM.get() ? this._ node.shadowRoots() : [];
2112 if (this._node.templateContent())
2113 visibleChildren.push(this._node.templateContent());
2114 if (this._node.childNodeCount())
2115 visibleChildren = visibleChildren.concat(this._node.children());
johnjbarton 2013/10/08 21:59:56 Here is the concat which uses childern(). visibleC
2116 return visibleChildren;
2117 },
2118
2119 /**
2120 * @return {Array.<WebInspector.DOMNode>} visibleChildren
2121 */
2122 _visibleChildCount: function()
2123 {
2124 var childCount = this._node.childNodeCount();
2125 if (this._node.templateContent())
2126 childCount++;
2127 if (WebInspector.settings.showShadowDOM.get())
2128 childCount += this._node.shadowRoots().length;
2129 return childCount;
2130 },
2131
2132 _updateHasChildren: function()
2133 {
2134 this.hasChildren = !this._elementCloseTag && !this._showInlineText() && this._visibleChildCount() > 0;
2116 }, 2135 },
2117 2136
2118 __proto__: TreeElement.prototype 2137 __proto__: TreeElement.prototype
2119 } 2138 }
2120 2139
2121 /** 2140 /**
2122 * @constructor 2141 * @constructor
2123 */ 2142 */
2124 WebInspector.ElementsTreeUpdater = function(treeOutline) 2143 WebInspector.ElementsTreeUpdater = function(treeOutline)
2125 { 2144 {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
2188 2207
2189 _nodeRemoved: function(event) 2208 _nodeRemoved: function(event)
2190 { 2209 {
2191 this._nodeModified(event.data.node, false, event.data.parent); 2210 this._nodeModified(event.data.node, false, event.data.parent);
2192 }, 2211 },
2193 2212
2194 _childNodeCountUpdated: function(event) 2213 _childNodeCountUpdated: function(event)
2195 { 2214 {
2196 var treeElement = this._treeOutline.findTreeElement(event.data); 2215 var treeElement = this._treeOutline.findTreeElement(event.data);
2197 if (treeElement) 2216 if (treeElement)
2198 treeElement.hasChildren = event.data.hasChildNodes(); 2217 treeElement._updateHasChildren();
2199 }, 2218 },
2200 2219
2201 _updateModifiedNodesSoon: function() 2220 _updateModifiedNodesSoon: function()
2202 { 2221 {
2203 if (this._updateModifiedNodesTimeout) 2222 if (this._updateModifiedNodesTimeout)
2204 return; 2223 return;
2205 this._updateModifiedNodesTimeout = setTimeout(this._updateModifiedNodes. bind(this), 50); 2224 this._updateModifiedNodesTimeout = setTimeout(this._updateModifiedNodes. bind(this), 50);
2206 }, 2225 },
2207 2226
2208 _updateModifiedNodes: function() 2227 _updateModifiedNodes: function()
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2276 * @constructor 2295 * @constructor
2277 * @param {boolean} isUpdated 2296 * @param {boolean} isUpdated
2278 * @param {WebInspector.DOMNode=} parent 2297 * @param {WebInspector.DOMNode=} parent
2279 */ 2298 */
2280 WebInspector.ElementsTreeUpdater.UpdateEntry = function(isUpdated, parent) 2299 WebInspector.ElementsTreeUpdater.UpdateEntry = function(isUpdated, parent)
2281 { 2300 {
2282 this.isUpdated = isUpdated; 2301 this.isUpdated = isUpdated;
2283 if (parent) 2302 if (parent)
2284 this.parent = parent; 2303 this.parent = parent;
2285 } 2304 }
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