Don't add additional padding when vertical tab is hidden completely (#32657)

Resolves brave/brave-browser#51056

Set 0 as vertical tab's minimum width when hidden completely.
BraveBrowserViewLayout will not consider vertical tab when calculating contents view's margin as it's hidden.

TEST=VerticalTabStripHideCompletelyTest.GetMinimumWidth
This commit is contained in:
Simon Hong
2025-12-05 09:31:37 +09:00
committed by GitHub
parent c6c4609eb2
commit ceacdc4d5a
3 changed files with 11 additions and 5 deletions
@@ -320,8 +320,10 @@ void BraveBrowserViewLayout::UpdateContentsContainerInsets(
// Due to vertical tab's padding(tabs::kMarginForVerticalTabContainers), we
// can see some space between vertical tab and contents. However, If we don't
// have margin from contents, vertical tab side contents shadow isn't visible.
// So, having half or margin from vertical tab and half from contents.
// So, having half of margin from vertical tab and half from contents.
if (browser() && tabs::utils::ShouldShowVerticalTabs(browser()) &&
(vertical_tab_strip_host_ &&
vertical_tab_strip_host_->GetPreferredSize().width() != 0) &&
!IsFullscreenForBrowser()) {
const int margin_with_vertical_tab =
browser()
@@ -463,6 +465,8 @@ gfx::Insets BraveBrowserViewLayout::AdjustInsetsConsideringFrameBorder(
const gfx::Insets& insets) {
BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser());
if (!browser() || !tabs::utils::ShouldShowVerticalTabs(browser()) ||
(vertical_tab_strip_host_ &&
vertical_tab_strip_host_->GetPreferredSize().width() == 0) ||
(browser_view && browser_view->IsFullscreen())) {
return insets;
}
@@ -1209,9 +1209,9 @@ IN_PROC_BROWSER_TEST_F(VerticalTabStripHideCompletelyTest, GetMinimumWidth) {
ASSERT_EQ(BraveVerticalTabStripRegionView::State::kCollapsed,
region_view->state());
// The minimum width of the region view should be 4px, which is narrower than
// it used to be.
EXPECT_EQ(4, region_view->GetMinimumSize().width());
// The minimum width of the region view should be 0px as it's hidden
// completely when collapsed.
EXPECT_EQ(0, region_view->GetMinimumSize().width());
// When the preference is disabled, the minimum width should be back to
// 41px(w/o rounded corners) or 38px(with rounded corners) due to region
@@ -775,7 +775,9 @@ gfx::Size BraveVerticalTabStripRegionView::CalculatePreferredSize(
}
gfx::Size BraveVerticalTabStripRegionView::GetMinimumSize() const {
if (IsFloatingEnabledForBrowserFullscreen()) {
if (IsFloatingEnabledForBrowserFullscreen() ||
((tabs::utils::ShouldHideVerticalTabsCompletelyWhenCollapsed(browser_) &&
state_ != State::kExpanded))) {
// Vertical tab strip always overlaps the contents area.
return {};
}