Don't take vertical tab strip into account when calculating the min window size (#15821)

* Don't take vertical tab strip into account when calculating the min window size

This is a trial to fix a bug, where window grows too tall and becomes
unresizable.

The exact steps to reproduce was not found, but it seems somehow the
min height is set to window. As min size could be cached internally,
this could have happened when the min size wasn't flushed.

Co-authored-by: Simon Hong <shong@brave.com>
This commit is contained in:
Sangwoo Ko
2022-11-10 10:14:59 -03:00
committed by GitHub
co-authored by Simon Hong
parent 561ceee21b
commit b351054202
3 changed files with 42 additions and 3 deletions
@@ -16,6 +16,8 @@
#include "chrome/browser/ui/views/tabs/tab_strip.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/test/browser_test.h"
#include "ui/views/layout/flex_layout.h"
#include "ui/views/layout/layout_manager.h"
#if BUILDFLAG(IS_WIN)
#include "chrome/browser/ui/views/frame/glass_browser_frame_view.h"
@@ -33,6 +35,21 @@
#include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h"
#endif
namespace {
class TallLayoutManager : public views::FlexLayout {
public:
using FlexLayout::FlexLayout;
~TallLayoutManager() override = default;
// views::FlexLayout:
gfx::Size GetMinimumSize(const views::View* host) const override {
return {300, 1000};
}
};
} // namespace
class VerticalTabStripBrowserTest : public InProcessBrowserTest {
public:
VerticalTabStripBrowserTest()
@@ -169,3 +186,16 @@ IN_PROC_BROWSER_TEST_F(VerticalTabStripBrowserTest, NewTabVisibility) {
EXPECT_TRUE(
browser_view()->tab_strip_region_view()->new_tab_button()->GetVisible());
}
IN_PROC_BROWSER_TEST_F(VerticalTabStripBrowserTest, MinHeight) {
brave::ToggleVerticalTabStrip(browser());
browser_non_client_frame_view()->Layout();
// TabStripRegionView's min height shouldn't affect that of browser window.
const auto min_size = browser_view()->GetMinimumSize();
auto* layout = browser_view()->tab_strip_region_view()->SetLayoutManager(
std::make_unique<TallLayoutManager>());
layout->SetOrientation(views::LayoutOrientation::kVertical);
browser_view()->tab_strip_region_view()->layout_manager_ = layout;
EXPECT_EQ(min_size.height(), browser_view()->GetMinimumSize().height());
}
@@ -6,10 +6,18 @@
#include "chrome/browser/ui/views/frame/browser_view_layout.h"
#include "brave/browser/ui/views/side_panel/brave_side_panel.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h"
#include "chrome/browser/ui/views/side_panel/side_panel.h"
#include "chrome/browser/ui/views/side_search/side_search_browser_controller.h"
// Double check if the tab strip is actually visible to calculate constraints.
#define SupportsWindowFeature(FEATURE) \
SupportsWindowFeature(FEATURE) && (FEATURE != Browser::FEATURE_TABSTRIP || \
delegate_->IsTabStripVisible());
#define SidePanel BraveSidePanel
#include "src/chrome/browser/ui/views/frame/browser_view_layout.cc"
#undef SidePanel
#undef SupportsWindowFeature
@@ -6,9 +6,10 @@
#ifndef BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_FRAME_TAB_STRIP_REGION_VIEW_H_
#define BRAVE_CHROMIUM_SRC_CHROME_BROWSER_UI_VIEWS_FRAME_TAB_STRIP_REGION_VIEW_H_
#define FrameColorsChanged \
UnUsed_FrameColorsChanged() {} \
friend class VerticalTabStripRegionView; \
#define FrameColorsChanged \
UnUsed_FrameColorsChanged() {} \
friend class VerticalTabStripRegionView; \
FRIEND_TEST_ALL_PREFIXES(VerticalTabStripBrowserTest, MinHeight); \
void FrameColorsChanged
#include "src/chrome/browser/ui/views/frame/tab_strip_region_view.h"
#undef FrameColorsChanged