Index: chrome/browser/ui/views/frame/browser_view_layout.cc |
diff --git a/chrome/browser/ui/views/frame/browser_view_layout.cc b/chrome/browser/ui/views/frame/browser_view_layout.cc |
index dac49231c50cbe2cc8c1ba547039c0f414c9be5d..763836eb66df54f1834fea2d622eb8810afc4a1d 100644 |
--- a/chrome/browser/ui/views/frame/browser_view_layout.cc |
+++ b/chrome/browser/ui/views/frame/browser_view_layout.cc |
@@ -15,6 +15,7 @@ |
#include "chrome/browser/ui/views/frame/browser_frame.h" |
#include "chrome/browser/ui/views/frame/browser_view.h" |
#include "chrome/browser/ui/views/frame/contents_container.h" |
+#include "chrome/browser/ui/views/immersive_mode_controller.h" |
#include "chrome/browser/ui/views/infobars/infobar_container_view.h" |
#include "chrome/browser/ui/views/tabs/tab_strip.h" |
#include "chrome/browser/ui/views/toolbar_view.h" |
@@ -58,11 +59,8 @@ bool ConvertedHitTest(views::View* src, views::View* dst, gfx::Point* point) { |
// BrowserViewLayout, public: |
BrowserViewLayout::BrowserViewLayout() |
- : tabstrip_(NULL), |
- toolbar_(NULL), |
- contents_split_(NULL), |
+ : contents_split_(NULL), |
contents_container_(NULL), |
- infobar_container_(NULL), |
download_shelf_(NULL), |
active_bookmark_bar_(NULL), |
browser_view_(NULL), |
@@ -82,13 +80,13 @@ bool BrowserViewLayout::GetConstrainedWindowTopY(int* top_y) { |
gfx::Size BrowserViewLayout::GetMinimumSize() { |
gfx::Size tabstrip_size( |
browser()->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ? |
- tabstrip_->GetMinimumSize() : gfx::Size()); |
+ browser_view_->tabstrip_->GetMinimumSize() : gfx::Size()); |
BrowserNonClientFrameView::TabStripInsets tab_strip_insets( |
browser_view_->frame()->GetTabStripInsets(false)); |
gfx::Size toolbar_size( |
(browser()->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || |
browser()->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) ? |
- toolbar_->GetMinimumSize() : gfx::Size()); |
+ browser_view_->toolbar_->GetMinimumSize() : gfx::Size()); |
if (tabstrip_size.height() && toolbar_size.height()) |
toolbar_size.Enlarge(0, -kToolbarTabStripVerticalOverlap); |
gfx::Size bookmark_bar_size; |
@@ -145,9 +143,15 @@ gfx::Rect BrowserViewLayout::GetFindBarBoundingBox() const { |
bool BrowserViewLayout::IsPositionInWindowCaption( |
const gfx::Point& point) { |
+ TabStrip* tabstrip = browser_view_->tabstrip_; |
+ // Tab strip may transiently have no parent between the RemoveChildView() and |
+ // AddChildView() caused by reparenting during an immersive mode reveal. |
+ // During this window report that the point didn't hit a tab. |
+ if (!tabstrip->parent()) |
+ return true; |
gfx::Point tabstrip_point(point); |
- views::View::ConvertPointToTarget(browser_view_, tabstrip_, &tabstrip_point); |
- return tabstrip_->IsPositionInWindowCaption(tabstrip_point); |
+ views::View::ConvertPointToTarget(browser_view_, tabstrip, &tabstrip_point); |
+ return tabstrip->IsPositionInWindowCaption(tabstrip_point); |
} |
int BrowserViewLayout::NonClientHitTest( |
@@ -168,8 +172,8 @@ int BrowserViewLayout::NonClientHitTest( |
// might be a popup window without a TabStrip. |
if (browser_view_->IsTabStripVisible()) { |
// See if the mouse pointer is within the bounds of the TabStrip. |
- if (ConvertedHitTest(parent, tabstrip_, &test_point)) { |
- if (tabstrip_->IsPositionInWindowCaption(test_point)) |
+ if (ConvertedHitTest(parent, browser_view_->tabstrip_, &test_point)) { |
+ if (browser_view_->tabstrip_->IsPositionInWindowCaption(test_point)) |
return HTCAPTION; |
return HTCLIENT; |
} |
@@ -179,7 +183,7 @@ int BrowserViewLayout::NonClientHitTest( |
// makes sense visually). |
if (!browser_view_->IsMaximized() && |
(point_in_browser_view_coords.y() < |
- (tabstrip_->y() + kTabShadowSize))) { |
+ (browser_view_->tabstrip_->y() + kTabShadowSize))) { |
// We return HTNOWHERE as this is a signal to our containing |
// NonClientView that it should figure out what the correct hit-test |
// code is given the mouse position... |
@@ -191,8 +195,8 @@ int BrowserViewLayout::NonClientHitTest( |
// within the bounds of this view, the point is considered to be within the |
// client area. |
gfx::Rect bv_bounds = browser_view_->bounds(); |
- bv_bounds.Offset(0, toolbar_->y()); |
- bv_bounds.set_height(bv_bounds.height() - toolbar_->y()); |
+ bv_bounds.Offset(0, browser_view_->toolbar_->y()); |
+ bv_bounds.set_height(bv_bounds.height() - browser_view_->toolbar_->y()); |
if (bv_bounds.Contains(point)) |
return HTCLIENT; |
@@ -207,7 +211,7 @@ int BrowserViewLayout::NonClientHitTest( |
// will hit-test the window controls before finally falling back to |
// HTCAPTION. |
bv_bounds = browser_view_->bounds(); |
- bv_bounds.set_height(toolbar_->y()); |
+ bv_bounds.set_height(browser_view_->toolbar_->y()); |
if (bv_bounds.Contains(point)) |
return HTNOWHERE; |
@@ -219,13 +223,10 @@ int BrowserViewLayout::NonClientHitTest( |
// BrowserViewLayout, views::LayoutManager implementation: |
void BrowserViewLayout::Installed(views::View* host) { |
- toolbar_ = NULL; |
contents_split_ = NULL; |
contents_container_ = NULL; |
- infobar_container_ = NULL; |
download_shelf_ = NULL; |
active_bookmark_bar_ = NULL; |
- tabstrip_ = NULL; |
browser_view_ = static_cast<BrowserView*>(host); |
} |
@@ -241,21 +242,12 @@ void BrowserViewLayout::ViewAdded(views::View* host, views::View* view) { |
contents_container_ = browser_view_->contents_; |
break; |
} |
- case VIEW_ID_INFO_BAR_CONTAINER: |
- infobar_container_ = view; |
- break; |
case VIEW_ID_DOWNLOAD_SHELF: |
download_shelf_ = static_cast<DownloadShelfView*>(view); |
break; |
case VIEW_ID_BOOKMARK_BAR: |
active_bookmark_bar_ = static_cast<BookmarkBarView*>(view); |
break; |
- case VIEW_ID_TOOLBAR: |
- toolbar_ = static_cast<ToolbarView*>(view); |
- break; |
- case VIEW_ID_TAB_STRIP: |
- tabstrip_ = static_cast<TabStrip*>(view); |
- break; |
} |
} |
@@ -271,13 +263,18 @@ void BrowserViewLayout::Layout(views::View* host) { |
vertical_layout_rect_ = browser_view_->GetLocalBounds(); |
int top = LayoutTabStripRegion(); |
if (browser_view_->IsTabStripVisible()) { |
- int x = tabstrip_->GetMirroredX() + browser_view_->GetMirroredX() + |
+ int x = browser_view_->tabstrip_->GetMirroredX() + |
+ browser_view_->GetMirroredX() + |
browser_view_->frame()->GetThemeBackgroundXInset(); |
- tabstrip_->SetBackgroundOffset(gfx::Point(x, |
+ browser_view_->tabstrip_->SetBackgroundOffset(gfx::Point(x, |
browser_view_->frame()->GetTabStripInsets(false).top)); |
} |
top = LayoutToolbar(top); |
top = LayoutBookmarkAndInfoBars(top); |
+ // During immersive mode reveal the content stays near the top of the view. |
+ if (browser_view_->immersive_mode_controller()->IsRevealed()) |
+ top = browser_view_->tabstrip_->x() + TabStrip::GetImmersiveHeight(); |
+ |
int bottom = LayoutDownloadShelf(browser_view_->height()); |
int active_top_margin = GetTopMarginForActiveContent(); |
top -= active_top_margin; |
@@ -321,22 +318,23 @@ const Browser* BrowserViewLayout::browser() const { |
} |
int BrowserViewLayout::LayoutTabStripRegion() { |
+ TabStrip* tabstrip = browser_view_->tabstrip_; |
if (!browser_view_->IsTabStripVisible()) { |
- tabstrip_->SetVisible(false); |
- tabstrip_->SetBounds(0, 0, 0, 0); |
+ tabstrip->SetVisible(false); |
+ tabstrip->SetBounds(0, 0, 0, 0); |
return 0; |
} |
// This retrieves the bounds for the tab strip based on whether or not we show |
// anything to the left of it, like the incognito avatar. |
gfx::Rect tabstrip_bounds( |
- browser_view_->frame()->GetBoundsForTabStrip(tabstrip_)); |
+ browser_view_->frame()->GetBoundsForTabStrip(tabstrip)); |
gfx::Point tabstrip_origin(tabstrip_bounds.origin()); |
views::View::ConvertPointToTarget(browser_view_->parent(), browser_view_, |
&tabstrip_origin); |
tabstrip_bounds.set_origin(tabstrip_origin); |
- tabstrip_->SetVisible(true); |
- tabstrip_->SetBoundsRect(tabstrip_bounds); |
+ tabstrip->SetVisible(true); |
+ tabstrip->SetBoundsRect(tabstrip_bounds); |
int bottom = tabstrip_bounds.bottom(); |
// The metro window switcher sits at the far right edge of the tabstrip |
@@ -373,15 +371,16 @@ int BrowserViewLayout::LayoutTabStripRegion() { |
} |
int BrowserViewLayout::LayoutToolbar(int top) { |
+ ToolbarView* toolbar = browser_view_->toolbar_; |
int browser_view_width = vertical_layout_rect_.width(); |
bool toolbar_visible = browser_view_->IsToolbarVisible(); |
- toolbar_->location_bar()->SetLocationEntryFocusable(toolbar_visible); |
+ toolbar->location_bar()->SetLocationEntryFocusable(toolbar_visible); |
int y = top; |
y -= (toolbar_visible && browser_view_->IsTabStripVisible()) ? |
kToolbarTabStripVerticalOverlap : 0; |
- int height = toolbar_visible ? toolbar_->GetPreferredSize().height() : 0; |
- toolbar_->SetVisible(toolbar_visible); |
- toolbar_->SetBounds(vertical_layout_rect_.x(), y, browser_view_width, height); |
+ int height = toolbar_visible ? toolbar->GetPreferredSize().height() : 0; |
+ toolbar->SetVisible(toolbar_visible); |
+ toolbar->SetBounds(vertical_layout_rect_.x(), y, browser_view_width, height); |
return y + height; |
} |
@@ -403,7 +402,8 @@ int BrowserViewLayout::LayoutBookmarkAndInfoBars(int top) { |
infobar_top : LayoutBookmarkBarAtTop(infobar_top); |
} |
// Otherwise, Bookmark bar first, Info bar second. |
- top = std::max(toolbar_->bounds().bottom(), LayoutBookmarkBarAtTop(top)); |
+ top = std::max(browser_view_->toolbar_->bounds().bottom(), |
+ LayoutBookmarkBarAtTop(top)); |
} |
find_bar_y_ = top + browser_view_->y() - 1; |
return LayoutInfoBar(top); |
@@ -479,16 +479,15 @@ void BrowserViewLayout::LayoutBookmarkBarAtBottom() { |
} |
int BrowserViewLayout::LayoutInfoBar(int top) { |
- // Raise the |infobar_container_| by its vertical overlap. |
- infobar_container_->SetVisible(InfobarVisible()); |
+ InfoBarContainerView* infobar_container = browser_view_->infobar_container_; |
+ // Raise the |infobar_container| by its vertical overlap. |
+ infobar_container->SetVisible(InfobarVisible()); |
int height; |
- int overlapped_top = top - |
- static_cast<InfoBarContainerView*>(infobar_container_)-> |
- GetVerticalOverlap(&height); |
- infobar_container_->SetBounds(vertical_layout_rect_.x(), |
- overlapped_top, |
- vertical_layout_rect_.width(), |
- height); |
+ int overlapped_top = top - infobar_container->GetVerticalOverlap(&height); |
+ infobar_container->SetBounds(vertical_layout_rect_.x(), |
+ overlapped_top, |
+ vertical_layout_rect_.width(), |
+ height); |
return overlapped_top + height; |
} |
@@ -545,7 +544,8 @@ int BrowserViewLayout::LayoutDownloadShelf(int bottom) { |
} |
bool BrowserViewLayout::InfobarVisible() const { |
+ views::View* infobar_container = browser_view_->infobar_container_; |
// NOTE: Can't check if the size IsEmpty() since it's always 0-width. |
return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && |
- (infobar_container_->GetPreferredSize().height() != 0); |
+ (infobar_container->GetPreferredSize().height() != 0); |
} |