Skip to content

Commit

Permalink
Revert "Hide Vertical tab strip even when it's browser fullscreen (#1…
Browse files Browse the repository at this point in the history
…9802)"

This reverts commit 8d1dbb9.
  • Loading branch information
sangwoo108 committed Sep 19, 2023
1 parent 4b30cbb commit 7db9892
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 31 deletions.
18 changes: 14 additions & 4 deletions browser/ui/views/frame/vertical_tab_strip_region_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -685,9 +685,19 @@ void VerticalTabStripRegionView::OnWidgetDestroying(views::Widget* widget) {
widget_observation_.Reset();
}

bool VerticalTabStripRegionView::IsFullscreen() const {
auto* widget = GetWidget();
return widget && widget->GetTopLevelWidget()->IsFullscreen();
bool VerticalTabStripRegionView::IsTabFullscreen() const {
auto* exclusive_access_manager = browser_->exclusive_access_manager();
if (!exclusive_access_manager) {
return false;
}

auto* fullscreen_controller =
exclusive_access_manager->fullscreen_controller();
if (!fullscreen_controller) {
return false;
}

return fullscreen_controller->IsWindowFullscreenForTabOrPending();
}

void VerticalTabStripRegionView::SetState(State state) {
Expand Down Expand Up @@ -1080,7 +1090,7 @@ gfx::Size VerticalTabStripRegionView::GetPreferredSizeForState(
return {};
}

if (IsFullscreen()) {
if (IsTabFullscreen()) {
return {};
}

Expand Down
4 changes: 2 additions & 2 deletions browser/ui/views/frame/vertical_tab_strip_region_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

namespace views {
class ResizeArea;
} // namespace views
}

class BraveNewTabButton;
class BrowserView;
Expand Down Expand Up @@ -116,7 +116,7 @@ class VerticalTabStripRegionView : public views::View,
FRIEND_TEST_ALL_PREFIXES(VerticalTabStripBrowserTest,
OriginalTabSearchButton);

bool IsFullscreen() const;
bool IsTabFullscreen() const;

void SetState(State state);

Expand Down
52 changes: 27 additions & 25 deletions browser/ui/views/tabs/vertical_tab_strip_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -391,31 +391,12 @@ IN_PROC_BROWSER_TEST_F(VerticalTabStripBrowserTest, MAYBE_Fullscreen) {
observer.Wait();
}

base::RunLoop run_loop;
auto wait_until = base::BindLambdaForTesting(
[&](base::RepeatingCallback<bool()> predicate) {
if (predicate.Run()) {
return;
}

base::RepeatingTimer scheduler;
scheduler.Start(FROM_HERE, base::Milliseconds(100),
base::BindLambdaForTesting([&]() {
if (predicate.Run()) {
run_loop.Quit();
}
}));
run_loop.Run();
});

// Vertical tab strip should be invisible on browser fullscreen.
// Vertical tab strip should be visible on browser fullscreen.
ASSERT_TRUE(fullscreen_controller->IsFullscreenForBrowser());
ASSERT_TRUE(browser_view()->IsFullscreen());
wait_until.Run(base::BindLambdaForTesting([&]() {
return !browser_view()
->vertical_tab_strip_host_view_->GetPreferredSize()
.width();
}));
EXPECT_TRUE(browser_view()
->vertical_tab_strip_host_view_->GetPreferredSize()
.width());

{
auto observer = FullscreenNotificationObserver(browser());
Expand All @@ -427,6 +408,7 @@ IN_PROC_BROWSER_TEST_F(VerticalTabStripBrowserTest, MAYBE_Fullscreen) {

{
auto observer = FullscreenNotificationObserver(browser());
// Vertical tab strip should become invisible on tab fullscreen.
fullscreen_controller->EnterFullscreenModeForTab(
browser_view()
->browser()
Expand All @@ -436,15 +418,35 @@ IN_PROC_BROWSER_TEST_F(VerticalTabStripBrowserTest, MAYBE_Fullscreen) {

observer.Wait();
}

// Vertical tab strip should be invisible on tab fullscreen.
ASSERT_TRUE(fullscreen_controller->IsTabFullscreen());
if (!browser_view()
->vertical_tab_strip_host_view_->GetPreferredSize()
.width()) {
return;
}

base::RunLoop run_loop;
auto wait_until = base::BindLambdaForTesting(
[&](base::RepeatingCallback<bool()> predicate) {
if (predicate.Run()) {
return;
}

base::RepeatingTimer scheduler;
scheduler.Start(FROM_HERE, base::Milliseconds(100),
base::BindLambdaForTesting([&]() {
if (predicate.Run()) {
run_loop.Quit();
} else {
LOG(ERROR) << browser_view()
->vertical_tab_strip_host_view_
->GetPreferredSize()
.width();
}
}));
run_loop.Run();
});

wait_until.Run(base::BindLambdaForTesting([&]() {
return !browser_view()
->vertical_tab_strip_host_view_->GetPreferredSize()
Expand Down

0 comments on commit 7db9892

Please sign in to comment.