OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "base/observer_list.h" | 7 #include "base/observer_list.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_finder.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 // |contents_container_| contains web page contents and devtools. | 516 // |contents_container_| contains web page contents and devtools. |
517 // See browser_view.h for details. | 517 // See browser_view.h for details. |
518 gfx::Rect contents_container_bounds(vertical_layout_rect_.x(), | 518 gfx::Rect contents_container_bounds(vertical_layout_rect_.x(), |
519 top, | 519 top, |
520 vertical_layout_rect_.width(), | 520 vertical_layout_rect_.width(), |
521 std::max(0, bottom - top)); | 521 std::max(0, bottom - top)); |
522 contents_container_->SetBoundsRect(contents_container_bounds); | 522 contents_container_->SetBoundsRect(contents_container_bounds); |
523 } | 523 } |
524 | 524 |
525 void BrowserViewLayout::UpdateTopContainerBounds() { | 525 void BrowserViewLayout::UpdateTopContainerBounds() { |
526 gfx::Rect top_container_bounds(top_container_->GetPreferredSize()); | 526 // Set the bounds of the top container view such that it is tall enough to |
| 527 // fully show all of its children. In particular, the bottom of the bookmark |
| 528 // bar can be above the bottom of the toolbar while the bookmark bar is |
| 529 // animating. The top container view is positioned relative to the top of the |
| 530 // client view instead of relative to GetTopInsetInBrowserView() because the |
| 531 // top container view paints parts of the frame (title, window controls) |
| 532 // during an immersive fullscreen reveal. |
| 533 int height = 0; |
| 534 for (int i = 0; i < top_container_->child_count(); ++i) { |
| 535 views::View* child = top_container_->child_at(i); |
| 536 if (!child->visible()) |
| 537 continue; |
| 538 int child_bottom = child->bounds().bottom(); |
| 539 if (child_bottom > height) |
| 540 height = child_bottom; |
| 541 } |
| 542 |
| 543 // Ensure that the top container view reaches the topmost view in the |
| 544 // ClientView because the bounds of the top container view are used in |
| 545 // layout and we assume that this is the case. |
| 546 height = std::max(height, delegate_->GetTopInsetInBrowserView()); |
| 547 |
| 548 gfx::Rect top_container_bounds(vertical_layout_rect_.width(), height); |
527 | 549 |
528 // If the immersive mode controller is animating the top container, it may be | 550 // If the immersive mode controller is animating the top container, it may be |
529 // partly offscreen. The top container is positioned relative to the top of | 551 // partly offscreen. |
530 // the client view instead of relative to GetTopInsetInBrowserView() because | |
531 // the top container paints parts of the frame (title, window controls) during | |
532 // an immersive reveal. | |
533 top_container_bounds.set_y( | 552 top_container_bounds.set_y( |
534 immersive_mode_controller_->GetTopContainerVerticalOffset( | 553 immersive_mode_controller_->GetTopContainerVerticalOffset( |
535 top_container_bounds.size())); | 554 top_container_bounds.size())); |
536 top_container_->SetBoundsRect(top_container_bounds); | 555 top_container_->SetBoundsRect(top_container_bounds); |
537 } | 556 } |
538 | 557 |
539 int BrowserViewLayout::GetContentsOffsetForBookmarkBar() { | 558 int BrowserViewLayout::GetContentsOffsetForBookmarkBar() { |
540 // If the bookmark bar is hidden or attached to the omnibox the web contents | 559 // If the bookmark bar is hidden or attached to the omnibox the web contents |
541 // will appear directly underneath it and does not need an offset. | 560 // will appear directly underneath it and does not need an offset. |
542 if (!bookmark_bar_ || | 561 if (!bookmark_bar_ || |
(...skipping 22 matching lines...) Expand all Loading... |
565 return bottom; | 584 return bottom; |
566 } | 585 } |
567 | 586 |
568 bool BrowserViewLayout::InfobarVisible() const { | 587 bool BrowserViewLayout::InfobarVisible() const { |
569 // Cast to a views::View to access GetPreferredSize(). | 588 // Cast to a views::View to access GetPreferredSize(). |
570 views::View* infobar_container = infobar_container_; | 589 views::View* infobar_container = infobar_container_; |
571 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. | 590 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. |
572 return browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && | 591 return browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && |
573 (infobar_container->GetPreferredSize().height() != 0); | 592 (infobar_container->GetPreferredSize().height() != 0); |
574 } | 593 } |
OLD | NEW |