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

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

Issue 720793003: DevTools: Replace visibleChildrenCount with hasVisibleChildren in ElementsTreeOutline. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix Created 6 years, 1 month 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 1417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1428 this.insertChild(this.expandAllButtonElement, targetButtonIndex) ; 1428 this.insertChild(this.expandAllButtonElement, targetButtonIndex) ;
1429 } else if (!this.expandAllButtonElement.parent) 1429 } else if (!this.expandAllButtonElement.parent)
1430 this.insertChild(this.expandAllButtonElement, targetButtonIndex) ; 1430 this.insertChild(this.expandAllButtonElement, targetButtonIndex) ;
1431 this.expandAllButtonElement._button.textContent = WebInspector.UIStr ing("Show All Nodes (%d More)", childNodeCount - expandedChildCount); 1431 this.expandAllButtonElement._button.textContent = WebInspector.UIStr ing("Show All Nodes (%d More)", childNodeCount - expandedChildCount);
1432 } else if (this.expandAllButtonElement) 1432 } else if (this.expandAllButtonElement)
1433 delete this.expandAllButtonElement; 1433 delete this.expandAllButtonElement;
1434 }, 1434 },
1435 1435
1436 handleLoadAllChildren: function() 1436 handleLoadAllChildren: function()
1437 { 1437 {
1438 this.expandedChildrenLimit = Math.max(this._visibleChildCount(), this.ex pandedChildrenLimit + WebInspector.ElementsTreeElement.InitialChildrenLimit); 1438 var visibleChildCount = this._visibleChildren().length;
1439 this.expandedChildrenLimit = Math.max(visibleChildCount, this.expandedCh ildrenLimit + WebInspector.ElementsTreeElement.InitialChildrenLimit);
1439 }, 1440 },
1440 1441
1441 expandRecursively: function() 1442 expandRecursively: function()
1442 { 1443 {
1443 /** 1444 /**
1444 * @this {WebInspector.ElementsTreeElement} 1445 * @this {WebInspector.ElementsTreeElement}
1445 */ 1446 */
1446 function callback() 1447 function callback()
1447 { 1448 {
1448 TreeElement.prototype.expandRecursively.call(this, Number.MAX_VALUE) ; 1449 TreeElement.prototype.expandRecursively.call(this, Number.MAX_VALUE) ;
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after
2722 /** 2723 /**
2723 * @return {!Array.<!WebInspector.DOMNode>} visibleChildren 2724 * @return {!Array.<!WebInspector.DOMNode>} visibleChildren
2724 */ 2725 */
2725 _visibleChildren: function() 2726 _visibleChildren: function()
2726 { 2727 {
2727 var visibleChildren = this._visibleShadowRoots(); 2728 var visibleChildren = this._visibleShadowRoots();
2728 if (this._node.importedDocument()) 2729 if (this._node.importedDocument())
2729 visibleChildren.push(this._node.importedDocument()); 2730 visibleChildren.push(this._node.importedDocument());
2730 if (this._node.templateContent()) 2731 if (this._node.templateContent())
2731 visibleChildren.push(this._node.templateContent()); 2732 visibleChildren.push(this._node.templateContent());
2732 var pseudoElements = this._node.pseudoElements(); 2733 var beforePseudoElement = this._node.beforePseudoElement();
2733 if (pseudoElements[WebInspector.DOMNode.PseudoElementNames.Before]) 2734 if (beforePseudoElement)
2734 visibleChildren.push(pseudoElements[WebInspector.DOMNode.PseudoEleme ntNames.Before]); 2735 visibleChildren.push(beforePseudoElement);
2735 if (this._node.childNodeCount()) 2736 if (this._node.childNodeCount())
2736 visibleChildren = visibleChildren.concat(this._node.children()); 2737 visibleChildren = visibleChildren.concat(this._node.children());
2737 if (pseudoElements[WebInspector.DOMNode.PseudoElementNames.After]) 2738 var afterPseudoElement = this._node.afterPseudoElement();
2738 visibleChildren.push(pseudoElements[WebInspector.DOMNode.PseudoEleme ntNames.After]); 2739 if (afterPseudoElement)
2740 visibleChildren.push(afterPseudoElement);
2739 return visibleChildren; 2741 return visibleChildren;
2740 }, 2742 },
2741 2743
2742 /** 2744 /**
2743 * @return {number} 2745 * @return {boolean}
2744 */ 2746 */
2745 _visibleChildCount: function() 2747 _hasVisibleChildren: function()
2746 { 2748 {
2747 var childCount = this._node.childNodeCount() + this._visibleShadowRoots( ).length;
2748 if (this._node.importedDocument()) 2749 if (this._node.importedDocument())
2749 ++childCount; 2750 return true;
2750 if (this._node.templateContent()) 2751 if (this._node.templateContent())
2751 ++childCount; 2752 return true;
2752 for (var pseudoType in this._node.pseudoElements()) 2753 if (this._node.childNodeCount())
2753 ++childCount; 2754 return true;
2754 return childCount; 2755 if (this._visibleShadowRoots().length)
2756 return true;
2757 if (this._node.hasPseudoElements())
2758 return true;
2759 return false;
2755 }, 2760 },
2756 2761
2757 /** 2762 /**
2758 * @return {boolean} 2763 * @return {boolean}
2759 */ 2764 */
2760 _hasChildTreeElements: function() 2765 _hasChildTreeElements: function()
2761 { 2766 {
2762 return this._childrenDisplayMode === WebInspector.ElementsTreeElement.Ch ildrenDisplayMode.HasChildren; 2767 return this._childrenDisplayMode === WebInspector.ElementsTreeElement.Ch ildrenDisplayMode.HasChildren;
2763 }, 2768 },
2764 2769
(...skipping 11 matching lines...) Expand all
2776 var textChild = this._node.firstChild; 2781 var textChild = this._node.firstChild;
2777 var maxInlineTextChildLength = 80; 2782 var maxInlineTextChildLength = 80;
2778 if (textChild.nodeValue().length < maxInlineTextChildLength) 2783 if (textChild.nodeValue().length < maxInlineTextChildLength)
2779 return true; 2784 return true;
2780 return false; 2785 return false;
2781 }, 2786 },
2782 2787
2783 _updateChildrenDisplayMode: function() 2788 _updateChildrenDisplayMode: function()
2784 { 2789 {
2785 var showInlineText = this._canShowInlineText(); 2790 var showInlineText = this._canShowInlineText();
2786 var hasChildren = !this._elementCloseTag && this._visibleChildCount() > 0; 2791 var hasChildren = !this._elementCloseTag && this._hasVisibleChildren();
2787 2792
2788 if (showInlineText) 2793 if (showInlineText)
2789 this._childrenDisplayMode = WebInspector.ElementsTreeElement.Childre nDisplayMode.InlineText; 2794 this._childrenDisplayMode = WebInspector.ElementsTreeElement.Childre nDisplayMode.InlineText;
2790 else if (hasChildren) 2795 else if (hasChildren)
2791 this._childrenDisplayMode = WebInspector.ElementsTreeElement.Childre nDisplayMode.HasChildren; 2796 this._childrenDisplayMode = WebInspector.ElementsTreeElement.Childre nDisplayMode.HasChildren;
2792 else 2797 else
2793 this._childrenDisplayMode = WebInspector.ElementsTreeElement.Childre nDisplayMode.NoChildren; 2798 this._childrenDisplayMode = WebInspector.ElementsTreeElement.Childre nDisplayMode.NoChildren;
2794 2799
2795 this.setHasChildren(this._childrenDisplayMode === WebInspector.ElementsT reeElement.ChildrenDisplayMode.HasChildren); 2800 this.setHasChildren(this._childrenDisplayMode === WebInspector.ElementsT reeElement.ChildrenDisplayMode.HasChildren);
2796 }, 2801 },
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
3158 treeOutline.rootDOMNode = node; 3163 treeOutline.rootDOMNode = node;
3159 if (!treeOutline.children[0].hasChildren) 3164 if (!treeOutline.children[0].hasChildren)
3160 treeOutline._element.classList.add("single-node"); 3165 treeOutline._element.classList.add("single-node");
3161 treeOutline.setVisible(true); 3166 treeOutline.setVisible(true);
3162 treeOutline.element.treeElementForTest = treeOutline.children[0] ; 3167 treeOutline.element.treeElementForTest = treeOutline.children[0] ;
3163 resolve(treeOutline.element); 3168 resolve(treeOutline.element);
3164 } 3169 }
3165 } 3170 }
3166 } 3171 }
3167 } 3172 }
OLDNEW
« no previous file with comments | « LayoutTests/inspector/elements/styles/pseudo-elements.html ('k') | Source/devtools/front_end/sdk/DOMModel.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698