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

Side by Side Diff: chrome/browser/ui/views/frame/browser_view_layout.cc

Issue 11411250: Immersive mode reveals the tabstrip/omnibox on top of web content (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update comment Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/frame/browser_view_layout.h" 5 #include "chrome/browser/ui/views/frame/browser_view_layout.h"
6 6
7 #include "chrome/browser/ui/browser_finder.h" 7 #include "chrome/browser/ui/browser_finder.h"
8 #include "chrome/browser/ui/find_bar/find_bar.h" 8 #include "chrome/browser/ui/find_bar/find_bar.h"
9 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 9 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
10 #include "chrome/browser/ui/search/search_model.h" 10 #include "chrome/browser/ui/search/search_model.h"
11 #include "chrome/browser/ui/search/search_ui.h" 11 #include "chrome/browser/ui/search/search_ui.h"
12 #include "chrome/browser/ui/view_ids.h" 12 #include "chrome/browser/ui/view_ids.h"
13 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 13 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
14 #include "chrome/browser/ui/views/download/download_shelf_view.h" 14 #include "chrome/browser/ui/views/download/download_shelf_view.h"
15 #include "chrome/browser/ui/views/frame/browser_frame.h" 15 #include "chrome/browser/ui/views/frame/browser_frame.h"
16 #include "chrome/browser/ui/views/frame/browser_view.h" 16 #include "chrome/browser/ui/views/frame/browser_view.h"
17 #include "chrome/browser/ui/views/frame/contents_container.h" 17 #include "chrome/browser/ui/views/frame/contents_container.h"
18 #include "chrome/browser/ui/views/immersive_mode_controller.h"
18 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" 19 #include "chrome/browser/ui/views/infobars/infobar_container_view.h"
19 #include "chrome/browser/ui/views/tabs/tab_strip.h" 20 #include "chrome/browser/ui/views/tabs/tab_strip.h"
20 #include "chrome/browser/ui/views/toolbar_view.h" 21 #include "chrome/browser/ui/views/toolbar_view.h"
21 #include "ui/base/hit_test.h" 22 #include "ui/base/hit_test.h"
22 #include "ui/gfx/point.h" 23 #include "ui/gfx/point.h"
23 #include "ui/gfx/scrollbar_size.h" 24 #include "ui/gfx/scrollbar_size.h"
24 #include "ui/gfx/size.h" 25 #include "ui/gfx/size.h"
25 #include "ui/views/controls/single_split_view.h" 26 #include "ui/views/controls/single_split_view.h"
26 #include "ui/views/controls/webview/webview.h" 27 #include "ui/views/controls/webview/webview.h"
27 28
(...skipping 23 matching lines...) Expand all
51 views::View::ConvertPointToTarget(src, dst, point); 52 views::View::ConvertPointToTarget(src, dst, point);
52 return dst->HitTestPoint(*point); 53 return dst->HitTestPoint(*point);
53 } 54 }
54 55
55 } // namespace 56 } // namespace
56 57
57 //////////////////////////////////////////////////////////////////////////////// 58 ////////////////////////////////////////////////////////////////////////////////
58 // BrowserViewLayout, public: 59 // BrowserViewLayout, public:
59 60
60 BrowserViewLayout::BrowserViewLayout() 61 BrowserViewLayout::BrowserViewLayout()
61 : tabstrip_(NULL), 62 : contents_split_(NULL),
62 toolbar_(NULL),
63 contents_split_(NULL),
64 contents_container_(NULL), 63 contents_container_(NULL),
65 infobar_container_(NULL),
66 download_shelf_(NULL), 64 download_shelf_(NULL),
67 active_bookmark_bar_(NULL), 65 active_bookmark_bar_(NULL),
68 browser_view_(NULL), 66 browser_view_(NULL),
69 find_bar_y_(0), 67 find_bar_y_(0),
70 constrained_window_top_y_(-1) { 68 constrained_window_top_y_(-1) {
71 } 69 }
72 70
73 BrowserViewLayout::~BrowserViewLayout() { 71 BrowserViewLayout::~BrowserViewLayout() {
74 } 72 }
75 73
76 bool BrowserViewLayout::GetConstrainedWindowTopY(int* top_y) { 74 bool BrowserViewLayout::GetConstrainedWindowTopY(int* top_y) {
77 DCHECK(top_y); 75 DCHECK(top_y);
78 *top_y = constrained_window_top_y_; 76 *top_y = constrained_window_top_y_;
79 return (constrained_window_top_y_ >= 0); 77 return (constrained_window_top_y_ >= 0);
80 } 78 }
81 79
82 gfx::Size BrowserViewLayout::GetMinimumSize() { 80 gfx::Size BrowserViewLayout::GetMinimumSize() {
83 gfx::Size tabstrip_size( 81 gfx::Size tabstrip_size(
84 browser()->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ? 82 browser()->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ?
85 tabstrip_->GetMinimumSize() : gfx::Size()); 83 browser_view_->tabstrip_->GetMinimumSize() : gfx::Size());
86 BrowserNonClientFrameView::TabStripInsets tab_strip_insets( 84 BrowserNonClientFrameView::TabStripInsets tab_strip_insets(
87 browser_view_->frame()->GetTabStripInsets(false)); 85 browser_view_->frame()->GetTabStripInsets(false));
88 gfx::Size toolbar_size( 86 gfx::Size toolbar_size(
89 (browser()->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || 87 (browser()->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) ||
90 browser()->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) ? 88 browser()->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) ?
91 toolbar_->GetMinimumSize() : gfx::Size()); 89 browser_view_->toolbar_->GetMinimumSize() : gfx::Size());
92 if (tabstrip_size.height() && toolbar_size.height()) 90 if (tabstrip_size.height() && toolbar_size.height())
93 toolbar_size.Enlarge(0, -kToolbarTabStripVerticalOverlap); 91 toolbar_size.Enlarge(0, -kToolbarTabStripVerticalOverlap);
94 gfx::Size bookmark_bar_size; 92 gfx::Size bookmark_bar_size;
95 if (active_bookmark_bar_ && 93 if (active_bookmark_bar_ &&
96 browser()->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR)) { 94 browser()->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR)) {
97 bookmark_bar_size = active_bookmark_bar_->GetMinimumSize(); 95 bookmark_bar_size = active_bookmark_bar_->GetMinimumSize();
98 bookmark_bar_size.Enlarge(0, 96 bookmark_bar_size.Enlarge(0,
99 -(views::NonClientFrameView::kClientEdgeThickness + 97 -(views::NonClientFrameView::kClientEdgeThickness +
100 active_bookmark_bar_->GetToolbarOverlap(true))); 98 active_bookmark_bar_->GetToolbarOverlap(true)));
101 } 99 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 int scrollbar_width = gfx::scrollbar_size(); 136 int scrollbar_width = gfx::scrollbar_size();
139 bounding_box.set_width(std::max(0, bounding_box.width() - scrollbar_width)); 137 bounding_box.set_width(std::max(0, bounding_box.width() - scrollbar_width));
140 if (base::i18n::IsRTL()) 138 if (base::i18n::IsRTL())
141 bounding_box.set_x(bounding_box.x() + scrollbar_width); 139 bounding_box.set_x(bounding_box.x() + scrollbar_width);
142 140
143 return bounding_box; 141 return bounding_box;
144 } 142 }
145 143
146 bool BrowserViewLayout::IsPositionInWindowCaption( 144 bool BrowserViewLayout::IsPositionInWindowCaption(
147 const gfx::Point& point) { 145 const gfx::Point& point) {
146 TabStrip* tabstrip = browser_view_->tabstrip_;
147 // Tab strip may transiently have no parent between the RemoveChildView() and
148 // AddChildView() caused by reparenting during an immersive mode reveal.
149 // During this window report that the point didn't hit a tab.
150 if (!tabstrip->parent())
151 return true;
148 gfx::Point tabstrip_point(point); 152 gfx::Point tabstrip_point(point);
149 views::View::ConvertPointToTarget(browser_view_, tabstrip_, &tabstrip_point); 153 views::View::ConvertPointToTarget(browser_view_, tabstrip, &tabstrip_point);
150 return tabstrip_->IsPositionInWindowCaption(tabstrip_point); 154 return tabstrip->IsPositionInWindowCaption(tabstrip_point);
151 } 155 }
152 156
153 int BrowserViewLayout::NonClientHitTest( 157 int BrowserViewLayout::NonClientHitTest(
154 const gfx::Point& point) { 158 const gfx::Point& point) {
155 // Since the TabStrip only renders in some parts of the top of the window, 159 // Since the TabStrip only renders in some parts of the top of the window,
156 // the un-obscured area is considered to be part of the non-client caption 160 // the un-obscured area is considered to be part of the non-client caption
157 // area of the window. So we need to treat hit-tests in these regions as 161 // area of the window. So we need to treat hit-tests in these regions as
158 // hit-tests of the titlebar. 162 // hit-tests of the titlebar.
159 163
160 views::View* parent = browser_view_->parent(); 164 views::View* parent = browser_view_->parent();
161 165
162 gfx::Point point_in_browser_view_coords(point); 166 gfx::Point point_in_browser_view_coords(point);
163 views::View::ConvertPointToTarget( 167 views::View::ConvertPointToTarget(
164 parent, browser_view_, &point_in_browser_view_coords); 168 parent, browser_view_, &point_in_browser_view_coords);
165 gfx::Point test_point(point); 169 gfx::Point test_point(point);
166 170
167 // Determine if the TabStrip exists and is capable of being clicked on. We 171 // Determine if the TabStrip exists and is capable of being clicked on. We
168 // might be a popup window without a TabStrip. 172 // might be a popup window without a TabStrip.
169 if (browser_view_->IsTabStripVisible()) { 173 if (browser_view_->IsTabStripVisible()) {
170 // See if the mouse pointer is within the bounds of the TabStrip. 174 // See if the mouse pointer is within the bounds of the TabStrip.
171 if (ConvertedHitTest(parent, tabstrip_, &test_point)) { 175 if (ConvertedHitTest(parent, browser_view_->tabstrip_, &test_point)) {
172 if (tabstrip_->IsPositionInWindowCaption(test_point)) 176 if (browser_view_->tabstrip_->IsPositionInWindowCaption(test_point))
173 return HTCAPTION; 177 return HTCAPTION;
174 return HTCLIENT; 178 return HTCLIENT;
175 } 179 }
176 180
177 // The top few pixels of the TabStrip are a drop-shadow - as we're pretty 181 // The top few pixels of the TabStrip are a drop-shadow - as we're pretty
178 // starved of dragable area, let's give it to window dragging (this also 182 // starved of dragable area, let's give it to window dragging (this also
179 // makes sense visually). 183 // makes sense visually).
180 if (!browser_view_->IsMaximized() && 184 if (!browser_view_->IsMaximized() &&
181 (point_in_browser_view_coords.y() < 185 (point_in_browser_view_coords.y() <
182 (tabstrip_->y() + kTabShadowSize))) { 186 (browser_view_->tabstrip_->y() + kTabShadowSize))) {
183 // We return HTNOWHERE as this is a signal to our containing 187 // We return HTNOWHERE as this is a signal to our containing
184 // NonClientView that it should figure out what the correct hit-test 188 // NonClientView that it should figure out what the correct hit-test
185 // code is given the mouse position... 189 // code is given the mouse position...
186 return HTNOWHERE; 190 return HTNOWHERE;
187 } 191 }
188 } 192 }
189 193
190 // If the point's y coordinate is below the top of the toolbar and otherwise 194 // If the point's y coordinate is below the top of the toolbar and otherwise
191 // within the bounds of this view, the point is considered to be within the 195 // within the bounds of this view, the point is considered to be within the
192 // client area. 196 // client area.
193 gfx::Rect bv_bounds = browser_view_->bounds(); 197 gfx::Rect bv_bounds = browser_view_->bounds();
194 bv_bounds.Offset(0, toolbar_->y()); 198 bv_bounds.Offset(0, browser_view_->toolbar_->y());
195 bv_bounds.set_height(bv_bounds.height() - toolbar_->y()); 199 bv_bounds.set_height(bv_bounds.height() - browser_view_->toolbar_->y());
196 if (bv_bounds.Contains(point)) 200 if (bv_bounds.Contains(point))
197 return HTCLIENT; 201 return HTCLIENT;
198 202
199 // If the point's y coordinate is above the top of the toolbar, but not in 203 // If the point's y coordinate is above the top of the toolbar, but not in
200 // the tabstrip (per previous checking in this function), then we consider it 204 // the tabstrip (per previous checking in this function), then we consider it
201 // in the window caption (e.g. the area to the right of the tabstrip 205 // in the window caption (e.g. the area to the right of the tabstrip
202 // underneath the window controls). However, note that we DO NOT return 206 // underneath the window controls). However, note that we DO NOT return
203 // HTCAPTION here, because when the window is maximized the window controls 207 // HTCAPTION here, because when the window is maximized the window controls
204 // will fall into this space (since the BrowserView is sized to entire size 208 // will fall into this space (since the BrowserView is sized to entire size
205 // of the window at that point), and the HTCAPTION value will cause the 209 // of the window at that point), and the HTCAPTION value will cause the
206 // window controls not to work. So we return HTNOWHERE so that the caller 210 // window controls not to work. So we return HTNOWHERE so that the caller
207 // will hit-test the window controls before finally falling back to 211 // will hit-test the window controls before finally falling back to
208 // HTCAPTION. 212 // HTCAPTION.
209 bv_bounds = browser_view_->bounds(); 213 bv_bounds = browser_view_->bounds();
210 bv_bounds.set_height(toolbar_->y()); 214 bv_bounds.set_height(browser_view_->toolbar_->y());
211 if (bv_bounds.Contains(point)) 215 if (bv_bounds.Contains(point))
212 return HTNOWHERE; 216 return HTNOWHERE;
213 217
214 // If the point is somewhere else, delegate to the default implementation. 218 // If the point is somewhere else, delegate to the default implementation.
215 return browser_view_->views::ClientView::NonClientHitTest(point); 219 return browser_view_->views::ClientView::NonClientHitTest(point);
216 } 220 }
217 221
218 ////////////////////////////////////////////////////////////////////////////// 222 //////////////////////////////////////////////////////////////////////////////
219 // BrowserViewLayout, views::LayoutManager implementation: 223 // BrowserViewLayout, views::LayoutManager implementation:
220 224
221 void BrowserViewLayout::Installed(views::View* host) { 225 void BrowserViewLayout::Installed(views::View* host) {
222 toolbar_ = NULL;
223 contents_split_ = NULL; 226 contents_split_ = NULL;
224 contents_container_ = NULL; 227 contents_container_ = NULL;
225 infobar_container_ = NULL;
226 download_shelf_ = NULL; 228 download_shelf_ = NULL;
227 active_bookmark_bar_ = NULL; 229 active_bookmark_bar_ = NULL;
228 tabstrip_ = NULL;
229 browser_view_ = static_cast<BrowserView*>(host); 230 browser_view_ = static_cast<BrowserView*>(host);
230 } 231 }
231 232
232 void BrowserViewLayout::Uninstalled(views::View* host) {} 233 void BrowserViewLayout::Uninstalled(views::View* host) {}
233 234
234 void BrowserViewLayout::ViewAdded(views::View* host, views::View* view) { 235 void BrowserViewLayout::ViewAdded(views::View* host, views::View* view) {
235 switch (view->id()) { 236 switch (view->id()) {
236 case VIEW_ID_CONTENTS_SPLIT: { 237 case VIEW_ID_CONTENTS_SPLIT: {
237 contents_split_ = static_cast<views::SingleSplitView*>(view); 238 contents_split_ = static_cast<views::SingleSplitView*>(view);
238 // We're installed as the LayoutManager before BrowserView creates the 239 // We're installed as the LayoutManager before BrowserView creates the
239 // contents, so we have to set contents_container_ here rather than in 240 // contents, so we have to set contents_container_ here rather than in
240 // Installed. 241 // Installed.
241 contents_container_ = browser_view_->contents_; 242 contents_container_ = browser_view_->contents_;
242 break; 243 break;
243 } 244 }
244 case VIEW_ID_INFO_BAR_CONTAINER:
245 infobar_container_ = view;
246 break;
247 case VIEW_ID_DOWNLOAD_SHELF: 245 case VIEW_ID_DOWNLOAD_SHELF:
248 download_shelf_ = static_cast<DownloadShelfView*>(view); 246 download_shelf_ = static_cast<DownloadShelfView*>(view);
249 break; 247 break;
250 case VIEW_ID_BOOKMARK_BAR: 248 case VIEW_ID_BOOKMARK_BAR:
251 active_bookmark_bar_ = static_cast<BookmarkBarView*>(view); 249 active_bookmark_bar_ = static_cast<BookmarkBarView*>(view);
252 break; 250 break;
253 case VIEW_ID_TOOLBAR:
254 toolbar_ = static_cast<ToolbarView*>(view);
255 break;
256 case VIEW_ID_TAB_STRIP:
257 tabstrip_ = static_cast<TabStrip*>(view);
258 break;
259 } 251 }
260 } 252 }
261 253
262 void BrowserViewLayout::ViewRemoved(views::View* host, views::View* view) { 254 void BrowserViewLayout::ViewRemoved(views::View* host, views::View* view) {
263 switch (view->id()) { 255 switch (view->id()) {
264 case VIEW_ID_BOOKMARK_BAR: 256 case VIEW_ID_BOOKMARK_BAR:
265 active_bookmark_bar_ = NULL; 257 active_bookmark_bar_ = NULL;
266 break; 258 break;
267 } 259 }
268 } 260 }
269 261
270 void BrowserViewLayout::Layout(views::View* host) { 262 void BrowserViewLayout::Layout(views::View* host) {
271 vertical_layout_rect_ = browser_view_->GetLocalBounds(); 263 vertical_layout_rect_ = browser_view_->GetLocalBounds();
272 int top = LayoutTabStripRegion(); 264 int top = LayoutTabStripRegion();
273 if (browser_view_->IsTabStripVisible()) { 265 if (browser_view_->IsTabStripVisible()) {
274 int x = tabstrip_->GetMirroredX() + browser_view_->GetMirroredX() + 266 int x = browser_view_->tabstrip_->GetMirroredX() +
267 browser_view_->GetMirroredX() +
275 browser_view_->frame()->GetThemeBackgroundXInset(); 268 browser_view_->frame()->GetThemeBackgroundXInset();
276 tabstrip_->SetBackgroundOffset(gfx::Point(x, 269 browser_view_->tabstrip_->SetBackgroundOffset(gfx::Point(x,
277 browser_view_->frame()->GetTabStripInsets(false).top)); 270 browser_view_->frame()->GetTabStripInsets(false).top));
278 } 271 }
279 top = LayoutToolbar(top); 272 top = LayoutToolbar(top);
280 top = LayoutBookmarkAndInfoBars(top); 273 top = LayoutBookmarkAndInfoBars(top);
274 // During immersive mode reveal the content stays near the top of the view.
275 if (browser_view_->immersive_mode_controller()->IsRevealed())
276 top = browser_view_->tabstrip_->x() + TabStrip::GetImmersiveHeight();
277
281 int bottom = LayoutDownloadShelf(browser_view_->height()); 278 int bottom = LayoutDownloadShelf(browser_view_->height());
282 int active_top_margin = GetTopMarginForActiveContent(); 279 int active_top_margin = GetTopMarginForActiveContent();
283 top -= active_top_margin; 280 top -= active_top_margin;
284 contents_container_->SetActiveTopMargin(active_top_margin); 281 contents_container_->SetActiveTopMargin(active_top_margin);
285 LayoutTabContents(top, bottom); 282 LayoutTabContents(top, bottom);
286 // This must be done _after_ we lay out the WebContents since this 283 // This must be done _after_ we lay out the WebContents since this
287 // code calls back into us to find the bounding box the find bar 284 // code calls back into us to find the bounding box the find bar
288 // must be laid out within, and that code depends on the 285 // must be laid out within, and that code depends on the
289 // TabContentsContainer's bounds being up to date. 286 // TabContentsContainer's bounds being up to date.
290 if (browser()->HasFindBarController()) { 287 if (browser()->HasFindBarController()) {
(...skipping 23 matching lines...) Expand all
314 311
315 Browser* BrowserViewLayout::browser() { 312 Browser* BrowserViewLayout::browser() {
316 return browser_view_->browser(); 313 return browser_view_->browser();
317 } 314 }
318 315
319 const Browser* BrowserViewLayout::browser() const { 316 const Browser* BrowserViewLayout::browser() const {
320 return browser_view_->browser(); 317 return browser_view_->browser();
321 } 318 }
322 319
323 int BrowserViewLayout::LayoutTabStripRegion() { 320 int BrowserViewLayout::LayoutTabStripRegion() {
321 TabStrip* tabstrip = browser_view_->tabstrip_;
324 if (!browser_view_->IsTabStripVisible()) { 322 if (!browser_view_->IsTabStripVisible()) {
325 tabstrip_->SetVisible(false); 323 tabstrip->SetVisible(false);
326 tabstrip_->SetBounds(0, 0, 0, 0); 324 tabstrip->SetBounds(0, 0, 0, 0);
327 return 0; 325 return 0;
328 } 326 }
329 // This retrieves the bounds for the tab strip based on whether or not we show 327 // This retrieves the bounds for the tab strip based on whether or not we show
330 // anything to the left of it, like the incognito avatar. 328 // anything to the left of it, like the incognito avatar.
331 gfx::Rect tabstrip_bounds( 329 gfx::Rect tabstrip_bounds(
332 browser_view_->frame()->GetBoundsForTabStrip(tabstrip_)); 330 browser_view_->frame()->GetBoundsForTabStrip(tabstrip));
333 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); 331 gfx::Point tabstrip_origin(tabstrip_bounds.origin());
334 views::View::ConvertPointToTarget(browser_view_->parent(), browser_view_, 332 views::View::ConvertPointToTarget(browser_view_->parent(), browser_view_,
335 &tabstrip_origin); 333 &tabstrip_origin);
336 tabstrip_bounds.set_origin(tabstrip_origin); 334 tabstrip_bounds.set_origin(tabstrip_origin);
337 335
338 tabstrip_->SetVisible(true); 336 tabstrip->SetVisible(true);
339 tabstrip_->SetBoundsRect(tabstrip_bounds); 337 tabstrip->SetBoundsRect(tabstrip_bounds);
340 int bottom = tabstrip_bounds.bottom(); 338 int bottom = tabstrip_bounds.bottom();
341 339
342 // The metro window switcher sits at the far right edge of the tabstrip 340 // The metro window switcher sits at the far right edge of the tabstrip
343 // a |kWindowSwitcherOffsetX| pixels from the right edge. 341 // a |kWindowSwitcherOffsetX| pixels from the right edge.
344 // Only visible if there is more than one type of window to switch between. 342 // Only visible if there is more than one type of window to switch between.
345 // TODO(mad): update this code when more window types than just incognito 343 // TODO(mad): update this code when more window types than just incognito
346 // and regular are available. 344 // and regular are available.
347 views::Button* switcher_button = browser_view_->window_switcher_button_; 345 views::Button* switcher_button = browser_view_->window_switcher_button_;
348 if (switcher_button) { 346 if (switcher_button) {
349 if (browser()->profile()->HasOffTheRecordProfile() && 347 if (browser()->profile()->HasOffTheRecordProfile() &&
(...skipping 16 matching lines...) Expand all
366 // ::SetWindowPos( , .. SWP_SHOWWINDOW) which causes this function to 364 // ::SetWindowPos( , .. SWP_SHOWWINDOW) which causes this function to
367 // be called again. This works both in showing or hidding the button. 365 // be called again. This works both in showing or hidding the button.
368 switcher_button->SetVisible(false); 366 switcher_button->SetVisible(false);
369 } 367 }
370 } 368 }
371 369
372 return bottom; 370 return bottom;
373 } 371 }
374 372
375 int BrowserViewLayout::LayoutToolbar(int top) { 373 int BrowserViewLayout::LayoutToolbar(int top) {
374 ToolbarView* toolbar = browser_view_->toolbar_;
376 int browser_view_width = vertical_layout_rect_.width(); 375 int browser_view_width = vertical_layout_rect_.width();
377 bool toolbar_visible = browser_view_->IsToolbarVisible(); 376 bool toolbar_visible = browser_view_->IsToolbarVisible();
378 toolbar_->location_bar()->SetLocationEntryFocusable(toolbar_visible); 377 toolbar->location_bar()->SetLocationEntryFocusable(toolbar_visible);
379 int y = top; 378 int y = top;
380 y -= (toolbar_visible && browser_view_->IsTabStripVisible()) ? 379 y -= (toolbar_visible && browser_view_->IsTabStripVisible()) ?
381 kToolbarTabStripVerticalOverlap : 0; 380 kToolbarTabStripVerticalOverlap : 0;
382 int height = toolbar_visible ? toolbar_->GetPreferredSize().height() : 0; 381 int height = toolbar_visible ? toolbar->GetPreferredSize().height() : 0;
383 toolbar_->SetVisible(toolbar_visible); 382 toolbar->SetVisible(toolbar_visible);
384 toolbar_->SetBounds(vertical_layout_rect_.x(), y, browser_view_width, height); 383 toolbar->SetBounds(vertical_layout_rect_.x(), y, browser_view_width, height);
385 384
386 return y + height; 385 return y + height;
387 } 386 }
388 387
389 int BrowserViewLayout::LayoutBookmarkAndInfoBars(int top) { 388 int BrowserViewLayout::LayoutBookmarkAndInfoBars(int top) {
390 constrained_window_top_y_ = 389 constrained_window_top_y_ =
391 top + browser_view_->y() - kConstrainedWindowOverlap; 390 top + browser_view_->y() - kConstrainedWindowOverlap;
392 find_bar_y_ = top + browser_view_->y() - 1; 391 find_bar_y_ = top + browser_view_->y() - 1;
393 if (active_bookmark_bar_) { 392 if (active_bookmark_bar_) {
394 // If the bookmark bar is showing in detached style: 393 // If the bookmark bar is showing in detached style:
395 // - for non-NTP mode, show any Info bar _above_ the bookmark bar, since the 394 // - for non-NTP mode, show any Info bar _above_ the bookmark bar, since the
396 // bookmark bar is styled to look like it's part of the page. 395 // bookmark bar is styled to look like it's part of the page.
397 // - otherwise, show the bookmark bar at the bottom of content view, so just 396 // - otherwise, show the bookmark bar at the bottom of content view, so just
398 // lay out infobar here; bottom bookmark bar is laid out in 397 // lay out infobar here; bottom bookmark bar is laid out in
399 // |LayoutBookmarkBarAtBottom|. 398 // |LayoutBookmarkBarAtBottom|.
400 if (active_bookmark_bar_->IsDetached()) { 399 if (active_bookmark_bar_->IsDetached()) {
401 int infobar_top = LayoutInfoBar(top); 400 int infobar_top = LayoutInfoBar(top);
402 return browser()->search_model()->mode().is_ntp() ? 401 return browser()->search_model()->mode().is_ntp() ?
403 infobar_top : LayoutBookmarkBarAtTop(infobar_top); 402 infobar_top : LayoutBookmarkBarAtTop(infobar_top);
404 } 403 }
405 // Otherwise, Bookmark bar first, Info bar second. 404 // Otherwise, Bookmark bar first, Info bar second.
406 top = std::max(toolbar_->bounds().bottom(), LayoutBookmarkBarAtTop(top)); 405 top = std::max(browser_view_->toolbar_->bounds().bottom(),
406 LayoutBookmarkBarAtTop(top));
407 } 407 }
408 find_bar_y_ = top + browser_view_->y() - 1; 408 find_bar_y_ = top + browser_view_->y() - 1;
409 return LayoutInfoBar(top); 409 return LayoutInfoBar(top);
410 } 410 }
411 411
412 int BrowserViewLayout::LayoutBookmarkBarAtTop(int top) { 412 int BrowserViewLayout::LayoutBookmarkBarAtTop(int top) {
413 DCHECK(active_bookmark_bar_); 413 DCHECK(active_bookmark_bar_);
414 int y = top; 414 int y = top;
415 if (!browser_view_->IsBookmarkBarVisible()) { 415 if (!browser_view_->IsBookmarkBarVisible()) {
416 active_bookmark_bar_->SetVisible(false); 416 active_bookmark_bar_->SetVisible(false);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 // contents_container_ allows it to tell its child view that it's bigger, 472 // contents_container_ allows it to tell its child view that it's bigger,
473 // and clip it so that a theme background aligned to the bottom 473 // and clip it so that a theme background aligned to the bottom
474 // or vertically centered is properly aligned whith the bookmark bar view 474 // or vertically centered is properly aligned whith the bookmark bar view
475 // drawing of the bottom of the bitmap. 475 // drawing of the bottom of the bitmap.
476 contents_container_->SetExtraContentHeight(height); 476 contents_container_->SetExtraContentHeight(height);
477 contents_split_->SetLeadingBottomOffset(height); 477 contents_split_->SetLeadingBottomOffset(height);
478 #endif // !USE_AURA 478 #endif // !USE_AURA
479 } 479 }
480 480
481 int BrowserViewLayout::LayoutInfoBar(int top) { 481 int BrowserViewLayout::LayoutInfoBar(int top) {
482 // Raise the |infobar_container_| by its vertical overlap. 482 InfoBarContainerView* infobar_container = browser_view_->infobar_container_;
483 infobar_container_->SetVisible(InfobarVisible()); 483 // Raise the |infobar_container| by its vertical overlap.
484 infobar_container->SetVisible(InfobarVisible());
484 int height; 485 int height;
485 int overlapped_top = top - 486 int overlapped_top = top - infobar_container->GetVerticalOverlap(&height);
486 static_cast<InfoBarContainerView*>(infobar_container_)-> 487 infobar_container->SetBounds(vertical_layout_rect_.x(),
487 GetVerticalOverlap(&height); 488 overlapped_top,
488 infobar_container_->SetBounds(vertical_layout_rect_.x(), 489 vertical_layout_rect_.width(),
489 overlapped_top, 490 height);
490 vertical_layout_rect_.width(),
491 height);
492 return overlapped_top + height; 491 return overlapped_top + height;
493 } 492 }
494 493
495 void BrowserViewLayout::LayoutTabContents(int top, int bottom) { 494 void BrowserViewLayout::LayoutTabContents(int top, int bottom) {
496 // The ultimate idea is to calculate bounds and reserved areas for all 495 // The ultimate idea is to calculate bounds and reserved areas for all
497 // contents views first and then resize them all, so every view 496 // contents views first and then resize them all, so every view
498 // (and its contents) is resized and laid out only once. 497 // (and its contents) is resized and laid out only once.
499 498
500 // The views hierarcy (see browser_view.h for more details): 499 // The views hierarcy (see browser_view.h for more details):
501 // contents_split_ -> [contents_container_ | devtools] 500 // contents_split_ -> [contents_container_ | devtools]
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 download_shelf_->SetVisible(visible); 537 download_shelf_->SetVisible(visible);
539 download_shelf_->SetBounds(vertical_layout_rect_.x(), bottom - height, 538 download_shelf_->SetBounds(vertical_layout_rect_.x(), bottom - height,
540 vertical_layout_rect_.width(), height); 539 vertical_layout_rect_.width(), height);
541 download_shelf_->Layout(); 540 download_shelf_->Layout();
542 bottom -= height; 541 bottom -= height;
543 } 542 }
544 return bottom; 543 return bottom;
545 } 544 }
546 545
547 bool BrowserViewLayout::InfobarVisible() const { 546 bool BrowserViewLayout::InfobarVisible() const {
547 views::View* infobar_container = browser_view_->infobar_container_;
548 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. 548 // NOTE: Can't check if the size IsEmpty() since it's always 0-width.
549 return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && 549 return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) &&
550 (infobar_container_->GetPreferredSize().height() != 0); 550 (infobar_container->GetPreferredSize().height() != 0);
551 } 551 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view_layout.h ('k') | chrome/browser/ui/views/immersive_mode_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698