Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI run for contributor PR #27117 #27125

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 25 additions & 9 deletions browser/ui/views/frame/vertical_tab_strip_region_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -918,25 +918,41 @@ void VerticalTabStripRegionView::Layout(PassKey) {
// As we have to update ScrollView's viewport size and its contents size,
// laying out children manually will be more handy.

// 1. New tab should be fixed at the bottom of container.
const auto contents_bounds = GetContentsBounds();
new_tab_button_->SetSize(
{contents_bounds.width(), new_tab_button_->GetPreferredSize().height()});
new_tab_button_->SetPosition(
{contents_bounds.x(),
contents_bounds.bottom() - new_tab_button_->height()});

const gfx::Size header_size{contents_bounds.width(),
tabs::kVerticalTabHeight + kHeaderInset * 2};
header_view_->SetPosition(contents_bounds.origin());
header_view_->SetSize(header_size);

contents_view_->SetSize(
{contents_bounds.width(), contents_bounds.height() -
new_tab_button_->height() -
header_view_->height()});
{contents_bounds.width(),
original_region_view_->tab_strip_->tab_container_->GetPreferredSize()
.height()});

contents_view_->SetPosition({contents_bounds.origin().x(),
header_view_->y() + header_view_->height()});

int new_tab_height = new_tab_button_->GetPreferredSize().height();
new_tab_button_->SetSize(gfx::Size(contents_bounds.width(), new_tab_height));

int contents_view_max_height = contents_bounds.height() -
new_tab_button_->height() -
header_view_->height();

// Position New Tab Button and update the size of contents view if needed.
int contents_view_bottom_y = contents_view_->y() + contents_view_->height();
int new_tab_button_max_y = contents_bounds.bottom() - new_tab_height;
if (contents_view_bottom_y >= new_tab_button_max_y) {
contents_view_->SetSize(
gfx::Size(contents_bounds.width(), contents_view_max_height));
new_tab_button_->SetPosition(gfx::Point(
contents_bounds.x(), contents_bounds.bottom() - new_tab_height));
} else {
new_tab_button_->SetPosition(gfx::Point(
contents_bounds.x(), contents_view_->y() + contents_view_->height()));
}

UpdateOriginalTabSearchButtonVisibility();

// Put resize area, overlapped with contents.
Expand Down
9 changes: 7 additions & 2 deletions browser/ui/views/tabs/brave_compound_tab_container.cc
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,11 @@ gfx::Size BraveCompoundTabContainer::CalculatePreferredSize(
auto preferred_size =
CompoundTabContainer::CalculatePreferredSize(available_size);

// Check if we can expand height to fill the entire scroll area's viewport.
const int combined_height =
pinned_tab_container_->GetPreferredSize().height() +
unpinned_tab_container_->GetPreferredSize().height();

// Traverse up the parent hierarchy to find the |VerticalTabStripRegionView|
for (auto* parent_view = parent(); parent_view;
parent_view = parent_view->parent()) {
auto* region_view =
Expand All @@ -280,7 +284,8 @@ gfx::Size BraveCompoundTabContainer::CalculatePreferredSize(
continue;
}

preferred_size.set_height(region_view->GetTabStripViewportHeight());
preferred_size.set_height(
std::min(combined_height, region_view->GetTabStripViewportHeight()));
break;
}

Expand Down
6 changes: 5 additions & 1 deletion browser/ui/views/tabs/brave_tab_strip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ bool BraveTabStrip::IsVerticalTabsFloating() const {
auto* vertical_region_view =
browser_view->vertical_tab_strip_widget_delegate_view()
->vertical_tab_strip_region_view();
DCHECK(vertical_region_view);

if (!vertical_region_view) {
// Could be null while closing a window.
return false;
}

return vertical_region_view->state() ==
VerticalTabStripRegionView::State::kFloating ||
Expand Down
Loading