Skip to content

Commit

Permalink
Only hide sidebar when tab-initiated fullscreen mode
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhong committed Aug 24, 2022
1 parent fbf1f39 commit b09164c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 11 additions & 1 deletion browser/ui/views/sidebar/sidebar_container_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/side_panel/side_panel_entry.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
Expand Down Expand Up @@ -184,7 +186,7 @@ void SidebarContainerView::Layout() {

gfx::Size SidebarContainerView::CalculatePreferredSize() const {
if (!initialized_ || !sidebar_control_view_->GetVisible() ||
browser_->window()->IsFullscreen())
IsFullscreenByTab())
return View::CalculatePreferredSize();

int preferred_width =
Expand All @@ -201,6 +203,14 @@ void SidebarContainerView::OnThemeChanged() {
UpdateBackground();
}

bool SidebarContainerView::IsFullscreenByTab() const {
DCHECK(browser_->exclusive_access_manager() &&
browser_->exclusive_access_manager()->fullscreen_controller());
return browser_->exclusive_access_manager()
->fullscreen_controller()
->IsWindowFullscreenForTabOrPending();
}

bool SidebarContainerView::ShouldForceShowSidebar() const {
// Always show if panel should be visible. It is more reliable to check
// whether the active index is a panel item rather than checking if
Expand Down
3 changes: 3 additions & 0 deletions browser/ui/views/sidebar/sidebar_container_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ class SidebarContainerView
bool ShouldForceShowSidebar() const;
void UpdateToolbarButtonVisibility();

// true when fullscreen is initiated by tab. (Ex, fullscreen mode in youtube)
bool IsFullscreenByTab() const;

// On some condition(ex, add item bubble is visible),
// sidebar should not be hidden even if mouse goes out from sidebar ui.
// If it's hidden, only bubble ui is visible. Then, weird situation happens.
Expand Down

0 comments on commit b09164c

Please sign in to comment.