Web Inspector: Remove unnecessary hasChildren from TreeOutline
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jun 2017 02:16:05 +0000 (02:16 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 30 Jun 2017 02:16:05 +0000 (02:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173986

Reviewed by Joseph Pecoraro.

* UserInterface/Views/TreeOutline.js:
(WebInspector.TreeOutline):
(WebInspector.TreeOutline.prototype.appendChild):
(WebInspector.TreeOutline.prototype.insertChild):
(WebInspector.TreeOutline.prototype.removeChildAtIndex):
(WebInspector.TreeOutline.prototype.removeChild):
(WebInspector.TreeOutline.prototype.get selectedTreeElementIndex):

* UserInterface/Views/NavigationSidebarPanel.js:
(WebInspector.NavigationSidebarPanel.prototype._checkOutlinesForPendingViewStateCookie):
* UserInterface/Views/VisualStyleCommaSeparatedKeywordEditor.js:
(WebInspector.VisualStyleCommaSeparatedKeywordEditor.prototype.get value):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218983 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/TreeOutline.js
Source/WebInspectorUI/UserInterface/Views/VisualStyleCommaSeparatedKeywordEditor.js

index abe334d..d382bf6 100644 (file)
@@ -1,5 +1,25 @@
 2017-06-29  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: Remove unnecessary hasChildren from TreeOutline
+        https://bugs.webkit.org/show_bug.cgi?id=173986
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Views/TreeOutline.js:
+        (WebInspector.TreeOutline):
+        (WebInspector.TreeOutline.prototype.appendChild):
+        (WebInspector.TreeOutline.prototype.insertChild):
+        (WebInspector.TreeOutline.prototype.removeChildAtIndex):
+        (WebInspector.TreeOutline.prototype.removeChild):
+        (WebInspector.TreeOutline.prototype.get selectedTreeElementIndex):
+
+        * UserInterface/Views/NavigationSidebarPanel.js:
+        (WebInspector.NavigationSidebarPanel.prototype._checkOutlinesForPendingViewStateCookie):
+        * UserInterface/Views/VisualStyleCommaSeparatedKeywordEditor.js:
+        (WebInspector.VisualStyleCommaSeparatedKeywordEditor.prototype.get value):
+
+2017-06-29  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: Cleanup unused/invalid parameters for SidebarPanels
         https://bugs.webkit.org/show_bug.cgi?id=173985
 
index bcf1bf4..9eb7d6a 100644 (file)
@@ -645,7 +645,7 @@ WebInspector.NavigationSidebarPanel = class NavigationSidebarPanel extends WebIn
 
         var visibleTreeElements = [];
         this.contentTreeOutlines.forEach(function(outline) {
-            var currentTreeElement = outline.hasChildren ? outline.children[0] : null;
+            var currentTreeElement = outline.children.length ? outline.children[0] : null;
             while (currentTreeElement) {
                 visibleTreeElements.push(currentTreeElement);
                 currentTreeElement = currentTreeElement.traverseNextTreeElement(false, null, false);
index 9e68275..8a6be4d 100644 (file)
@@ -44,7 +44,6 @@ WebInspector.TreeOutline = class TreeOutline extends WebInspector.Object
         this._treeElementsExpandedState = [];
         this.allowsRepeatSelection = false;
         this.root = true;
-        this.hasChildren = false;
         this.expanded = true;
         this.selected = false;
         this.treeOutline = this;
@@ -156,7 +155,6 @@ WebInspector.TreeOutline = class TreeOutline extends WebInspector.Object
         var isFirstChild = !this.children.length;
 
         this.children.push(child);
-        this.hasChildren = true;
         child.parent = this;
         child.treeOutline = this.treeOutline;
         child.treeOutline._rememberTreeElement(child);
@@ -206,7 +204,6 @@ WebInspector.TreeOutline = class TreeOutline extends WebInspector.Object
         var isFirstChild = !this.children.length;
 
         this.children.splice(index, 0, child);
-        this.hasChildren = true;
         child.parent = this;
         child.treeOutline = this.treeOutline;
         child.treeOutline._rememberTreeElement(child);
@@ -267,6 +264,9 @@ WebInspector.TreeOutline = class TreeOutline extends WebInspector.Object
         child.nextSibling = null;
         child.previousSibling = null;
 
+        if (!this.children.length && this._listItemNode)
+            this._listItemNode.classList.remove("parent");
+
         if (treeOutline)
             treeOutline.dispatchEventToListeners(WebInspector.TreeOutline.Event.ElementRemoved, {element: child});
     }
@@ -283,12 +283,6 @@ WebInspector.TreeOutline = class TreeOutline extends WebInspector.Object
             return;
 
         this.removeChildAtIndex(childIndex, suppressOnDeselect, suppressSelectSibling);
-
-        if (!this.children.length) {
-            if (this._listItemNode)
-                this._listItemNode.classList.remove("parent");
-            this.hasChildren = false;
-        }
     }
 
     removeChildren(suppressOnDeselect)
@@ -622,7 +616,7 @@ WebInspector.TreeOutline = class TreeOutline extends WebInspector.Object
 
     get selectedTreeElementIndex()
     {
-        if (!this.hasChildren || !this.selectedTreeElement)
+        if (!this.children.length || !this.selectedTreeElement)
             return;
 
         for (var i = 0; i < this.children.length; ++i) {
index 02a0334..3d40e0d 100644 (file)
@@ -68,7 +68,7 @@ WebInspector.VisualStyleCommaSeparatedKeywordEditor = class VisualStyleCommaSepa
 
     get value()
     {
-        if (!this._commaSeparatedKeywords.hasChildren)
+        if (!this._commaSeparatedKeywords.children.length)
             return "";
 
         let value = "";