Web Inspector: Reorder Debugger tab sidebar panels: Scope Chain, Resource, Probes
authormattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Apr 2017 18:50:05 +0000 (18:50 +0000)
committermattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Apr 2017 18:50:05 +0000 (18:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=170418
<rdar://problem/31410771>

Reviewed by Timothy Hatcher.

Maintain the sidebar panel order defined by TabContentView when adding
and removing panels.

* UserInterface/Views/ContentBrowserTabContentView.js:
(WebInspector.ContentBrowserTabContentView.prototype.showDetailsSidebarPanels):
Insert sidebar panel based on the panel order defined by TabContentView.

* UserInterface/Views/DebuggerTabContentView.js:
(WebInspector.DebuggerTabContentView):

* UserInterface/Views/Sidebar.js:
(WebInspector.Sidebar.prototype.addSidebarPanel):
Implemented as an insert at the end.
(WebInspector.Sidebar.prototype.insertSidebarPanel):
Allow inserting into the sidebar panel collection.
(WebInspector.Sidebar.prototype.removeSidebarPanel):
Remove unused return value.

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

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

index a2e7c2f..e5c3da0 100644 (file)
@@ -1,3 +1,29 @@
+2017-04-06  Matt Baker  <mattbaker@apple.com>
+
+        Web Inspector: Reorder Debugger tab sidebar panels: Scope Chain, Resource, Probes
+        https://bugs.webkit.org/show_bug.cgi?id=170418
+        <rdar://problem/31410771>
+
+        Reviewed by Timothy Hatcher.
+
+        Maintain the sidebar panel order defined by TabContentView when adding
+        and removing panels.
+
+        * UserInterface/Views/ContentBrowserTabContentView.js:
+        (WebInspector.ContentBrowserTabContentView.prototype.showDetailsSidebarPanels):
+        Insert sidebar panel based on the panel order defined by TabContentView.
+
+        * UserInterface/Views/DebuggerTabContentView.js:
+        (WebInspector.DebuggerTabContentView):
+
+        * UserInterface/Views/Sidebar.js:
+        (WebInspector.Sidebar.prototype.addSidebarPanel):
+        Implemented as an insert at the end.
+        (WebInspector.Sidebar.prototype.insertSidebarPanel):
+        Allow inserting into the sidebar panel collection.
+        (WebInspector.Sidebar.prototype.removeSidebarPanel):
+        Remove unused return value.
+
 2017-04-05  Matt Baker  <mattbaker@apple.com>
 
         Web Inspector: Probe values not showing in sidebar
index 7814893..e8d82aa 100644 (file)
@@ -142,6 +142,8 @@ WebInspector.ContentBrowserTabContentView = class ContentBrowserTabContentView e
         this._ignoreDetailsSidebarPanelSelectedEvent = true;
         this._ignoreDetailsSidebarPanelCollapsedEvent = true;
 
+        let hiddenSidebarPanels = 0;
+
         for (var i = 0; i < this.detailsSidebarPanels.length; ++i) {
             var sidebarPanel = this.detailsSidebarPanels[i];
             if (sidebarPanel.inspect(currentRepresentedObjects)) {
@@ -151,7 +153,8 @@ WebInspector.ContentBrowserTabContentView = class ContentBrowserTabContentView e
                 }
 
                 // The sidebar panel was not previously showing, so add the panel.
-                WebInspector.detailsSidebar.addSidebarPanel(sidebarPanel);
+                let index = i - hiddenSidebarPanels;
+                WebInspector.detailsSidebar.insertSidebarPanel(sidebarPanel, index);
 
                 if (this._lastSelectedDetailsSidebarPanelSetting.value === sidebarPanel.identifier) {
                     // Restore the sidebar panel selection if this sidebar panel was the last one selected by the user.
@@ -160,6 +163,7 @@ WebInspector.ContentBrowserTabContentView = class ContentBrowserTabContentView e
             } else {
                 // The sidebar panel can't inspect the current represented objects, so remove the panel and hide the toolbar item.
                 WebInspector.detailsSidebar.removeSidebarPanel(sidebarPanel);
+                hiddenSidebarPanels++;
             }
         }
 
index a15406d..dfbc4a0 100644 (file)
@@ -29,7 +29,7 @@ WebInspector.DebuggerTabContentView = class DebuggerTabContentView extends WebIn
     {
         let {image, title} = WebInspector.DebuggerTabContentView.tabInfo();
         let tabBarItem = new WebInspector.GeneralTabBarItem(image, title);
-        let detailsSidebarPanels = [WebInspector.resourceDetailsSidebarPanel, WebInspector.scopeChainDetailsSidebarPanel, WebInspector.probeDetailsSidebarPanel];
+        let detailsSidebarPanels = [WebInspector.scopeChainDetailsSidebarPanel, WebInspector.resourceDetailsSidebarPanel, WebInspector.probeDetailsSidebarPanel];
 
         super(identifier || "debugger", "debugger", tabBarItem, WebInspector.DebuggerSidebarPanel, detailsSidebarPanels);
     }
index 33b7b73..421e962 100644 (file)
@@ -62,32 +62,38 @@ WebInspector.Sidebar = class Sidebar extends WebInspector.View
 
     addSidebarPanel(sidebarPanel)
     {
+        this.insertSidebarPanel(sidebarPanel, this._sidebarPanels.length);
+    }
+
+    insertSidebarPanel(sidebarPanel, index)
+    {
         console.assert(sidebarPanel instanceof WebInspector.SidebarPanel);
         if (!(sidebarPanel instanceof WebInspector.SidebarPanel))
-            return null;
+            return;
 
         console.assert(!sidebarPanel.parentSidebar);
         if (sidebarPanel.parentSidebar)
-            return null;
+            return;
+
+        console.assert(index >= 0 && index <= this._sidebarPanels.length);
+        this._sidebarPanels.splice(index, 0, sidebarPanel);
 
-        this._sidebarPanels.push(sidebarPanel);
-        this.addSubview(sidebarPanel);
+        let referenceView = this._sidebarPanels[index + 1] || null;
+        this.insertSubviewBefore(sidebarPanel, referenceView);
 
         if (this._navigationBar) {
             console.assert(sidebarPanel.navigationItem);
-            this._navigationBar.addNavigationItem(sidebarPanel.navigationItem);
+            this._navigationBar.insertNavigationItem(sidebarPanel.navigationItem, index);
         }
 
         sidebarPanel.added();
-
-        return sidebarPanel;
     }
 
     removeSidebarPanel(sidebarPanelOrIdentifierOrIndex)
     {
         var sidebarPanel = this.findSidebarPanel(sidebarPanelOrIdentifierOrIndex);
         if (!sidebarPanel)
-            return null;
+            return;
 
         sidebarPanel.selected = false;
 
@@ -110,8 +116,6 @@ WebInspector.Sidebar = class Sidebar extends WebInspector.View
         }
 
         sidebarPanel.removed();
-
-        return sidebarPanel;
     }
 
     get selectedSidebarPanel()