Web Inspector: sidebar panels shouldn't be added as subviews unless visible
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Apr 2019 17:27:27 +0000 (17:27 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Apr 2019 17:27:27 +0000 (17:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196888
<rdar://problem/49870659>

Reviewed by Timothy Hatcher.

* UserInterface/Views/Sidebar.js:
(WI.Sidebar.prototype.insertSidebarPanel):
(WI.Sidebar.prototype.removeSidebarPanel):
(WI.Sidebar.prototype.set selectedSidebarPanel):

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/Sidebar.js

index a264098..663d007 100644 (file)
@@ -1,5 +1,18 @@
 2019-04-15  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: sidebar panels shouldn't be added as subviews unless visible
+        https://bugs.webkit.org/show_bug.cgi?id=196888
+        <rdar://problem/49870659>
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Views/Sidebar.js:
+        (WI.Sidebar.prototype.insertSidebarPanel):
+        (WI.Sidebar.prototype.removeSidebarPanel):
+        (WI.Sidebar.prototype.set selectedSidebarPanel):
+
+2019-04-15  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: Elements: event listener change events should only be fired for the selected node and it's ancestors
         https://bugs.webkit.org/show_bug.cgi?id=196887
         <rdar://problem/49870627>
index 856aa1e..3768485 100644 (file)
@@ -78,9 +78,6 @@ WI.Sidebar = class Sidebar extends WI.View
         console.assert(index >= 0 && index <= this._sidebarPanels.length);
         this._sidebarPanels.splice(index, 0, sidebarPanel);
 
-        let referenceView = this._sidebarPanels[index + 1] || null;
-        this.insertSubviewBefore(sidebarPanel, referenceView);
-
         if (this._navigationBar) {
             console.assert(sidebarPanel.navigationItem);
             this._navigationBar.insertNavigationItem(sidebarPanel.navigationItem, index);
@@ -106,7 +103,6 @@ WI.Sidebar = class Sidebar extends WI.View
         }
 
         this._sidebarPanels.remove(sidebarPanel);
-        this.removeSubview(sidebarPanel);
 
         if (this._navigationBar) {
             console.assert(sidebarPanel.navigationItem);
@@ -126,12 +122,10 @@ WI.Sidebar = class Sidebar extends WI.View
             return;
 
         if (this._selectedSidebarPanel) {
-            if (this._selectedSidebarPanel.visible) {
-                this._selectedSidebarPanel.hidden();
-                this._selectedSidebarPanel.visibilityDidChange();
-            }
-
+            this._selectedSidebarPanel.hidden();
+            this._selectedSidebarPanel.visibilityDidChange();
             this._selectedSidebarPanel.selected = false;
+            this.removeSubview(this._selectedSidebarPanel);
         }
 
         this._selectedSidebarPanel = sidebarPanel || null;
@@ -140,12 +134,10 @@ WI.Sidebar = class Sidebar extends WI.View
             this._navigationBar.selectedNavigationItem = sidebarPanel ? sidebarPanel.navigationItem : null;
 
         if (this._selectedSidebarPanel) {
+            this.addSubview(this._selectedSidebarPanel);
             this._selectedSidebarPanel.selected = true;
-
-            if (this._selectedSidebarPanel.visible) {
-                this._selectedSidebarPanel.shown();
-                this._selectedSidebarPanel.visibilityDidChange();
-            }
+            this._selectedSidebarPanel.shown();
+            this._selectedSidebarPanel.visibilityDidChange();
         }
 
         this.dispatchEventToListeners(WI.Sidebar.Event.SidebarPanelSelected);