Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7307)

Unified Diff: chrome/browser/ui/views/frame/browser_view_layout.cc

Issue 12013004: alternate ntp: unpinned bookmark bar in ntp (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 88851905819af931c60caab6d667a8aa5f8a6500..00311c5eb48adc645296308410b000f51fd54005 100644
--- a/chrome/browser/ui/views/frame/browser_view_layout.cc
+++ b/chrome/browser/ui/views/frame/browser_view_layout.cc
@@ -7,8 +7,6 @@
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/find_bar/find_bar.h"
#include "chrome/browser/ui/find_bar/find_bar_controller.h"
-#include "chrome/browser/ui/search/search_model.h"
-#include "chrome/browser/ui/search/search_ui.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
#include "chrome/browser/ui/views/download/download_shelf_view.h"
@@ -24,7 +22,6 @@
#include "ui/gfx/scrollbar_size.h"
#include "ui/gfx/size.h"
#include "ui/views/controls/single_split_view.h"
-#include "ui/views/controls/webview/webview.h"
namespace {
@@ -291,16 +288,6 @@ void BrowserViewLayout::Layout(views::View* host) {
browser()->GetFindBarController()->find_bar()->MoveWindowIfNecessary(
gfx::Rect(), true);
}
-
- if (active_bookmark_bar_ && active_bookmark_bar_->IsDetached() &&
- browser()->search_model()->mode().is_ntp()) {
- LayoutBookmarkBarAtBottom();
- } else {
-#if !defined(USE_AURA)
- contents_container_->SetExtraContentHeight(0);
- contents_split_->SetLeadingBottomOffset(0);
-#endif
- }
}
// Return the preferred size which is the size required to give each
@@ -393,26 +380,20 @@ int BrowserViewLayout::LayoutBookmarkAndInfoBars(int top) {
top + browser_view_->y() - kConstrainedWindowOverlap;
find_bar_y_ = top + browser_view_->y() - 1;
if (active_bookmark_bar_) {
- // If the bookmark bar is showing in detached style:
- // - for non-NTP mode, show any Info bar _above_ the bookmark bar, since the
- // bookmark bar is styled to look like it's part of the page.
- // - otherwise, show the bookmark bar at the bottom of content view, so just
- // lay out infobar here; bottom bookmark bar is laid out in
- // |LayoutBookmarkBarAtBottom|.
- if (active_bookmark_bar_->IsDetached()) {
- int infobar_top = LayoutInfoBar(top);
- return browser()->search_model()->mode().is_ntp() ?
- infobar_top : LayoutBookmarkBarAtTop(infobar_top);
- }
+ // If we're showing the Bookmark bar in detached style, then we
+ // need to show any Info bar _above_ the Bookmark bar, since the
+ // Bookmark bar is styled to look like it's part of the page.
+ if (active_bookmark_bar_->IsDetached())
+ return LayoutBookmarkBar(LayoutInfoBar(top));
// Otherwise, Bookmark bar first, Info bar second.
top = std::max(browser_view_->toolbar_->bounds().bottom(),
- LayoutBookmarkBarAtTop(top));
+ LayoutBookmarkBar(top));
}
find_bar_y_ = top + browser_view_->y() - 1;
return LayoutInfoBar(top);
}
-int BrowserViewLayout::LayoutBookmarkBarAtTop(int top) {
+int BrowserViewLayout::LayoutBookmarkBar(int top) {
DCHECK(active_bookmark_bar_);
int y = top;
if (!browser_view_->IsBookmarkBarVisible()) {
@@ -432,55 +413,6 @@ int BrowserViewLayout::LayoutBookmarkBarAtTop(int top) {
return y + bookmark_bar_height;
}
-void BrowserViewLayout::LayoutBookmarkBarAtBottom() {
- DCHECK(active_bookmark_bar_);
- // Layout bookmark bar at bottom of content view in the y-direction.
- // Bookmark bar is child of |BrowserView| while content view is child of
- // ContentsContainer, so convert its bottom coordinate relative to
- // |BrowserView|.
- gfx::Point content_bottom(
- 0, browser_view_->contents_container_->bounds().bottom());
- views::View::ConvertPointToTarget(
- browser_view_->contents_container_->parent(), browser_view_,
- &content_bottom);
- // Only show bookmark bar if height of content view is >=
- // chrome::search::kMinContentHeightForBottomBookmarkBar.
- if (browser_view_->contents_container_->height() <
- chrome::search::kMinContentHeightForBottomBookmarkBar ||
- !browser_view_->IsBookmarkBarVisible()) {
- active_bookmark_bar_->SetVisible(false);
- active_bookmark_bar_->SetBounds(0, content_bottom.y(),
- browser_view_->width(), 0);
-#if !defined(USE_AURA)
- // When the bookmark bar is hidden, there is no need for a clip offset.
- contents_container_->SetExtraContentHeight(0);
- contents_split_->SetLeadingBottomOffset(0);
-#endif // !USE_AURA
- return;
- }
-
- // BookmarkBarView uses infobar visibility to determine toolbar overlap, which
- // is 0 if bookmark bar is detached and infobar is visible. Since the
- // bookmark bar on the NTP is detached at bottom of content view, toolbar
- // overlap is irrelevant. So set infobar visible to force no toolbar overlap.
- active_bookmark_bar_->set_infobar_visible(true);
- active_bookmark_bar_->SetVisible(true);
-
- int height = active_bookmark_bar_->GetPreferredSize().height();
- active_bookmark_bar_->SetBounds(0, content_bottom.y() - height,
- vertical_layout_rect_.width(), height);
-#if !defined(USE_AURA)
- // Without Aura, the bookmark bar can't be layered on top of the
- // contents_container_. Setting a bottom clip offset on the
- // contents_container_ allows it to tell its child view that it's bigger,
- // and clip it so that a theme background aligned to the bottom
- // or vertically centered is properly aligned whith the bookmark bar view
- // drawing of the bottom of the bitmap.
- contents_container_->SetExtraContentHeight(height);
- contents_split_->SetLeadingBottomOffset(height);
-#endif // !USE_AURA
-}
-
int BrowserViewLayout::LayoutInfoBar(int top) {
InfoBarContainerView* infobar_container = browser_view_->infobar_container_;
// Raise the |infobar_container| by its vertical overlap.
@@ -502,9 +434,32 @@ void BrowserViewLayout::LayoutTabContents(int top, int bottom) {
// The views hierarcy (see browser_view.h for more details):
// contents_split_ -> [contents_container_ | devtools]
+ gfx::Rect contents_bounds;
+ gfx::Rect devtools_bounds;
+
gfx::Rect contents_split_bounds(vertical_layout_rect_.x(), top,
vertical_layout_rect_.width(),
std::max(0, bottom - top));
+ gfx::Point contents_split_offset(
+ contents_split_bounds.x() - contents_split_->bounds().x(),
+ contents_split_bounds.y() - contents_split_->bounds().y());
+
+ // Layout resize corner and calculate reserved contents rects here as all
+ // contents view bounds are already determined, but not yet set at this point,
+ // so contents will be laid out once at most.
+ gfx::Rect browser_reserved_rect;
+ if (!browser_view_->frame_->IsMaximized() &&
+ !browser_view_->frame_->IsFullscreen()) {
+ gfx::Size resize_corner_size = browser_view_->GetResizeCornerSize();
+ if (!resize_corner_size.IsEmpty()) {
+ gfx::Rect bounds = browser_view_->GetContentsBounds();
+ gfx::Point resize_corner_origin(
+ bounds.right() - resize_corner_size.width(),
+ bounds.bottom() - resize_corner_size.height());
+ browser_reserved_rect =
+ gfx::Rect(resize_corner_origin, resize_corner_size);
+ }
+ }
// Now it's safe to actually resize all contents views in the hierarchy.
contents_split_->SetBoundsRect(contents_split_bounds);
@@ -512,11 +467,7 @@ void BrowserViewLayout::LayoutTabContents(int top, int bottom) {
int BrowserViewLayout::GetTopMarginForActiveContent() {
if (!active_bookmark_bar_ || !browser_view_->IsBookmarkBarVisible() ||
- !active_bookmark_bar_->IsDetached() ||
- // For |NTP| mode, detached bookmark bar does NOT overlap with top of
- // content view; instead, it "overlaps" with bottom of content view, which
- // is handled in |LayoutBookmarkBarAtBottom|.
- browser()->search_model()->mode().is_ntp()) {
+ !active_bookmark_bar_->IsDetached()) {
return 0;
}
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view_layout.h ('k') | chrome/browser/ui/views/frame/contents_container.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698