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

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

Issue 3332022: Bunch of match preview tweaks: (Closed)
Patch Set: Add string16 include Created 10 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/views/frame/browser_view_layout.h" 5 #include "chrome/browser/views/frame/browser_view_layout.h"
6 6
7 #include "chrome/browser/find_bar.h" 7 #include "chrome/browser/find_bar.h"
8 #include "chrome/browser/find_bar_controller.h" 8 #include "chrome/browser/find_bar_controller.h"
9 #include "chrome/browser/sidebar/sidebar_manager.h" 9 #include "chrome/browser/sidebar/sidebar_manager.h"
10 #include "chrome/browser/view_ids.h" 10 #include "chrome/browser/view_ids.h"
11 #include "chrome/browser/views/bookmark_bar_view.h" 11 #include "chrome/browser/views/bookmark_bar_view.h"
12 #include "chrome/browser/views/download_shelf_view.h" 12 #include "chrome/browser/views/download_shelf_view.h"
13 #include "chrome/browser/views/frame/browser_frame.h" 13 #include "chrome/browser/views/frame/browser_frame.h"
14 #include "chrome/browser/views/frame/browser_view.h" 14 #include "chrome/browser/views/frame/browser_view.h"
15 #include "chrome/browser/views/frame/contents_container.h"
15 #include "chrome/browser/views/tabs/side_tab_strip.h" 16 #include "chrome/browser/views/tabs/side_tab_strip.h"
16 #include "chrome/browser/views/tabs/tab_strip.h" 17 #include "chrome/browser/views/tabs/tab_strip.h"
17 #include "chrome/browser/views/toolbar_view.h" 18 #include "chrome/browser/views/toolbar_view.h"
18 #include "gfx/scrollbar_size.h" 19 #include "gfx/scrollbar_size.h"
19 #include "views/window/window.h" 20 #include "views/window/window.h"
20 21
21 #if defined(OS_LINUX) 22 #if defined(OS_LINUX)
22 #include "views/window/hit_test.h" 23 #include "views/window/hit_test.h"
23 #endif 24 #endif
24 25
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 active_bookmark_bar_ = NULL; 200 active_bookmark_bar_ = NULL;
200 tabstrip_ = NULL; 201 tabstrip_ = NULL;
201 browser_view_ = static_cast<BrowserView*>(host); 202 browser_view_ = static_cast<BrowserView*>(host);
202 } 203 }
203 204
204 void BrowserViewLayout::Uninstalled(views::View* host) {} 205 void BrowserViewLayout::Uninstalled(views::View* host) {}
205 206
206 void BrowserViewLayout::ViewAdded(views::View* host, views::View* view) { 207 void BrowserViewLayout::ViewAdded(views::View* host, views::View* view) {
207 switch (view->GetID()) { 208 switch (view->GetID()) {
208 case VIEW_ID_CONTENTS_SPLIT: { 209 case VIEW_ID_CONTENTS_SPLIT: {
209 contents_split_ = view; 210 contents_split_ = view;
210 if (SidebarManager::IsSidebarAllowed()) { 211 // TODO: this is fragile, fix.
211 views::View* sidebar_split = contents_split_->GetChildViewAt(0); 212 if (SidebarManager::IsSidebarAllowed()) {
212 contents_container_ = sidebar_split->GetChildViewAt(0); 213 views::View* sidebar_split = contents_split_->GetChildViewAt(0);
213 } else { 214 contents_container_ = static_cast<ContentsContainer*>(
214 contents_container_ = contents_split_->GetChildViewAt(0); 215 sidebar_split->GetChildViewAt(0));
215 } 216 } else {
217 contents_container_ = static_cast<ContentsContainer*>(
218 contents_split_->GetChildViewAt(0));
216 } 219 }
217 break; 220 break;
221 }
218 case VIEW_ID_INFO_BAR_CONTAINER: 222 case VIEW_ID_INFO_BAR_CONTAINER:
219 infobar_container_ = view; 223 infobar_container_ = view;
220 break; 224 break;
221 case VIEW_ID_DOWNLOAD_SHELF: 225 case VIEW_ID_DOWNLOAD_SHELF:
222 download_shelf_ = static_cast<DownloadShelfView*>(view); 226 download_shelf_ = static_cast<DownloadShelfView*>(view);
223 break; 227 break;
224 case VIEW_ID_BOOKMARK_BAR: 228 case VIEW_ID_BOOKMARK_BAR:
225 active_bookmark_bar_ = static_cast<BookmarkBarView*>(view); 229 active_bookmark_bar_ = static_cast<BookmarkBarView*>(view);
226 break; 230 break;
227 case VIEW_ID_TOOLBAR: 231 case VIEW_ID_TOOLBAR:
(...skipping 17 matching lines...) Expand all
245 vertical_layout_rect_ = browser_view_->GetLocalBounds(true); 249 vertical_layout_rect_ = browser_view_->GetLocalBounds(true);
246 int top = LayoutTabStrip(); 250 int top = LayoutTabStrip();
247 if (browser_view_->IsTabStripVisible() && !browser_view_->UseVerticalTabs()) { 251 if (browser_view_->IsTabStripVisible() && !browser_view_->UseVerticalTabs()) {
248 tabstrip_->SetBackgroundOffset(gfx::Point( 252 tabstrip_->SetBackgroundOffset(gfx::Point(
249 tabstrip_->MirroredX() + browser_view_->MirroredX(), 253 tabstrip_->MirroredX() + browser_view_->MirroredX(),
250 browser_view_->frame()->GetHorizontalTabStripVerticalOffset(false))); 254 browser_view_->frame()->GetHorizontalTabStripVerticalOffset(false)));
251 } 255 }
252 top = LayoutToolbar(top); 256 top = LayoutToolbar(top);
253 top = LayoutBookmarkAndInfoBars(top); 257 top = LayoutBookmarkAndInfoBars(top);
254 int bottom = LayoutDownloadShelf(browser_view_->height()); 258 int bottom = LayoutDownloadShelf(browser_view_->height());
259 int active_top_margin = GetTopMarginForActiveContent();
260 top -= active_top_margin;
261 bottom += active_top_margin;
262 contents_container_->SetActiveTopMargin(active_top_margin);
255 LayoutTabContents(top, bottom); 263 LayoutTabContents(top, bottom);
256 // This must be done _after_ we lay out the TabContents since this 264 // This must be done _after_ we lay out the TabContents since this
257 // code calls back into us to find the bounding box the find bar 265 // code calls back into us to find the bounding box the find bar
258 // must be laid out within, and that code depends on the 266 // must be laid out within, and that code depends on the
259 // TabContentsContainer's bounds being up to date. 267 // TabContentsContainer's bounds being up to date.
260 if (browser()->HasFindBarController()) { 268 if (browser()->HasFindBarController()) {
261 browser()->GetFindBarController()->find_bar()->MoveWindowIfNecessary( 269 browser()->GetFindBarController()->find_bar()->MoveWindowIfNecessary(
262 gfx::Rect(), true); 270 gfx::Rect(), true);
263 } 271 }
264 // Align status bubble with the bottom of the contents_container. 272 // Align status bubble with the bottom of the contents_container.
265 browser_view_->LayoutStatusBubble( 273 browser_view_->LayoutStatusBubble(
266 top + contents_container_->bounds().height()); 274 top + contents_container_->bounds().height());
267 browser_view_->SchedulePaint(); 275 browser_view_->SchedulePaint();
268 } 276 }
269 277
270 // Return the preferred size which is the size required to give each 278 // Return the preferred size which is the size required to give each
271 // children their respective preferred size. 279 // children their respective preferred size.
272 gfx::Size BrowserViewLayout::GetPreferredSize(views::View* host) { 280 gfx::Size BrowserViewLayout::GetPreferredSize(views::View* host) {
273 return gfx::Size(); 281 return gfx::Size();
274 } 282 }
275 283
276 ////////////////////////////////////////////////////////////////////////////// 284 //////////////////////////////////////////////////////////////////////////////
277 // BrowserViewLayout, private: 285 // BrowserViewLayout, private:
278 286
287 Browser* BrowserViewLayout::browser() {
288 return browser_view_->browser();
289 }
290
291 const Browser* BrowserViewLayout::browser() const {
292 return browser_view_->browser();
293 }
294
279 int BrowserViewLayout::LayoutTabStrip() { 295 int BrowserViewLayout::LayoutTabStrip() {
280 if (!browser_view_->IsTabStripVisible()) { 296 if (!browser_view_->IsTabStripVisible()) {
281 tabstrip_->SetVisible(false); 297 tabstrip_->SetVisible(false);
282 tabstrip_->SetBounds(0, 0, 0, 0); 298 tabstrip_->SetBounds(0, 0, 0, 0);
283 return 0; 299 return 0;
284 } 300 }
285 301
286 gfx::Rect tabstrip_bounds( 302 gfx::Rect tabstrip_bounds(
287 browser_view_->frame()->GetBoundsForTabStrip(tabstrip_)); 303 browser_view_->frame()->GetBoundsForTabStrip(tabstrip_));
288 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); 304 gfx::Point tabstrip_origin(tabstrip_bounds.origin());
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 366
351 int BrowserViewLayout::LayoutInfoBar(int top) { 367 int BrowserViewLayout::LayoutInfoBar(int top) {
352 bool visible = InfobarVisible(); 368 bool visible = InfobarVisible();
353 int height = visible ? infobar_container_->GetPreferredSize().height() : 0; 369 int height = visible ? infobar_container_->GetPreferredSize().height() : 0;
354 infobar_container_->SetVisible(visible); 370 infobar_container_->SetVisible(visible);
355 infobar_container_->SetBounds(vertical_layout_rect_.x(), top, 371 infobar_container_->SetBounds(vertical_layout_rect_.x(), top,
356 vertical_layout_rect_.width(), height); 372 vertical_layout_rect_.width(), height);
357 return top + height; 373 return top + height;
358 } 374 }
359 375
360 // Layout the TabContents container, between the coordinates |top| and
361 // |bottom|.
362 void BrowserViewLayout::LayoutTabContents(int top, int bottom) { 376 void BrowserViewLayout::LayoutTabContents(int top, int bottom) {
363 contents_split_->SetBounds(vertical_layout_rect_.x(), top, 377 contents_split_->SetBounds(vertical_layout_rect_.x(), top,
364 vertical_layout_rect_.width(), bottom - top); 378 vertical_layout_rect_.width(), bottom - top);
365 } 379 }
366 380
381 int BrowserViewLayout::GetTopMarginForActiveContent() {
382 if (!active_bookmark_bar_ || !browser_view_->IsBookmarkBarVisible() ||
383 !active_bookmark_bar_->IsDetached()) {
384 return 0;
385 }
386
387 if (contents_split_->GetChildViewAt(1) &&
388 contents_split_->GetChildViewAt(1)->IsVisible())
389 return 0;
390
391 if (SidebarManager::IsSidebarAllowed()) {
392 views::View* sidebar_split = contents_split_->GetChildViewAt(0);
393 if (sidebar_split->GetChildViewAt(1) &&
394 sidebar_split->GetChildViewAt(1)->IsVisible())
395 return 0;
396 }
397
398 return active_bookmark_bar_->height();
399 }
400
367 int BrowserViewLayout::LayoutDownloadShelf(int bottom) { 401 int BrowserViewLayout::LayoutDownloadShelf(int bottom) {
368 // Re-layout the shelf either if it is visible or if it's close animation 402 // Re-layout the shelf either if it is visible or if it's close animation
369 // is currently running. 403 // is currently running.
370 if (browser_view_->IsDownloadShelfVisible() || 404 if (browser_view_->IsDownloadShelfVisible() ||
371 (download_shelf_ && download_shelf_->IsClosing())) { 405 (download_shelf_ && download_shelf_->IsClosing())) {
372 bool visible = browser()->SupportsWindowFeature( 406 bool visible = browser()->SupportsWindowFeature(
373 Browser::FEATURE_DOWNLOADSHELF); 407 Browser::FEATURE_DOWNLOADSHELF);
374 DCHECK(download_shelf_); 408 DCHECK(download_shelf_);
375 int height = visible ? download_shelf_->GetPreferredSize().height() : 0; 409 int height = visible ? download_shelf_->GetPreferredSize().height() : 0;
376 download_shelf_->SetVisible(visible); 410 download_shelf_->SetVisible(visible);
377 download_shelf_->SetBounds(vertical_layout_rect_.x(), bottom - height, 411 download_shelf_->SetBounds(vertical_layout_rect_.x(), bottom - height,
378 vertical_layout_rect_.width(), height); 412 vertical_layout_rect_.width(), height);
379 download_shelf_->Layout(); 413 download_shelf_->Layout();
380 bottom -= height; 414 bottom -= height;
381 } 415 }
382 return bottom; 416 return bottom;
383 } 417 }
384 418
385 bool BrowserViewLayout::InfobarVisible() const { 419 bool BrowserViewLayout::InfobarVisible() const {
386 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. 420 // NOTE: Can't check if the size IsEmpty() since it's always 0-width.
387 return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && 421 return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) &&
388 (infobar_container_->GetPreferredSize().height() != 0); 422 (infobar_container_->GetPreferredSize().height() != 0);
389 } 423 }
OLDNEW
« no previous file with comments | « chrome/browser/views/frame/browser_view_layout.h ('k') | chrome/browser/views/frame/contents_container.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698