Changeset 279613 in webkit


Ignore:
Timestamp:
Jul 6, 2021 1:25:48 PM (13 months ago)
Author:
Patrick Angle
Message:

Web Inspector: Elements Tab Details Sidebar navigation items sometime wrap to a second line
https://bugs.webkit.org/show_bug.cgi?id=227707

Reviewed by Devin Rousso.

When resizing a sidebar, it was possible that the cumulative widths of each navigation item could add up to just
less than the actual amount of space necessary to lay out each item in a single row, leading to wrapping items
to the next line. This resolves that issue by taking the ceiling of each item's width when calculating the
total amount of space needed to display all the items. Additionally, every time a panel is added or removed from
the sidebar, we need to recalculate the width of the sidebar to make sure the new navigation item, or the
removal thereof, is accommodated.

  • UserInterface/Views/NavigationBar.js:

(WI.NavigationBar.prototype.layout.calculateVisibleItemWidth):
(WI.NavigationBar.prototype._calculateMinimumWidth):

  • UserInterface/Views/SingleSidebar.js:

(WI.SingleSidebar.prototype.didInsertSidebarPanel):
(WI.SingleSidebar.prototype.didRemoveSidebarPanel):

Location:
trunk/Source/WebInspectorUI
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r279510 r279613  
     12021-07-06  Patrick Angle  <pangle@apple.com>
     2
     3        Web Inspector: Elements Tab Details Sidebar navigation items sometime wrap to a second line
     4        https://bugs.webkit.org/show_bug.cgi?id=227707
     5
     6        Reviewed by Devin Rousso.
     7
     8        When resizing a sidebar, it was possible that the cumulative widths of each navigation item could add up to just
     9        less than the actual amount of space necessary to lay out each item in a single row, leading to wrapping items
     10        to the next line. This resolves that issue by taking the ceiling of each item's width when calculating the
     11        total amount of space needed to display all the items. Additionally, every time a panel is added or removed from
     12        the sidebar, we need to recalculate the width of the sidebar to make sure the new navigation item, or the
     13        removal thereof, is accommodated.
     14
     15        * UserInterface/Views/NavigationBar.js:
     16        (WI.NavigationBar.prototype.layout.calculateVisibleItemWidth):
     17        (WI.NavigationBar.prototype._calculateMinimumWidth):
     18        * UserInterface/Views/SingleSidebar.js:
     19        (WI.SingleSidebar.prototype.didInsertSidebarPanel):
     20        (WI.SingleSidebar.prototype.didRemoveSidebarPanel):
     21
    1222021-07-02  Harshil Ratnu  <hratnu@apple.com>
    223
  • trunk/Source/WebInspectorUI/UserInterface/Views/NavigationBar.js

    r259168 r279613  
    224224
    225225        function calculateVisibleItemWidth() {
    226             return visibleNavigationItems.reduce((total, item) => total + item.width, 0);
     226            return visibleNavigationItems.reduce((total, item) => total + Math.ceil(item.width), 0);
    227227        }
    228228
     
    253253            while (totalItemWidth > barWidth && visibleNavigationItems.length) {
    254254                let navigationItem = visibleNavigationItems.shift();
    255                 totalItemWidth -= navigationItem.width;
     255                totalItemWidth -= Math.ceil(navigationItem.width);
    256256                forceItemHidden(navigationItem, true);
    257257            }
     
    415415            this.element.classList.add(WI.NavigationBar.CollapsedStyleClassName);
    416416
    417         let totalItemWidth = visibleNavigationItems.reduce((total, item) => total + item.minimumWidth, 0);
     417        let totalItemWidth = visibleNavigationItems.reduce((total, item) => total + Math.ceil(item.minimumWidth), 0);
    418418
    419419        // Remove the collapsed style class if we were not collapsed before.
  • trunk/Source/WebInspectorUI/UserInterface/Views/SingleSidebar.js

    r274465 r279613  
    8484    didInsertSidebarPanel(sidebarPanel, index)
    8585    {
    86         if (this._navigationBar) {
    87             console.assert(sidebarPanel.navigationItem);
    88             this._navigationBar.insertNavigationItem(sidebarPanel.navigationItem, index);
    89         }
     86        if (!this._navigationBar)
     87            return;
     88
     89        console.assert(sidebarPanel.navigationItem);
     90        this._navigationBar.insertNavigationItem(sidebarPanel.navigationItem, index);
     91
     92        this._recalculateWidth();   
    9093    }
    9194
    9295    didRemoveSidebarPanel(sidebarPanel)
    9396    {
    94         if (this._navigationBar) {
    95             console.assert(sidebarPanel.navigationItem);
    96             this._navigationBar.removeNavigationItem(sidebarPanel.navigationItem);
    97         }
     97        if (!this._navigationBar)
     98            return;
     99
     100        console.assert(sidebarPanel.navigationItem);
     101        this._navigationBar.removeNavigationItem(sidebarPanel.navigationItem);
     102
     103        this._recalculateWidth();
    98104    }
    99105
Note: See TracChangeset for help on using the changeset viewer.