| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 bookmark_bar_->visible() && | 179 bookmark_bar_->visible() && |
| 180 browser()->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR)) { | 180 browser()->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR)) { |
| 181 bookmark_bar_size = bookmark_bar_->GetMinimumSize(); | 181 bookmark_bar_size = bookmark_bar_->GetMinimumSize(); |
| 182 bookmark_bar_size.Enlarge(0, -bookmark_bar_->GetToolbarOverlap()); | 182 bookmark_bar_size.Enlarge(0, -bookmark_bar_->GetToolbarOverlap()); |
| 183 } | 183 } |
| 184 gfx::Size infobar_container_size(infobar_container_->GetMinimumSize()); | 184 gfx::Size infobar_container_size(infobar_container_->GetMinimumSize()); |
| 185 // TODO: Adjust the minimum height for the find bar. | 185 // TODO: Adjust the minimum height for the find bar. |
| 186 | 186 |
| 187 gfx::Size contents_size(contents_container_->GetMinimumSize()); | 187 gfx::Size contents_size(contents_container_->GetMinimumSize()); |
| 188 | 188 |
| 189 int min_height = delegate_->GetTopInsetInBrowserView() + | 189 int min_height = delegate_->GetTopInsetInBrowserView(false) + |
| 190 tabstrip_size.height() + toolbar_size.height() + | 190 tabstrip_size.height() + toolbar_size.height() + |
| 191 bookmark_bar_size.height() + infobar_container_size.height() + | 191 bookmark_bar_size.height() + infobar_container_size.height() + |
| 192 contents_size.height(); | 192 contents_size.height(); |
| 193 int widths[] = { | 193 int widths[] = { |
| 194 tabstrip_size.width(), | 194 tabstrip_size.width(), |
| 195 toolbar_size.width(), | 195 toolbar_size.width(), |
| 196 bookmark_bar_size.width(), | 196 bookmark_bar_size.width(), |
| 197 infobar_container_size.width(), | 197 infobar_container_size.width(), |
| 198 contents_size.width() }; | 198 contents_size.width() }; |
| 199 int min_width = *std::max_element(&widths[0], &widths[arraysize(widths)]); | 199 int min_width = *std::max_element(&widths[0], &widths[arraysize(widths)]); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 | 311 |
| 312 // If the point is somewhere else, delegate to the default implementation. | 312 // If the point is somewhere else, delegate to the default implementation. |
| 313 return browser_view_->views::ClientView::NonClientHitTest(point); | 313 return browser_view_->views::ClientView::NonClientHitTest(point); |
| 314 } | 314 } |
| 315 | 315 |
| 316 ////////////////////////////////////////////////////////////////////////////// | 316 ////////////////////////////////////////////////////////////////////////////// |
| 317 // BrowserViewLayout, views::LayoutManager implementation: | 317 // BrowserViewLayout, views::LayoutManager implementation: |
| 318 | 318 |
| 319 void BrowserViewLayout::Layout(views::View* browser_view) { | 319 void BrowserViewLayout::Layout(views::View* browser_view) { |
| 320 vertical_layout_rect_ = browser_view->GetLocalBounds(); | 320 vertical_layout_rect_ = browser_view->GetLocalBounds(); |
| 321 int top = delegate_->GetTopInsetInBrowserView(); | 321 int top = delegate_->GetTopInsetInBrowserView(false); |
| 322 top = LayoutTabStripRegion(top); | 322 top = LayoutTabStripRegion(top); |
| 323 if (delegate_->IsTabStripVisible()) { | 323 if (delegate_->IsTabStripVisible()) { |
| 324 // Set the position of the background image in tabs and the new tab button. |
| 324 int x = tab_strip_->GetMirroredX() + | 325 int x = tab_strip_->GetMirroredX() + |
| 325 browser_view_->GetMirroredX() + | 326 browser_view_->GetMirroredX() + |
| 326 delegate_->GetThemeBackgroundXInset(); | 327 delegate_->GetThemeBackgroundXInset(); |
| 327 int y = browser_view_->y() + delegate_->GetTopInsetInBrowserView(); | 328 // By passing true here, we position the tab background to vertically align |
| 329 // with the frame background image of a restored-mode frame, even in a |
| 330 // maximized window. Then in the frame code, we position the frame so the |
| 331 // portion of the image that's behind the restored-mode tabstrip is always |
| 332 // behind the tabstrip. Together these ensure that the tab and frame images |
| 333 // are always aligned, and that their relative alignment with the toolbar |
| 334 // image is always the same, so themes which try to align all three will |
| 335 // look correct in both restored and maximized windows. |
| 336 int y = browser_view_->y() + delegate_->GetTopInsetInBrowserView(true); |
| 328 tab_strip_->SetBackgroundOffset(gfx::Point(x, y)); | 337 tab_strip_->SetBackgroundOffset(gfx::Point(x, y)); |
| 329 } | 338 } |
| 330 top = LayoutToolbar(top); | 339 top = LayoutToolbar(top); |
| 331 | 340 |
| 332 top = LayoutBookmarkAndInfoBars(top, browser_view->y()); | 341 top = LayoutBookmarkAndInfoBars(top, browser_view->y()); |
| 333 | 342 |
| 334 // Top container requires updated toolbar and bookmark bar to compute bounds. | 343 // Top container requires updated toolbar and bookmark bar to compute bounds. |
| 335 UpdateTopContainerBounds(); | 344 UpdateTopContainerBounds(); |
| 336 | 345 |
| 337 int bottom = LayoutDownloadShelf(browser_view->height()); | 346 int bottom = LayoutDownloadShelf(browser_view->height()); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 if (!child->visible()) | 501 if (!child->visible()) |
| 493 continue; | 502 continue; |
| 494 int child_bottom = child->bounds().bottom(); | 503 int child_bottom = child->bounds().bottom(); |
| 495 if (child_bottom > height) | 504 if (child_bottom > height) |
| 496 height = child_bottom; | 505 height = child_bottom; |
| 497 } | 506 } |
| 498 | 507 |
| 499 // Ensure that the top container view reaches the topmost view in the | 508 // Ensure that the top container view reaches the topmost view in the |
| 500 // ClientView because the bounds of the top container view are used in | 509 // ClientView because the bounds of the top container view are used in |
| 501 // layout and we assume that this is the case. | 510 // layout and we assume that this is the case. |
| 502 height = std::max(height, delegate_->GetTopInsetInBrowserView()); | 511 height = std::max(height, delegate_->GetTopInsetInBrowserView(false)); |
| 503 | 512 |
| 504 gfx::Rect top_container_bounds(vertical_layout_rect_.width(), height); | 513 gfx::Rect top_container_bounds(vertical_layout_rect_.width(), height); |
| 505 | 514 |
| 506 // If the immersive mode controller is animating the top container, it may be | 515 // If the immersive mode controller is animating the top container, it may be |
| 507 // partly offscreen. | 516 // partly offscreen. |
| 508 top_container_bounds.set_y( | 517 top_container_bounds.set_y( |
| 509 immersive_mode_controller_->GetTopContainerVerticalOffset( | 518 immersive_mode_controller_->GetTopContainerVerticalOffset( |
| 510 top_container_bounds.size())); | 519 top_container_bounds.size())); |
| 511 top_container_->SetBoundsRect(top_container_bounds); | 520 top_container_->SetBoundsRect(top_container_bounds); |
| 512 } | 521 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 540 return bottom; | 549 return bottom; |
| 541 } | 550 } |
| 542 | 551 |
| 543 bool BrowserViewLayout::InfobarVisible() const { | 552 bool BrowserViewLayout::InfobarVisible() const { |
| 544 // Cast to a views::View to access GetPreferredSize(). | 553 // Cast to a views::View to access GetPreferredSize(). |
| 545 views::View* infobar_container = infobar_container_; | 554 views::View* infobar_container = infobar_container_; |
| 546 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. | 555 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. |
| 547 return browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && | 556 return browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && |
| 548 (infobar_container->GetPreferredSize().height() != 0); | 557 (infobar_container->GetPreferredSize().height() != 0); |
| 549 } | 558 } |
| OLD | NEW |