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

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

Issue 944343002: DevTools: migrate treeoutline from hasChildren to is/setExpandable(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 if (parentTreeElement.populated) 1410 if (parentTreeElement.populated)
1411 this.updateChildren(parentTreeElement); 1411 this.updateChildren(parentTreeElement);
1412 } 1412 }
1413 }, 1413 },
1414 1414
1415 /** 1415 /**
1416 * @param {!WebInspector.ElementsTreeElement} treeElement 1416 * @param {!WebInspector.ElementsTreeElement} treeElement
1417 */ 1417 */
1418 populateTreeElement: function(treeElement) 1418 populateTreeElement: function(treeElement)
1419 { 1419 {
1420 if (treeElement.childCount() || !treeElement.hasChildren) 1420 if (treeElement.childCount() || !treeElement.isExpandable())
1421 return; 1421 return;
1422 1422
1423 this._updateModifiedParentNode(treeElement.node()); 1423 this._updateModifiedParentNode(treeElement.node());
1424 }, 1424 },
1425 1425
1426 /** 1426 /**
1427 * @param {!WebInspector.DOMNode} node 1427 * @param {!WebInspector.DOMNode} node
1428 * @param {boolean=} closingTag 1428 * @param {boolean=} closingTag
1429 * @return {!WebInspector.ElementsTreeElement} 1429 * @return {!WebInspector.ElementsTreeElement}
1430 */ 1430 */
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1703 return hasChildren ? WebInspector.ElementsTreeElement.ChildrenDisplayMod e.HasChildren : WebInspector.ElementsTreeElement.ChildrenDisplayMode.NoChildren; 1703 return hasChildren ? WebInspector.ElementsTreeElement.ChildrenDisplayMod e.HasChildren : WebInspector.ElementsTreeElement.ChildrenDisplayMode.NoChildren;
1704 }, 1704 },
1705 1705
1706 /** 1706 /**
1707 * @param {!WebInspector.ElementsTreeElement} treeElement 1707 * @param {!WebInspector.ElementsTreeElement} treeElement
1708 */ 1708 */
1709 _updateChildrenDisplayMode: function(treeElement) 1709 _updateChildrenDisplayMode: function(treeElement)
1710 { 1710 {
1711 var childrenDisplayMode = this._calculateChildrenDisplayMode(treeElement ); 1711 var childrenDisplayMode = this._calculateChildrenDisplayMode(treeElement );
1712 treeElement.setChildrenDisplayMode(childrenDisplayMode); 1712 treeElement.setChildrenDisplayMode(childrenDisplayMode);
1713 treeElement.setHasChildren(childrenDisplayMode === WebInspector.Elements TreeElement.ChildrenDisplayMode.HasChildren); 1713 treeElement.setExpandable(childrenDisplayMode === WebInspector.ElementsT reeElement.ChildrenDisplayMode.HasChildren);
1714 }, 1714 },
1715 1715
1716 /** 1716 /**
1717 * @param {!WebInspector.ElementsTreeElement} treeElement 1717 * @param {!WebInspector.ElementsTreeElement} treeElement
1718 */ 1718 */
1719 _createExpandAllButtonTreeElement: function(treeElement) 1719 _createExpandAllButtonTreeElement: function(treeElement)
1720 { 1720 {
1721 var button = createTextButton("", handleLoadAllChildren.bind(this)); 1721 var button = createTextButton("", handleLoadAllChildren.bind(this));
1722 button.value = ""; 1722 button.value = "";
1723 var expandAllButtonElement = new TreeElement(button); 1723 var expandAllButtonElement = new TreeElement(button);
(...skipping 26 matching lines...) Expand all
1750 treeElement.setExpandedChildrenLimit(expandedChildrenLimit); 1750 treeElement.setExpandedChildrenLimit(expandedChildrenLimit);
1751 if (treeElement.treeOutline && !this._treeElementsBeingUpdated.has(treeE lement)) 1751 if (treeElement.treeOutline && !this._treeElementsBeingUpdated.has(treeE lement))
1752 this._updateModifiedParentNode(treeElement.node()); 1752 this._updateModifiedParentNode(treeElement.node());
1753 }, 1753 },
1754 1754
1755 /** 1755 /**
1756 * @param {!WebInspector.ElementsTreeElement} treeElement 1756 * @param {!WebInspector.ElementsTreeElement} treeElement
1757 */ 1757 */
1758 updateChildren: function(treeElement) 1758 updateChildren: function(treeElement)
1759 { 1759 {
1760 if (!treeElement.hasChildren) { 1760 if (!treeElement.isExpandable()) {
1761 var selectedTreeElement = treeElement.treeOutline.selectedTreeElemen t; 1761 var selectedTreeElement = treeElement.treeOutline.selectedTreeElemen t;
1762 if (selectedTreeElement && selectedTreeElement.hasAncestor(treeEleme nt)) 1762 if (selectedTreeElement && selectedTreeElement.hasAncestor(treeEleme nt))
1763 treeElement.select(); 1763 treeElement.select();
1764 treeElement.removeChildren(); 1764 treeElement.removeChildren();
1765 return; 1765 return;
1766 } 1766 }
1767 console.assert(!treeElement.isClosingTag()); 1767 console.assert(!treeElement.isClosingTag());
1768 1768
1769 var barrier = new CallbackBarrier(); 1769 var barrier = new CallbackBarrier();
1770 treeElement.node().getChildNodes(childNodesLoaded.bind(null, barrier.cre ateCallback())); 1770 treeElement.node().getChildNodes(childNodesLoaded.bind(null, barrier.cre ateCallback()));
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1879 var targetButtonIndex = expandedChildCount; 1879 var targetButtonIndex = expandedChildCount;
1880 if (!treeElement.expandAllButtonElement) 1880 if (!treeElement.expandAllButtonElement)
1881 treeElement.expandAllButtonElement = this._createExpandAllButton TreeElement(treeElement); 1881 treeElement.expandAllButtonElement = this._createExpandAllButton TreeElement(treeElement);
1882 treeElement.insertChild(treeElement.expandAllButtonElement, targetBu ttonIndex); 1882 treeElement.insertChild(treeElement.expandAllButtonElement, targetBu ttonIndex);
1883 treeElement.expandAllButtonElement.button.textContent = WebInspector .UIString("Show All Nodes (%d More)", visibleChildren.length - expandedChildCoun t); 1883 treeElement.expandAllButtonElement.button.textContent = WebInspector .UIString("Show All Nodes (%d More)", visibleChildren.length - expandedChildCoun t);
1884 } else if (treeElement.expandAllButtonElement) { 1884 } else if (treeElement.expandAllButtonElement) {
1885 delete treeElement.expandAllButtonElement; 1885 delete treeElement.expandAllButtonElement;
1886 } 1886 }
1887 1887
1888 // Insert close tag. 1888 // Insert close tag.
1889 if (node.nodeType() === Node.ELEMENT_NODE && treeElement.hasChildren) 1889 if (node.nodeType() === Node.ELEMENT_NODE && treeElement.isExpandable())
1890 this.insertChildElement(treeElement, node, treeElement.childCount(), true); 1890 this.insertChildElement(treeElement, node, treeElement.childCount(), true);
1891 1891
1892 this._treeElementsBeingUpdated.delete(treeElement); 1892 this._treeElementsBeingUpdated.delete(treeElement);
1893 }, 1893 },
1894 1894
1895 /** 1895 /**
1896 * @param {!WebInspector.DOMNode} shadowHost 1896 * @param {!WebInspector.DOMNode} shadowHost
1897 * @param {?WebInspector.ElementsTreeOutline.ShadowHostDisplayMode} newMode 1897 * @param {?WebInspector.ElementsTreeOutline.ShadowHostDisplayMode} newMode
1898 */ 1898 */
1899 setShadowHostDisplayMode: function(shadowHost, newMode) 1899 setShadowHostDisplayMode: function(shadowHost, newMode)
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
2161 * @param {?WebInspector.DOMNode} node 2161 * @param {?WebInspector.DOMNode} node
2162 */ 2162 */
2163 function onNodeResolved(node) 2163 function onNodeResolved(node)
2164 { 2164 {
2165 if (!node) { 2165 if (!node) {
2166 reject(new Error("Could not resolve node.")); 2166 reject(new Error("Could not resolve node."));
2167 return; 2167 return;
2168 } 2168 }
2169 var treeOutline = new WebInspector.ElementsTreeOutline(node.targ et(), false, false); 2169 var treeOutline = new WebInspector.ElementsTreeOutline(node.targ et(), false, false);
2170 treeOutline.rootDOMNode = node; 2170 treeOutline.rootDOMNode = node;
2171 if (!treeOutline.firstChild().hasChildren) 2171 if (!treeOutline.firstChild().isExpandable())
2172 treeOutline._element.classList.add("single-node"); 2172 treeOutline._element.classList.add("single-node");
2173 treeOutline.setVisible(true); 2173 treeOutline.setVisible(true);
2174 treeOutline.element.treeElementForTest = treeOutline.firstChild( ); 2174 treeOutline.element.treeElementForTest = treeOutline.firstChild( );
2175 resolve(treeOutline.element); 2175 resolve(treeOutline.element);
2176 } 2176 }
2177 } 2177 }
2178 } 2178 }
2179 } 2179 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698