| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 if (bookmark_bar_ && | 197 if (bookmark_bar_ && |
| 198 bookmark_bar_->visible() && | 198 bookmark_bar_->visible() && |
| 199 browser()->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR)) { | 199 browser()->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR)) { |
| 200 bookmark_bar_size = bookmark_bar_->GetMinimumSize(); | 200 bookmark_bar_size = bookmark_bar_->GetMinimumSize(); |
| 201 bookmark_bar_size.Enlarge(0, -bookmark_bar_->GetToolbarOverlap()); | 201 bookmark_bar_size.Enlarge(0, -bookmark_bar_->GetToolbarOverlap()); |
| 202 } | 202 } |
| 203 // TODO: Adjust the minimum height for the find bar. | 203 // TODO: Adjust the minimum height for the find bar. |
| 204 | 204 |
| 205 gfx::Size contents_size(contents_split_->GetMinimumSize()); | 205 gfx::Size contents_size(contents_split_->GetMinimumSize()); |
| 206 | 206 |
| 207 int min_height = tabstrip_size.height() + toolbar_size.height() + | 207 int min_height = delegate_->GetTopInsetInBrowserView() + |
| 208 tabstrip_size.height() + toolbar_size.height() + |
| 208 bookmark_bar_size.height() + contents_size.height(); | 209 bookmark_bar_size.height() + contents_size.height(); |
| 209 int widths[] = { | 210 int widths[] = { |
| 210 tabstrip_size.width(), | 211 tabstrip_size.width(), |
| 211 toolbar_size.width(), | 212 toolbar_size.width(), |
| 212 bookmark_bar_size.width(), | 213 bookmark_bar_size.width(), |
| 213 contents_size.width() }; | 214 contents_size.width() }; |
| 214 int min_width = *std::max_element(&widths[0], &widths[arraysize(widths)]); | 215 int min_width = *std::max_element(&widths[0], &widths[arraysize(widths)]); |
| 215 return gfx::Size(min_width, min_height); | 216 return gfx::Size(min_width, min_height); |
| 216 } | 217 } |
| 217 | 218 |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 gfx::Rect contents_split_bounds(vertical_layout_rect_.x(), | 526 gfx::Rect contents_split_bounds(vertical_layout_rect_.x(), |
| 526 top, | 527 top, |
| 527 vertical_layout_rect_.width(), | 528 vertical_layout_rect_.width(), |
| 528 std::max(0, bottom - top)); | 529 std::max(0, bottom - top)); |
| 529 contents_split_->SetBoundsRect(contents_split_bounds); | 530 contents_split_->SetBoundsRect(contents_split_bounds); |
| 530 } | 531 } |
| 531 | 532 |
| 532 void BrowserViewLayout::UpdateTopContainerBounds() { | 533 void BrowserViewLayout::UpdateTopContainerBounds() { |
| 533 gfx::Rect top_container_bounds(top_container_->GetPreferredSize()); | 534 gfx::Rect top_container_bounds(top_container_->GetPreferredSize()); |
| 534 | 535 |
| 535 // If the immersive mode controller is animating the top-of-window views, | 536 // If the immersive mode controller is animating the top container, it may be |
| 536 // part of the top container may be offscreen. | 537 // partly offscreen. The top container is positioned relative to the top of |
| 538 // the client view instead of relative to GetTopInsetInBrowserView() because |
| 539 // the top container paints parts of the frame (title, window controls) during |
| 540 // an immersive reveal. |
| 537 top_container_bounds.set_y( | 541 top_container_bounds.set_y( |
| 538 immersive_mode_controller_->GetTopContainerVerticalOffset( | 542 immersive_mode_controller_->GetTopContainerVerticalOffset( |
| 539 top_container_bounds.size())); | 543 top_container_bounds.size())); |
| 540 top_container_->SetBoundsRect(top_container_bounds); | 544 top_container_->SetBoundsRect(top_container_bounds); |
| 541 } | 545 } |
| 542 | 546 |
| 543 int BrowserViewLayout::GetContentsOffsetForBookmarkBar() { | 547 int BrowserViewLayout::GetContentsOffsetForBookmarkBar() { |
| 544 // If the bookmark bar is hidden or attached to the omnibox the web contents | 548 // If the bookmark bar is hidden or attached to the omnibox the web contents |
| 545 // will appear directly underneath it and does not need an offset. | 549 // will appear directly underneath it and does not need an offset. |
| 546 if (!bookmark_bar_ || | 550 if (!bookmark_bar_ || |
| (...skipping 26 matching lines...) Expand all Loading... |
| 573 return bottom; | 577 return bottom; |
| 574 } | 578 } |
| 575 | 579 |
| 576 bool BrowserViewLayout::InfobarVisible() const { | 580 bool BrowserViewLayout::InfobarVisible() const { |
| 577 // Cast to a views::View to access GetPreferredSize(). | 581 // Cast to a views::View to access GetPreferredSize(). |
| 578 views::View* infobar_container = infobar_container_; | 582 views::View* infobar_container = infobar_container_; |
| 579 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. | 583 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. |
| 580 return browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && | 584 return browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && |
| 581 (infobar_container->GetPreferredSize().height() != 0); | 585 (infobar_container->GetPreferredSize().height() != 0); |
| 582 } | 586 } |
| OLD | NEW |