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 68198926309d6592fd596c4cf7e24c1eca403a8b..4205a317f16b94346aa682f87c2952d6c6a137d3 100644 |
--- a/chrome/browser/ui/views/frame/browser_view_layout.cc |
+++ b/chrome/browser/ui/views/frame/browser_view_layout.cc |
@@ -29,13 +29,13 @@ |
#include "ui/views/controls/single_split_view.h" |
#include "ui/views/controls/webview/webview.h" |
+using views::View; |
+ |
namespace { |
// The visible height of the shadow above the tabs. Clicks in this area are |
// treated as clicks to the frame, rather than clicks to the tab. |
const int kTabShadowSize = 2; |
-// The vertical overlap between the TabStrip and the Toolbar. |
-const int kToolbarTabStripVerticalOverlap = 3; |
// The number of pixels the bookmark bar should overlap the spacer by if the |
// spacer is visible. |
const int kSpacerBookmarkBarOverlap = 1; |
@@ -100,6 +100,8 @@ class BrowserViewLayout::WebContentsModalDialogHostViews |
DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogHostViews); |
}; |
+// static |
+const int BrowserViewLayout::kToolbarTabStripVerticalOverlap = 3; |
//////////////////////////////////////////////////////////////////////////////// |
// BrowserViewLayout, public: |
@@ -331,26 +333,7 @@ void BrowserViewLayout::Layout(views::View* host) { |
browser_view_->top_container_->GetPreferredSize()); |
int bottom = LayoutDownloadShelf(browser_view_->height()); |
- int active_top_margin = GetTopMarginForActiveContent(); |
- top -= active_top_margin; |
- contents_container_->SetActiveTopMargin(active_top_margin); |
- LayoutTabContents(top, bottom); |
- |
- // Now set the contents to display at their previous origin if we just hid the |
- // bookmark and/or infobars. |
- if (active_top_margin == 0 && !old_contents_origin.IsOrigin()) { |
- gfx::Point new_contents_origin(contents->bounds().origin()); |
- views::View::ConvertPointToTarget(contents->parent(), browser_view_, |
- &new_contents_origin); |
- active_top_margin = old_contents_origin.y() - new_contents_origin.y(); |
- // Special case: While normally the suggestions appear to "cover" any |
- // bookmark/infobars, if the suggestions are very short, they might not |
- // fully cover that gap, and leaving the contents at their original height |
- // would leave an odd-looking blank space. In this case, we allow the |
- // contents to go ahead and shift upward. |
- if (active_top_margin > 0 && active_top_margin < overlay_height) |
- contents_container_->SetActiveTopMargin(active_top_margin); |
- } |
+ LayoutTabContents(top, bottom, old_contents_origin); |
// This must be done _after_ we lay out the WebContents since this |
// code calls back into us to find the bounding box the find bar |
@@ -475,6 +458,8 @@ int BrowserViewLayout::LayoutBookmarkBar(int top) { |
int y = top; |
if (!browser_view_->IsBookmarkBarVisible()) { |
bookmark_bar->SetVisible(false); |
+ // TODO(jamescook): Don't change the bookmark bar height when it is |
+ // invisible, so we can use its height for layout even in that state. |
bookmark_bar->SetBounds(0, y, browser_view_->width(), 0); |
return y; |
} |
@@ -510,43 +495,70 @@ int BrowserViewLayout::LayoutInfoBar(int top) { |
return overlapped_top + height; |
} |
-void BrowserViewLayout::LayoutTabContents(int top, int bottom) { |
- // The ultimate idea is to calculate bounds and reserved areas for all |
- // contents views first and then resize them all, so every view |
- // (and its contents) is resized and laid out only once. |
- |
- // The views hierarcy (see browser_view.h for more details): |
- // contents_split_ -> [contents_container_ | devtools] |
- |
- gfx::Rect contents_bounds; |
- gfx::Rect devtools_bounds; |
+void BrowserViewLayout::LayoutTabContents( |
+ int top, |
+ int bottom, |
+ const gfx::Point& contents_origin) { |
+ // Vertical offsets for the active page and instant overlay. |
+ int active_top_margin = GetTopMarginForActiveContent(); |
+ int overlay_top_margin = 0; |
- gfx::Rect contents_split_bounds(vertical_layout_rect_.x(), top, |
+ // |contents_split_| contains web page contents and devtools. |
+ // See browser_view.h for details. |
+ top -= active_top_margin; |
+ 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); |
+ contents_split_->SetBoundsRect(contents_split_bounds); |
James Cook
2013/04/05 02:05:05
The diff is confusing - LayoutTabContents() contai
kuan
2013/04/08 15:56:30
if SetBoundsRect changes bounds of contents_contai
kuan
2013/04/08 16:05:33
in the scenario that fails, Layout is called separ
|
+ |
+ // During an immersive reveal, if instant extended is showing suggestions |
+ // (either in an overlay web view or the active web view) ensure the |
+ // the web view appears aligned with the bottom of the omnibox. |
+ InstantUIState instant_ui_state = GetInstantUIState(); |
+ if (instant_ui_state != kInstantUINone && |
+ browser_view_->immersive_mode_controller()->IsRevealed()) { |
+ gfx::Point bottom_edge(0, browser_view_->top_container_->height()); |
+ views::View::ConvertPointToTarget(browser_view_->top_container_, |
+ contents_container_, |
+ &bottom_edge); |
+ switch (instant_ui_state) { |
+ case kInstantUINone: |
+ break; |
+ case kInstantUIOverlay: |
+ overlay_top_margin = bottom_edge.y(); |
+ break; |
+ case kInstantUIFullPageResults: |
+ active_top_margin = bottom_edge.y(); |
+ break; |
} |
} |
- // Now it's safe to actually resize all contents views in the hierarchy. |
- contents_split_->SetBoundsRect(contents_split_bounds); |
+ // Now set the contents to display at their previous origin if we just hid the |
+ // bookmark and/or infobars for instant extended. We can't just compute the |
+ // proper position at this point because we don't know the height of all the |
+ // infobars and their arrows. |
+ if (active_top_margin == 0 && !contents_origin.IsOrigin()) { |
+ views::WebView* contents_view = browser_view_->contents_container_; |
+ gfx::Point new_contents_origin(contents_view->bounds().origin()); |
+ views::View::ConvertPointToTarget(contents_view->parent(), |
+ browser_view_, |
+ &new_contents_origin); |
+ int contents_offset = contents_origin.y() - new_contents_origin.y(); |
+ // Special case: While normally the suggestions appear to "cover" any |
+ // bookmark/infobars, if the suggestions are very short, they might not |
+ // fully cover that gap, and leaving the contents at their original height |
+ // would leave an odd-looking blank space. In this case, we allow the |
+ // contents to go ahead and shift upward. |
+ if (contents_offset > 0 && |
+ contents_offset < contents_container_->overlay_height()) |
+ active_top_margin = contents_offset; |
+ } |
+ |
+ // Apply our adjustments to the active page and instant overlay position |
+ // to account for detached bookmark bars, instant extended and immersive mode. |
+ contents_container_->SetWebViewsTopMargins(active_top_margin, |
+ overlay_top_margin); |
} |
int BrowserViewLayout::GetTopMarginForActiveContent() { |
@@ -557,14 +569,31 @@ int BrowserViewLayout::GetTopMarginForActiveContent() { |
return 0; |
} |
+ // Handle dev tools. |
if (contents_split_->child_at(1) && contents_split_->child_at(1)->visible()) |
return 0; |
- // Adjust for separator. |
+ // Offset for the detached bookmark bar. |
return bookmark_bar->height() - |
views::NonClientFrameView::kClientEdgeThickness; |
} |
+BrowserViewLayout::InstantUIState BrowserViewLayout::GetInstantUIState() { |
James Cook
2013/04/05 02:05:05
This is a near-copy of the Mac function currentIns
|
+ if (!browser()->search_model()->mode().is_search_suggestions()) |
+ return kInstantUINone; |
+ |
+ // If the search suggestions are already being displayed in the overlay |
+ // contents then return kInstantUIOverlay. |
+ if (contents_container_->overlay_height() > 0) |
+ return kInstantUIOverlay; |
+ |
+ // Top bars stay visible until the results page notifies Chrome it is ready. |
+ if (browser()->search_model()->top_bars_visible()) |
+ return kInstantUINone; |
+ |
+ return kInstantUIFullPageResults; |
+} |
+ |
int BrowserViewLayout::LayoutDownloadShelf(int bottom) { |
// Re-layout the shelf either if it is visible or if its close animation |
// is currently running. |