diff --git a/browser/ui/views/tabs/brave_tab.cc b/browser/ui/views/tabs/brave_tab.cc index 309682b52b29..03523f069c47 100644 --- a/browser/ui/views/tabs/brave_tab.cc +++ b/browser/ui/views/tabs/brave_tab.cc @@ -54,6 +54,11 @@ std::u16string BraveTab::GetTooltipText(const gfx::Point& p) const { return Tab::GetTooltipText(p); } +void BraveTab::UpdateBorder() { + // In vertical tab, different border is used based on split view state. + SetBorder(views::CreateEmptyBorder(tab_style_views()->GetContentsInsets())); +} + int BraveTab::GetWidthOfLargestSelectableRegion() const { // Assume the entire region except the area that alert indicator/close buttons // occupied is available for click-to-select. diff --git a/browser/ui/views/tabs/brave_tab.h b/browser/ui/views/tabs/brave_tab.h index 8bd14932d8c3..798e14bfc706 100644 --- a/browser/ui/views/tabs/brave_tab.h +++ b/browser/ui/views/tabs/brave_tab.h @@ -24,6 +24,7 @@ class BraveTab : public Tab { // Tab: std::u16string GetTooltipText(const gfx::Point& p) const override; + void UpdateBorder() override; // Overridden because we moved alert button to left side in the tab whereas // upstream put it on right side. Need to consider this change for calculating diff --git a/browser/ui/views/tabs/brave_tab_container.cc b/browser/ui/views/tabs/brave_tab_container.cc index 58a285634608..fa44f6d4b9f7 100644 --- a/browser/ui/views/tabs/brave_tab_container.cc +++ b/browser/ui/views/tabs/brave_tab_container.cc @@ -470,7 +470,6 @@ std::optional BraveTabContainer::GetDropIndex( continue; } - const bool is_tab_pinned = tab->data().pinned; // When dropping text or links onto pinned tabs, we need to take the @@ -601,10 +600,12 @@ void BraveTabContainer::HandleDragExited() { } void BraveTabContainer::OnTileTabs(const TabTile& tile) { + UpdateTabsBorderInTile(tile); SchedulePaint(); } void BraveTabContainer::OnDidBreakTile(const TabTile& tile) { + UpdateTabsBorderInTile(tile); SchedulePaint(); } @@ -757,5 +758,31 @@ void BraveTabContainer::SetDropArrow( drop_arrow_->SetWindowBounds(drop_bounds); } +bool BraveTabContainer::IsPinnedTabContainer() const { + return tabs_view_model_.view_size() > 0 && tabs_view_model_.view_at(0)->data().pinned; +} + +void BraveTabContainer::UpdateTabsBorderInTile(const TabTile& tile) { + auto* tab_strip_model = tab_slot_controller_->GetBrowser()->tab_strip_model(); + const int offset = + IsPinnedTabContainer() ? 0 : tab_strip_model->IndexOfFirstNonPinnedTab(); + + auto tab1_index = tab_strip_model->GetIndexOfTab(tile.first) - offset; + auto tab2_index = tab_strip_model->GetIndexOfTab(tile.second) - offset; + + if (!controller_->IsValidModelIndex(tab1_index) || + !controller_->IsValidModelIndex(tab2_index)) { + // In case the tiled tab is not in this container, this can happen. + // For instance, this container is for pinned tabs but tabs in the tile + // are unpinned. + return; + } + + auto* tab1 = GetTabAtModelIndex(tab1_index); + auto* tab2 = GetTabAtModelIndex(tab2_index); + tab1->UpdateBorder(); + tab2->UpdateBorder(); +} + BEGIN_METADATA(BraveTabContainer) END_METADATA diff --git a/browser/ui/views/tabs/brave_tab_container.h b/browser/ui/views/tabs/brave_tab_container.h index bbb49bd5988b..099083ad2743 100644 --- a/browser/ui/views/tabs/brave_tab_container.h +++ b/browser/ui/views/tabs/brave_tab_container.h @@ -121,6 +121,9 @@ class BraveTabContainer : public TabContainerImpl, bool drop_in_group, bool* is_beneath); + bool IsPinnedTabContainer() const; + void UpdateTabsBorderInTile(const TabTile& tile); + base::flat_set closing_tabs_; raw_ptr drag_context_; diff --git a/browser/ui/views/tabs/brave_tab_style_views.inc.cc b/browser/ui/views/tabs/brave_tab_style_views.inc.cc index 0f5ea082e4de..8e4eea83dadf 100644 --- a/browser/ui/views/tabs/brave_tab_style_views.inc.cc +++ b/browser/ui/views/tabs/brave_tab_style_views.inc.cc @@ -13,6 +13,8 @@ namespace { using tabs::features::HorizontalTabsUpdateEnabled; +constexpr auto kPaddingForVerticalTabInTile = 4; + // Returns a value indicating if the browser frame view is "condensed", i.e. // that its frame border is somehow collapsed, as in fullscreen or when // maximized, or in Linux when caption buttons and the title bar are not @@ -215,13 +217,13 @@ SkPath BraveVerticalTabStyle::GetPath( } } - if (IsTabTiled(tab()) && path_type != TabStyle::PathType::kHitTest) { + if (!is_pinned && IsTabTiled(tab()) && path_type != TabStyle::PathType::kHitTest) { if (ShouldShowVerticalTabs()) { - constexpr auto kPaddingForVerticalTab = 4; - tab_top += scale * kPaddingForVerticalTab; - tab_bottom -= scale * kPaddingForVerticalTab; - tab_left += scale * kPaddingForVerticalTab; - tab_right -= scale * kPaddingForVerticalTab; + tab()->controller()->IsFirstTabInTile(tab()) + ? tab_top += scale* kPaddingForVerticalTabInTile + : tab_bottom -= scale * kPaddingForVerticalTabInTile; + tab_left += scale * kPaddingForVerticalTabInTile; + tab_right -= scale * kPaddingForVerticalTabInTile; } else { // Give 2 dip more padding when tab is in tile. constexpr auto kPaddingForHorizontalTab = 2; @@ -251,20 +253,30 @@ SkPath BraveVerticalTabStyle::GetPath( } gfx::Insets BraveVerticalTabStyle::GetContentsInsets() const { - if (!HorizontalTabsUpdateEnabled()) { - return BraveTabStyleViews::GetContentsInsets(); + const bool is_pinned = tab()->data().pinned; + auto insets = tab_style()->GetContentsInsets(); + + if (!is_pinned && ShouldShowVerticalTabs() && IsTabTiled(tab())) { + const bool is_first_tab = tab()->controller()->IsFirstTabInTile(tab()); + return insets + gfx::Insets::TLBR( + is_first_tab ? kPaddingForVerticalTabInTile : 0, 0, + is_first_tab ? 0 : kPaddingForVerticalTabInTile, 0); } - // Ignore any stroke widths when determining the horizontal contents insets. - // To make contents vertically align evenly regardless of overlap in non - // vertical tab, use it as bottom inset in a tab as it's hidden by - // overlapping. - const int bottom_inset = ShouldShowVerticalTabs() - ? 0 - : GetLayoutConstant(TABSTRIP_TOOLBAR_OVERLAP); + if (HorizontalTabsUpdateEnabled()) { + // Ignore any stroke widths when determining the horizontal contents insets. + // To make contents vertically align evenly regardless of overlap in non + // vertical tab, use it as bottom inset in a tab as it's hidden by + // overlapping. + return insets + + gfx::Insets::TLBR(0, 0, + ShouldShowVerticalTabs() + ? 0 + : GetLayoutConstant(TABSTRIP_TOOLBAR_OVERLAP), + 0); + } - return tab_style()->GetContentsInsets() + - gfx::Insets::TLBR(0, 0, bottom_inset, 0); + return BraveTabStyleViews::GetContentsInsets(); } TabStyle::SeparatorBounds BraveVerticalTabStyle::GetSeparatorBounds( diff --git a/chromium_src/chrome/browser/ui/views/tabs/tab.h b/chromium_src/chrome/browser/ui/views/tabs/tab.h index 8cc15a690dc0..7d2b89e7ef57 100644 --- a/chromium_src/chrome/browser/ui/views/tabs/tab.h +++ b/chromium_src/chrome/browser/ui/views/tabs/tab.h @@ -13,6 +13,7 @@ class BraveTab; kMinimumContentsWidthForCloseButtons = 55; \ friend class ::BraveTabTest; \ friend class ::BraveTab; \ + virtual void UpdateBorder() {} \ static constexpr int kMinimumContentsWidthForCloseButtons_UnUsed #define GetWidthOfLargestSelectableRegion \