Title: [258623] trunk/Source/WebInspectorUI
Revision
258623
Author
[email protected]
Date
2020-03-17 21:30:22 -0700 (Tue, 17 Mar 2020)

Log Message

Web Inspector: the width of `WI.TabBarItem` can change if the detached window is resized
https://bugs.webkit.org/show_bug.cgi?id=209200

Reviewed by Timothy Hatcher.

* UserInterface/Views/TabBar.js:
(WI.TabBar.prototype.layout):
(WI.TabBar.prototype.layout.measureWidth): Renamed from `measureItemWidth`.
When undocked, `WI.TabBarItem` grow to fill any available space. As a result, if a
`WI.TabBarItem` is added or removed, the width of all `WI.TabBarItem` will change.
Wait to measure widths until all `WI.TabBarItem` are un-hidden for the reason above.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (258622 => 258623)


--- trunk/Source/WebInspectorUI/ChangeLog	2020-03-18 04:14:52 UTC (rev 258622)
+++ trunk/Source/WebInspectorUI/ChangeLog	2020-03-18 04:30:22 UTC (rev 258623)
@@ -1,5 +1,19 @@
 2020-03-17  Devin Rousso  <[email protected]>
 
+        Web Inspector: the width of `WI.TabBarItem` can change if the detached window is resized
+        https://bugs.webkit.org/show_bug.cgi?id=209200
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Views/TabBar.js:
+        (WI.TabBar.prototype.layout):
+        (WI.TabBar.prototype.layout.measureWidth): Renamed from `measureItemWidth`.
+        When undocked, `WI.TabBarItem` grow to fill any available space. As a result, if a
+        `WI.TabBarItem` is added or removed, the width of all `WI.TabBarItem` will change.
+        Wait to measure widths until all `WI.TabBarItem` are un-hidden for the reason above.
+
+2020-03-17  Devin Rousso  <[email protected]>
+
         Web Inspector: Network: we should prefer showing "Preserve Log" over "Group Media Requests"
         https://bugs.webkit.org/show_bug.cgi?id=209199
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TabBar.js (258622 => 258623)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TabBar.js	2020-03-18 04:14:52 UTC (rev 258622)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TabBar.js	2020-03-18 04:30:22 UTC (rev 258623)
@@ -435,13 +435,16 @@
         const tabBarHorizontalPadding = WI.TabBar.horizontalPadding;
         const tabBarItemHorizontalMargin = WI.TabBarItem.horizontalMargin;
 
-        function measureItemWidth(item) {
-            if (!item[WI.TabBar.CachedWidthSymbol])
-                item[WI.TabBar.CachedWidthSymbol] = item.element.realOffsetWidth + tabBarItemHorizontalMargin;
-            return item[WI.TabBar.CachedWidthSymbol];
+        let undocked = WI.dockConfiguration === WI.DockConfiguration.Undocked;
+
+        function measureWidth(tabBarItem) {
+            if (!tabBarItem[WI.TabBar.CachedWidthSymbol])
+                tabBarItem[WI.TabBar.CachedWidthSymbol] = tabBarItem.element.realOffsetWidth + tabBarItemHorizontalMargin;
+            return tabBarItem[WI.TabBar.CachedWidthSymbol];
         }
 
-        let availableSpace = this._tabContainer.realOffsetWidth - tabBarHorizontalPadding;
+        // Add one to allow for possible sub-px widths.
+        let availableSpace = this._tabContainer.realOffsetWidth - tabBarHorizontalPadding + 1;
 
         this._tabContainer.classList.add("calculate-width");
 
@@ -448,7 +451,6 @@
         this._hiddenTabBarItems = [];
 
         let normalTabBarItems = [];
-        let normalTabBarItemsWidth = 0;
         for (let tabBarItem of this._tabBarItemsFromLeftToRight()) {
             if (tabBarItem === this._tabPickerTabBarItem) {
                 tabBarItem.hidden = true;
@@ -457,17 +459,24 @@
 
             tabBarItem.hidden = false;
 
-            if (tabBarItem instanceof WI.PinnedTabBarItem)
-                availableSpace -= measureItemWidth(tabBarItem);
-            else {
-                normalTabBarItems.push(tabBarItem);
-                normalTabBarItemsWidth += measureItemWidth(tabBarItem);
+            if (tabBarItem instanceof WI.PinnedTabBarItem) {
+                availableSpace -= measureWidth(tabBarItem);
+                continue;
             }
+
+            normalTabBarItems.push(tabBarItem);
+
+            // When undocked, `WI.TabBarItem` grow to fill any available space. As a result, if a
+            // `WI.TabBarItem` is added or removed, the width of all `WI.TabBarItem` will change.
+            if (undocked)
+                tabBarItem[WI.TabBar.CachedWidthSymbol] = 0;
         }
 
+        // Wait to measure widths until all `WI.TabBarItem` are un-hidden for the reason above.
+        let normalTabBarItemsWidth = normalTabBarItems.reduce((accumulator, tabBarItem) => accumulator + measureWidth(tabBarItem), 0);
         if (normalTabBarItemsWidth > availableSpace) {
             this._tabPickerTabBarItem.hidden = false;
-            availableSpace -= measureItemWidth(this._tabPickerTabBarItem);
+            availableSpace -= measureWidth(this._tabPickerTabBarItem);
 
             let index = normalTabBarItems.length - 1;
             do {
@@ -475,7 +484,7 @@
                 if (tabBarItem === this._selectedTabBarItem)
                     continue;
 
-                normalTabBarItemsWidth -= measureItemWidth(tabBarItem);
+                normalTabBarItemsWidth -= measureWidth(tabBarItem);
 
                 tabBarItem.hidden = true;
                 this._hiddenTabBarItems.push(tabBarItem);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to