Web Inspector: Storage tab navigation bar should fit on a single line
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Jan 2016 01:40:24 +0000 (01:40 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Jan 2016 01:40:24 +0000 (01:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=152473

Patch by Devin Rousso <dcrousso+webkit@gmail.com> on 2016-01-11
Reviewed by Timothy Hatcher.

The wrapping of the navigation bar on the Storage tab was caused by the
fact that Sidebar.js used a minimum width of 200px, regardless of the
content within the sidebar (unless it had a NavigationBar). Logic has
been added that causes the sidebar to use the selected panel's own
minimum width calculation if it is greater than 200px.

* UserInterface/Views/DebuggerSidebarPanel.js:
(WebInspector.DebuggerSidebarPanel.prototype.get minimumWidth):

* UserInterface/Views/MultipleScopeBarItem.js:
(WebInspector.MultipleScopeBarItem.prototype.set selectedScopeBarItem):
(WebInspector.MultipleScopeBarItem.prototype.displaySelectedItem):
Sets the displayed text to the currently selected item.

(WebInspector.MultipleScopeBarItem.prototype.displayWidestItem):
Sets the displayed text to the widest (pixel wise) item in the select element.

* UserInterface/Views/NavigationBar.js:
(WebInspector.NavigationBar.prototype._calculateMinimumWidth):
Now uses NavigationItem.prototype.get minimumWidth.

* UserInterface/Views/NavitationItem.js:
(WebInspector.NavitationItem.prototype.get minimumWidth):
Returns the element's realOffsetWidth.

* UserInterface/Views/NetworkSidebarPanel.js:
(WebInspector.NetworkSidebarPanel.prototype.get minimumWidth):

* UserInterface/Views/ResourceSidebarPanel.js:
(WebInspector.ResourceSidebarPanel.prototype.get minimumWidth):

* UserInterface/Views/ScopeBar.js:
(WebInspector.ScopeBar):
(WebInspector.ScopeBar.prototype.get minimumWidth):

* UserInterface/Views/Sidebar.js:
(WebInspector.Sidebar.prototype.set selectedSidebarPanel):
(WebInspector.Sidebar.prototype.get minimumWidth):
(WebInspector.Sidebar.prototype.set width):
(WebInspector.Sidebar.prototype.set collapsed):
(WebInspector.Sidebar.prototype._recalculateWidth):
Whenever the sidebar changes (e.g. tab change, sidebar becomes
visible/hidden, etc.), a width recalculation is necessary to ensure
that the navigation bar never wraps.

* UserInterface/Views/SidebarPanel.js:
(WebInspector.SidebarPanel.prototype.get minimumWidth):

* UserInterface/Views/StorageSidebarPanel.js:
(WebInspector.StorageSidebarPanel.prototype.get minimumWidth):

* UserInterface/Views/TimelineSidebarPanel.js:
(WebInspector.TimelineSidebarPanel.prototype.get minimumWidth):

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

12 files changed:
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/MultipleScopeBarItem.js
Source/WebInspectorUI/UserInterface/Views/NavigationBar.js
Source/WebInspectorUI/UserInterface/Views/NavigationItem.js
Source/WebInspectorUI/UserInterface/Views/NetworkSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/ScopeBar.js
Source/WebInspectorUI/UserInterface/Views/Sidebar.js
Source/WebInspectorUI/UserInterface/Views/SidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/StorageSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/TimelineSidebarPanel.js

index ecebb92..45655a2 100644 (file)
@@ -1,5 +1,66 @@
 2016-01-11  Devin Rousso  <dcrousso+webkit@gmail.com>
 
+        Web Inspector: Storage tab navigation bar should fit on a single line
+        https://bugs.webkit.org/show_bug.cgi?id=152473
+
+        Reviewed by Timothy Hatcher.
+
+        The wrapping of the navigation bar on the Storage tab was caused by the
+        fact that Sidebar.js used a minimum width of 200px, regardless of the
+        content within the sidebar (unless it had a NavigationBar). Logic has
+        been added that causes the sidebar to use the selected panel's own
+        minimum width calculation if it is greater than 200px.
+
+        * UserInterface/Views/DebuggerSidebarPanel.js:
+        (WebInspector.DebuggerSidebarPanel.prototype.get minimumWidth):
+
+        * UserInterface/Views/MultipleScopeBarItem.js:
+        (WebInspector.MultipleScopeBarItem.prototype.set selectedScopeBarItem):
+        (WebInspector.MultipleScopeBarItem.prototype.displaySelectedItem):
+        Sets the displayed text to the currently selected item.
+
+        (WebInspector.MultipleScopeBarItem.prototype.displayWidestItem):
+        Sets the displayed text to the widest (pixel wise) item in the select element.
+
+        * UserInterface/Views/NavigationBar.js:
+        (WebInspector.NavigationBar.prototype._calculateMinimumWidth):
+        Now uses NavigationItem.prototype.get minimumWidth.
+
+        * UserInterface/Views/NavitationItem.js:
+        (WebInspector.NavitationItem.prototype.get minimumWidth):
+        Returns the element's realOffsetWidth.
+
+        * UserInterface/Views/NetworkSidebarPanel.js:
+        (WebInspector.NetworkSidebarPanel.prototype.get minimumWidth):
+
+        * UserInterface/Views/ResourceSidebarPanel.js:
+        (WebInspector.ResourceSidebarPanel.prototype.get minimumWidth):
+
+        * UserInterface/Views/ScopeBar.js:
+        (WebInspector.ScopeBar):
+        (WebInspector.ScopeBar.prototype.get minimumWidth):
+
+        * UserInterface/Views/Sidebar.js:
+        (WebInspector.Sidebar.prototype.set selectedSidebarPanel):
+        (WebInspector.Sidebar.prototype.get minimumWidth):
+        (WebInspector.Sidebar.prototype.set width):
+        (WebInspector.Sidebar.prototype.set collapsed):
+        (WebInspector.Sidebar.prototype._recalculateWidth):
+        Whenever the sidebar changes (e.g. tab change, sidebar becomes
+        visible/hidden, etc.), a width recalculation is necessary to ensure
+        that the navigation bar never wraps.
+
+        * UserInterface/Views/SidebarPanel.js:
+        (WebInspector.SidebarPanel.prototype.get minimumWidth):
+
+        * UserInterface/Views/StorageSidebarPanel.js:
+        (WebInspector.StorageSidebarPanel.prototype.get minimumWidth):
+
+        * UserInterface/Views/TimelineSidebarPanel.js:
+        (WebInspector.TimelineSidebarPanel.prototype.get minimumWidth):
+
+2016-01-11  Devin Rousso  <dcrousso+webkit@gmail.com>
+
         Web Inspector: Make Timelines view also remember sort order
         https://bugs.webkit.org/show_bug.cgi?id=152811
 
index 5c54c75..1a4e2f5 100644 (file)
@@ -164,6 +164,11 @@ WebInspector.DebuggerSidebarPanel = class DebuggerSidebarPanel extends WebInspec
 
     // Public
 
+    get minimumWidth()
+    {
+        return this._navigationBar.minimumWidth;
+    }
+
     closed()
     {
         super.closed();
index 9fc648e..4fca0cf 100644 (file)
@@ -133,7 +133,7 @@ WebInspector.MultipleScopeBarItem = class MultipleScopeBarItem extends WebInspec
         this._selectElement.selectedIndex = this._scopeBarItems.indexOf(this._selectedScopeBarItem);
 
         if (this._selectedScopeBarItem) {
-            this._titleElement.textContent = this._selectedScopeBarItem.label;
+            this.displaySelectedItem();
             this._selectedScopeBarItem.selected = true;
         }
 
@@ -143,6 +143,25 @@ WebInspector.MultipleScopeBarItem = class MultipleScopeBarItem extends WebInspec
         this._ignoreItemSelectedEvent = false;
     }
 
+    displaySelectedItem()
+    {
+        this._titleElement.textContent = this._selectedScopeBarItem.label;
+    }
+
+    displayWidestItem()
+    {
+        let widestLabel = null;
+        let widestSize = 0;
+        for (let option of Array.from(this._selectElement.options)) {
+            this._titleElement.textContent = option.label;
+            if (this._titleElement.realOffsetWidth > widestSize) {
+                widestSize = this._titleElement.realOffsetWidth;
+                widestLabel = option.label;
+            }
+        }
+        this._titleElement.textContent = widestLabel;
+    }
+
     // Private
 
     _clicked(event)
index 8facf3b..547ba84 100644 (file)
@@ -361,12 +361,13 @@ WebInspector.NavigationBar = class NavigationBar extends WebInspector.View
         if (!wasCollapsed)
             this.element.classList.add(WebInspector.NavigationBar.CollapsedStyleClassName);
 
-        var totalItemWidth = 0;
-        for (var i = 0; i < this._navigationItems.length; ++i) {
+        let totalItemWidth = 0;
+        for (let item of this._navigationItems) {
             // Skip flexible space items since they can take up no space at the minimum width.
-            if (this._navigationItems[i] instanceof WebInspector.FlexibleSpaceNavigationItem)
+            if (item instanceof WebInspector.FlexibleSpaceNavigationItem)
                 continue;
-            totalItemWidth += this._navigationItems[i].element.realOffsetWidth;
+
+            totalItemWidth += item.minimumWidth;
         }
 
         // Remove the collapsed style class if we were not collapsed before.
index 1d76115..87bfdfa 100644 (file)
@@ -60,6 +60,11 @@ WebInspector.NavigationItem = class NavigationItem extends WebInspector.Object
         return this._parentNavigationBar;
     }
 
+    get minimumWidth()
+    {
+        return this._element.realOffsetWidth;
+    }
+
     updateLayout(expandOnly)
     {
         // Implemented by subclasses.
index 058b890..c1f0e42 100644 (file)
@@ -71,6 +71,11 @@ WebInspector.NetworkSidebarPanel = class NetworkSidebarPanel extends WebInspecto
 
     // Public
 
+    get minimumWidth()
+    {
+        return this._navigationBar.minimumWidth;
+    }
+
     closed()
     {
         super.closed();
index be2af8f..20c3b93 100644 (file)
@@ -75,6 +75,11 @@ WebInspector.ResourceSidebarPanel = class ResourceSidebarPanel extends WebInspec
 
     // Public
 
+    get minimumWidth()
+    {
+        return this._navigationBar.minimumWidth;
+    }
+
     closed()
     {
         super.closed();
index 3222015..ede6988 100644 (file)
@@ -35,11 +35,35 @@ WebInspector.ScopeBar = class ScopeBar extends WebInspector.NavigationItem
         this._defaultItem = defaultItem;
         this._shouldGroupNonExclusiveItems = shouldGroupNonExclusiveItems || false;
 
+        this._minimumWidth = 0;
+
         this._populate();
     }
 
     // Public
 
+    get minimumWidth()
+    {
+        if (!this._minimumWidth) {
+            // If a "display: flex;" element is too small for its contents and
+            // has "flex-wrap: wrap;" set as well, this will cause the contents
+            // to wrap (potentially overflowing), thus preventing a proper
+            // measurement of the width of the element. Removing the "flex-wrap"
+            // property will ensure that the contents are rendered on one line.
+            this.element.style.flexWrap = "initial !important";
+
+            if (this._multipleItem)
+                this._multipleItem.displayWidestItem();
+
+            this._minimumWidth = this.element.realOffsetWidth;
+            this.element.style.flexWrap = null;
+
+            if (this._multipleItem)
+                this._multipleItem.displaySelectedItem();
+        }
+        return this._minimumWidth;
+    }
+
     get defaultItem()
     {
         return this._defaultItem;
index 3670bd6..9653845 100644 (file)
@@ -147,6 +147,7 @@ WebInspector.Sidebar = class Sidebar extends WebInspector.View
             if (this._selectedSidebarPanel.visible) {
                 this._selectedSidebarPanel.shown();
                 this._selectedSidebarPanel.visibilityDidChange();
+                this._recalculateWidth();
             }
         }
 
@@ -157,6 +158,8 @@ WebInspector.Sidebar = class Sidebar extends WebInspector.View
     {
         if (this._navigationBar)
             return Math.max(WebInspector.Sidebar.AbsoluteMinimumWidth, this._navigationBar.minimumWidth);
+        if (this._selectedSidebarPanel)
+            return Math.max(WebInspector.Sidebar.AbsoluteMinimumWidth, this._selectedSidebarPanel.minimumWidth);
         return WebInspector.Sidebar.AbsoluteMinimumWidth;
     }
 
@@ -177,17 +180,7 @@ WebInspector.Sidebar = class Sidebar extends WebInspector.View
         if (newWidth === this.width)
             return;
 
-        newWidth = Math.max(this.minimumWidth, Math.min(newWidth, this.maximumWidth));
-
-        this.element.style.width = newWidth + "px";
-
-        if (!this.collapsed && this._navigationBar)
-            this._navigationBar.needsLayout();
-
-        if (!this.collapsed && this._selectedSidebarPanel)
-            this._selectedSidebarPanel.widthDidChange();
-
-        this.dispatchEventToListeners(WebInspector.Sidebar.Event.WidthDidChange);
+        this._recalculateWidth(newWidth);
     }
 
     get collapsed()
@@ -213,8 +206,8 @@ WebInspector.Sidebar = class Sidebar extends WebInspector.View
                 this._selectedSidebarPanel.hidden();
 
             this._selectedSidebarPanel.visibilityDidChange();
-
             this._selectedSidebarPanel.widthDidChange();
+            this._recalculateWidth();
         }
 
         this.dispatchEventToListeners(WebInspector.Sidebar.Event.CollapsedStateDidChange);
@@ -271,6 +264,21 @@ WebInspector.Sidebar = class Sidebar extends WebInspector.View
 
     // Private
 
+    _recalculateWidth(newWidth = this.width)
+    {
+        // Need to add 1 because of the 1px border-right.
+        newWidth = Number.constrain(newWidth, this.minimumWidth + 1, this.maximumWidth);
+        this.element.style.width = Math.ceil(newWidth) + "px";
+
+        if (!this.collapsed && this._navigationBar)
+            this._navigationBar.needsLayout();
+
+        if (!this.collapsed && this._selectedSidebarPanel)
+            this._selectedSidebarPanel.widthDidChange();
+
+        this.dispatchEventToListeners(WebInspector.Sidebar.Event.WidthDidChange);
+    }
+
     _navigationItemSelected(event)
     {
         this.selectedSidebarPanel = event.target.selectedNavigationItem ? event.target.selectedNavigationItem.identifier : null;
index 683cc8a..bce88eb 100644 (file)
@@ -81,6 +81,12 @@ WebInspector.SidebarPanel = class SidebarPanel extends WebInspector.View
         return this.parentView;
     }
 
+    get minimumWidth()
+    {
+        // Implemented by subclasses.
+        return 0;
+    }
+
     show()
     {
         if (!this.parentSidebar)
index f79ba42..b39011b 100644 (file)
@@ -106,6 +106,11 @@ WebInspector.StorageSidebarPanel = class StorageSidebarPanel extends WebInspecto
 
     // Public
 
+    get minimumWidth()
+    {
+        return this._navigationBar.minimumWidth;
+    }
+
     showDefaultContentView()
     {
         // Don't show anything by default. It doesn't make a whole lot of sense here.
index 8ac1231..715993d 100644 (file)
@@ -218,6 +218,13 @@ WebInspector.TimelineSidebarPanel = class TimelineSidebarPanel extends WebInspec
 
     // Public
 
+    get minimumWidth()
+    {
+        if (this._viewModeNavigationBar)
+            return Math.max(this._replayNavigationBar.minimumWidth, this._viewModeNavigationBar.minimumWidth);
+        return this._replayNavigationBar.minimumWidth;
+    }
+
     shown()
     {
         super.shown();