Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/sidebar/sidebar_manager.h" | |
| 8 #include "chrome/browser/ui/find_bar/find_bar.h" | 7 #include "chrome/browser/ui/find_bar/find_bar.h" |
| 9 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 8 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 10 #include "chrome/browser/ui/view_ids.h" | 9 #include "chrome/browser/ui/view_ids.h" |
| 11 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" | 10 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
| 12 #include "chrome/browser/ui/views/frame/browser_frame.h" | 11 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 13 #include "chrome/browser/ui/views/frame/browser_view.h" | 12 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 14 #include "chrome/browser/ui/views/frame/contents_container.h" | 13 #include "chrome/browser/ui/views/frame/contents_container.h" |
| 15 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" | 14 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" |
| 16 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" | 15 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" |
| 17 #include "chrome/browser/ui/views/tabs/abstract_tab_strip_view.h" | 16 #include "chrome/browser/ui/views/tabs/abstract_tab_strip_view.h" |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 412 | 411 |
| 413 source->SetReservedContentsRect(reserved_rect); | 412 source->SetReservedContentsRect(reserved_rect); |
| 414 } | 413 } |
| 415 | 414 |
| 416 void BrowserViewLayout::LayoutTabContents(int top, int bottom) { | 415 void BrowserViewLayout::LayoutTabContents(int top, int bottom) { |
| 417 // The ultimate idea is to calcualte bounds and reserved areas for all | 416 // The ultimate idea is to calcualte bounds and reserved areas for all |
| 418 // contents views first and then resize them all, so every view | 417 // contents views first and then resize them all, so every view |
| 419 // (and its contents) is resized and laid out only once. | 418 // (and its contents) is resized and laid out only once. |
| 420 | 419 |
| 421 // The views hierarcy (see browser_view.h for more details): | 420 // The views hierarcy (see browser_view.h for more details): |
| 422 // 1) Sidebar is not allowed: | 421 // contents_split_ -> [contents_container_ | devtools] |
| 423 // contents_split_ -> [contents_container_ | devtools] | |
| 424 // 2) Sidebar is allowed: | |
| 425 // contents_split_ -> | |
| 426 // [sidebar_split -> [contents_container_ | sidebar]] | devtools | |
| 427 | 422 |
| 428 gfx::Rect sidebar_split_bounds; | |
| 429 gfx::Rect contents_bounds; | 423 gfx::Rect contents_bounds; |
| 430 gfx::Rect sidebar_bounds; | |
| 431 gfx::Rect devtools_bounds; | 424 gfx::Rect devtools_bounds; |
| 432 | 425 |
| 433 gfx::Rect contents_split_bounds(vertical_layout_rect_.x(), top, | 426 gfx::Rect contents_split_bounds(vertical_layout_rect_.x(), top, |
| 434 vertical_layout_rect_.width(), | 427 vertical_layout_rect_.width(), |
| 435 std::max(0, bottom - top)); | 428 std::max(0, bottom - top)); |
| 436 contents_split_->CalculateChildrenBounds( | |
|
Devlin
2011/12/21 02:11:27
Looking at the CalculateChildrenBounds method, it
Aaron Boodman
2011/12/21 08:38:20
Ben should confirm this.
| |
| 437 contents_split_bounds, &sidebar_split_bounds, &devtools_bounds); | |
| 438 gfx::Point contents_split_offset( | 429 gfx::Point contents_split_offset( |
| 439 contents_split_bounds.x() - contents_split_->bounds().x(), | 430 contents_split_bounds.x() - contents_split_->bounds().x(), |
| 440 contents_split_bounds.y() - contents_split_->bounds().y()); | 431 contents_split_bounds.y() - contents_split_->bounds().y()); |
| 441 gfx::Point sidebar_split_offset(contents_split_offset); | |
| 442 sidebar_split_offset.Offset(sidebar_split_bounds.x(), | |
| 443 sidebar_split_bounds.y()); | |
| 444 | 432 |
| 445 views::SingleSplitView* sidebar_split = browser_view_->sidebar_split_; | 433 // Layout resize corner and calculate reserved contents |
| 446 if (sidebar_split) { | |
| 447 DCHECK(sidebar_split == contents_split_->child_at(0)); | |
| 448 sidebar_split->CalculateChildrenBounds( | |
| 449 sidebar_split_bounds, &contents_bounds, &sidebar_bounds); | |
| 450 } else { | |
| 451 contents_bounds = sidebar_split_bounds; | |
| 452 } | |
| 453 | |
| 454 // Layout resize corner, sidebar mini tabs and calculate reserved contents | |
| 455 // rects here as all contents view bounds are already determined, but not yet | 434 // rects here as all contents view bounds are already determined, but not yet |
| 456 // set at this point, so contents will be laid out once at most. | 435 // set at this point, so contents will be laid out once at most. |
| 457 // TODO(alekseys): layout sidebar minitabs and adjust reserved rect | |
| 458 // accordingly. | |
| 459 gfx::Rect browser_reserved_rect; | 436 gfx::Rect browser_reserved_rect; |
| 460 if (!browser_view_->frame_->IsMaximized() && | 437 if (!browser_view_->frame_->IsMaximized() && |
| 461 !browser_view_->frame_->IsFullscreen()) { | 438 !browser_view_->frame_->IsFullscreen()) { |
| 462 gfx::Size resize_corner_size = browser_view_->GetResizeCornerSize(); | 439 gfx::Size resize_corner_size = browser_view_->GetResizeCornerSize(); |
| 463 if (!resize_corner_size.IsEmpty()) { | 440 if (!resize_corner_size.IsEmpty()) { |
| 464 gfx::Rect bounds = browser_view_->GetContentsBounds(); | 441 gfx::Rect bounds = browser_view_->GetContentsBounds(); |
| 465 gfx::Point resize_corner_origin( | 442 gfx::Point resize_corner_origin( |
| 466 bounds.right() - resize_corner_size.width(), | 443 bounds.right() - resize_corner_size.width(), |
| 467 bounds.bottom() - resize_corner_size.height()); | 444 bounds.bottom() - resize_corner_size.height()); |
| 468 browser_reserved_rect = | 445 browser_reserved_rect = |
| 469 gfx::Rect(resize_corner_origin, resize_corner_size); | 446 gfx::Rect(resize_corner_origin, resize_corner_size); |
| 470 } | 447 } |
| 471 } | 448 } |
| 472 | 449 |
| 473 UpdateReservedContentsRect(browser_reserved_rect, | 450 UpdateReservedContentsRect(browser_reserved_rect, |
| 474 browser_view_->contents_container_, | 451 browser_view_->contents_container_, |
| 475 contents_bounds, | 452 contents_bounds, |
| 476 sidebar_split_offset); | 453 contents_split_offset); |
| 477 if (sidebar_split) { | |
| 478 UpdateReservedContentsRect(browser_reserved_rect, | |
| 479 browser_view_->sidebar_container_, | |
| 480 sidebar_bounds, | |
| 481 sidebar_split_offset); | |
| 482 } | |
| 483 UpdateReservedContentsRect(browser_reserved_rect, | 454 UpdateReservedContentsRect(browser_reserved_rect, |
| 484 browser_view_->devtools_container_, | 455 browser_view_->devtools_container_, |
| 485 devtools_bounds, | 456 devtools_bounds, |
| 486 contents_split_offset); | 457 contents_split_offset); |
| 487 | 458 |
| 488 // Now it's safe to actually resize all contents views in the hierarchy. | 459 // Now it's safe to actually resize all contents views in the hierarchy. |
| 489 contents_split_->SetBoundsRect(contents_split_bounds); | 460 contents_split_->SetBoundsRect(contents_split_bounds); |
| 490 if (sidebar_split) | |
| 491 sidebar_split->SetBoundsRect(sidebar_split_bounds); | |
| 492 } | 461 } |
| 493 | 462 |
| 494 int BrowserViewLayout::GetTopMarginForActiveContent() { | 463 int BrowserViewLayout::GetTopMarginForActiveContent() { |
| 495 if (!active_bookmark_bar_ || !browser_view_->IsBookmarkBarVisible() || | 464 if (!active_bookmark_bar_ || !browser_view_->IsBookmarkBarVisible() || |
| 496 !active_bookmark_bar_->IsDetached()) { | 465 !active_bookmark_bar_->IsDetached()) { |
| 497 return 0; | 466 return 0; |
| 498 } | 467 } |
| 499 | 468 |
| 500 if (contents_split_->child_at(1) && contents_split_->child_at(1)->visible()) | 469 if (contents_split_->child_at(1) && contents_split_->child_at(1)->visible()) |
| 501 return 0; | 470 return 0; |
| 502 | 471 |
| 503 if (SidebarManager::IsSidebarAllowed()) { | |
| 504 views::View* sidebar_split = contents_split_->child_at(0); | |
| 505 if (sidebar_split->child_count() >= 2 && | |
| 506 sidebar_split->child_at(1)->visible()) | |
| 507 return 0; | |
| 508 } | |
| 509 | |
| 510 // Adjust for separator. | 472 // Adjust for separator. |
| 511 return active_bookmark_bar_->height() - | 473 return active_bookmark_bar_->height() - |
| 512 views::NonClientFrameView::kClientEdgeThickness; | 474 views::NonClientFrameView::kClientEdgeThickness; |
| 513 } | 475 } |
| 514 | 476 |
| 515 int BrowserViewLayout::LayoutDownloadShelf(int bottom) { | 477 int BrowserViewLayout::LayoutDownloadShelf(int bottom) { |
| 516 #if !defined(OS_CHROMEOS) || defined(USE_AURA) | 478 #if !defined(OS_CHROMEOS) || defined(USE_AURA) |
| 517 // Re-layout the shelf either if it is visible or if it's close animation | 479 // Re-layout the shelf either if it is visible or if it's close animation |
| 518 // is currently running. ChromiumOS uses ActiveDownloadsUI instead of | 480 // is currently running. ChromiumOS uses ActiveDownloadsUI instead of |
| 519 // DownloadShelf. | 481 // DownloadShelf. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 531 } | 493 } |
| 532 #endif | 494 #endif |
| 533 return bottom; | 495 return bottom; |
| 534 } | 496 } |
| 535 | 497 |
| 536 bool BrowserViewLayout::InfobarVisible() const { | 498 bool BrowserViewLayout::InfobarVisible() const { |
| 537 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. | 499 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. |
| 538 return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && | 500 return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && |
| 539 (infobar_container_->GetPreferredSize().height() != 0); | 501 (infobar_container_->GetPreferredSize().height() != 0); |
| 540 } | 502 } |
| OLD | NEW |