Changeset 258623 in webkit
- Timestamp:
- Mar 17, 2020 9:30:22 PM (4 years ago)
- Location:
- trunk/Source/WebInspectorUI
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebInspectorUI/ChangeLog
r258622 r258623 1 2020-03-17 Devin Rousso <drousso@apple.com> 2 3 Web Inspector: the width of `WI.TabBarItem` can change if the detached window is resized 4 https://bugs.webkit.org/show_bug.cgi?id=209200 5 6 Reviewed by Timothy Hatcher. 7 8 * UserInterface/Views/TabBar.js: 9 (WI.TabBar.prototype.layout): 10 (WI.TabBar.prototype.layout.measureWidth): Renamed from `measureItemWidth`. 11 When undocked, `WI.TabBarItem` grow to fill any available space. As a result, if a 12 `WI.TabBarItem` is added or removed, the width of all `WI.TabBarItem` will change. 13 Wait to measure widths until all `WI.TabBarItem` are un-hidden for the reason above. 14 1 15 2020-03-17 Devin Rousso <drousso@apple.com> 2 16 -
trunk/Source/WebInspectorUI/UserInterface/Views/TabBar.js
r258550 r258623 436 436 const tabBarItemHorizontalMargin = WI.TabBarItem.horizontalMargin; 437 437 438 function measureItemWidth(item) { 439 if (!item[WI.TabBar.CachedWidthSymbol]) 440 item[WI.TabBar.CachedWidthSymbol] = item.element.realOffsetWidth + tabBarItemHorizontalMargin; 441 return item[WI.TabBar.CachedWidthSymbol]; 442 } 443 444 let availableSpace = this._tabContainer.realOffsetWidth - tabBarHorizontalPadding; 438 let undocked = WI.dockConfiguration === WI.DockConfiguration.Undocked; 439 440 function measureWidth(tabBarItem) { 441 if (!tabBarItem[WI.TabBar.CachedWidthSymbol]) 442 tabBarItem[WI.TabBar.CachedWidthSymbol] = tabBarItem.element.realOffsetWidth + tabBarItemHorizontalMargin; 443 return tabBarItem[WI.TabBar.CachedWidthSymbol]; 444 } 445 446 // Add one to allow for possible sub-px widths. 447 let availableSpace = this._tabContainer.realOffsetWidth - tabBarHorizontalPadding + 1; 445 448 446 449 this._tabContainer.classList.add("calculate-width"); … … 449 452 450 453 let normalTabBarItems = []; 451 let normalTabBarItemsWidth = 0;452 454 for (let tabBarItem of this._tabBarItemsFromLeftToRight()) { 453 455 if (tabBarItem === this._tabPickerTabBarItem) { … … 458 460 tabBarItem.hidden = false; 459 461 460 if (tabBarItem instanceof WI.PinnedTabBarItem) 461 availableSpace -= measureItemWidth(tabBarItem); 462 else { 463 normalTabBarItems.push(tabBarItem); 464 normalTabBarItemsWidth += measureItemWidth(tabBarItem); 465 } 466 } 467 462 if (tabBarItem instanceof WI.PinnedTabBarItem) { 463 availableSpace -= measureWidth(tabBarItem); 464 continue; 465 } 466 467 normalTabBarItems.push(tabBarItem); 468 469 // When undocked, `WI.TabBarItem` grow to fill any available space. As a result, if a 470 // `WI.TabBarItem` is added or removed, the width of all `WI.TabBarItem` will change. 471 if (undocked) 472 tabBarItem[WI.TabBar.CachedWidthSymbol] = 0; 473 } 474 475 // Wait to measure widths until all `WI.TabBarItem` are un-hidden for the reason above. 476 let normalTabBarItemsWidth = normalTabBarItems.reduce((accumulator, tabBarItem) => accumulator + measureWidth(tabBarItem), 0); 468 477 if (normalTabBarItemsWidth > availableSpace) { 469 478 this._tabPickerTabBarItem.hidden = false; 470 availableSpace -= measure ItemWidth(this._tabPickerTabBarItem);479 availableSpace -= measureWidth(this._tabPickerTabBarItem); 471 480 472 481 let index = normalTabBarItems.length - 1; … … 476 485 continue; 477 486 478 normalTabBarItemsWidth -= measure ItemWidth(tabBarItem);487 normalTabBarItemsWidth -= measureWidth(tabBarItem); 479 488 480 489 tabBarItem.hidden = true;
Note: See TracChangeset
for help on using the changeset viewer.