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

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

Issue 1355893002: Parametrize a variety of constants in preparation for changing them in MD. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + fix bugs Created 5 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 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"
11 #include "chrome/browser/ui/browser_window.h" 11 #include "chrome/browser/ui/browser_window.h"
12 #include "chrome/browser/ui/find_bar/find_bar.h" 12 #include "chrome/browser/ui/find_bar/find_bar.h"
13 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 13 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
14 #include "chrome/browser/ui/search/search_model.h" 14 #include "chrome/browser/ui/search/search_model.h"
15 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" 15 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
16 #include "chrome/browser/ui/views/download/download_shelf_view.h" 16 #include "chrome/browser/ui/views/download/download_shelf_view.h"
17 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h" 17 #include "chrome/browser/ui/views/exclusive_access_bubble_views.h"
18 #include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h" 18 #include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h"
19 #include "chrome/browser/ui/views/frame/contents_layout_manager.h" 19 #include "chrome/browser/ui/views/frame/contents_layout_manager.h"
20 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" 20 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
21 #include "chrome/browser/ui/views/frame/top_container_view.h" 21 #include "chrome/browser/ui/views/frame/top_container_view.h"
22 #include "chrome/browser/ui/views/infobars/infobar_container_view.h" 22 #include "chrome/browser/ui/views/infobars/infobar_container_view.h"
23 #include "chrome/browser/ui/views/layout_constants.h"
23 #include "chrome/browser/ui/views/tabs/tab_strip.h" 24 #include "chrome/browser/ui/views/tabs/tab_strip.h"
24 #include "components/web_modal/web_contents_modal_dialog_host.h" 25 #include "components/web_modal/web_contents_modal_dialog_host.h"
25 #include "ui/base/hit_test.h" 26 #include "ui/base/hit_test.h"
26 #include "ui/base/resource/material_design/material_design_controller.h" 27 #include "ui/base/resource/material_design/material_design_controller.h"
27 #include "ui/gfx/geometry/point.h" 28 #include "ui/gfx/geometry/point.h"
28 #include "ui/gfx/geometry/size.h" 29 #include "ui/gfx/geometry/size.h"
29 #include "ui/gfx/scrollbar_size.h" 30 #include "ui/gfx/scrollbar_size.h"
30 #include "ui/views/controls/webview/webview.h" 31 #include "ui/views/controls/webview/webview.h"
31 #include "ui/views/widget/widget.h" 32 #include "ui/views/widget/widget.h"
32 #include "ui/views/window/client_view.h" 33 #include "ui/views/window/client_view.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 observer_list_.RemoveObserver(observer); 108 observer_list_.RemoveObserver(observer);
108 } 109 }
109 110
110 BrowserViewLayout* const browser_view_layout_; 111 BrowserViewLayout* const browser_view_layout_;
111 112
112 base::ObserverList<ModalDialogHostObserver> observer_list_; 113 base::ObserverList<ModalDialogHostObserver> observer_list_;
113 114
114 DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogHostViews); 115 DISALLOW_COPY_AND_ASSIGN(WebContentsModalDialogHostViews);
115 }; 116 };
116 117
117 // static
118 const int BrowserViewLayout::kToolbarTabStripVerticalOverlap = 3;
119
120 //////////////////////////////////////////////////////////////////////////////// 118 ////////////////////////////////////////////////////////////////////////////////
121 // BrowserViewLayout, public: 119 // BrowserViewLayout, public:
122 120
123 BrowserViewLayout::BrowserViewLayout() 121 BrowserViewLayout::BrowserViewLayout()
124 : browser_(nullptr), 122 : browser_(nullptr),
125 browser_view_(nullptr), 123 browser_view_(nullptr),
126 top_container_(nullptr), 124 top_container_(nullptr),
127 tab_strip_(nullptr), 125 tab_strip_(nullptr),
128 toolbar_(nullptr), 126 toolbar_(nullptr),
129 bookmark_bar_(nullptr), 127 bookmark_bar_(nullptr),
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 166
169 gfx::Size BrowserViewLayout::GetMinimumSize() { 167 gfx::Size BrowserViewLayout::GetMinimumSize() {
170 gfx::Size tabstrip_size( 168 gfx::Size tabstrip_size(
171 browser()->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ? 169 browser()->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ?
172 tab_strip_->GetMinimumSize() : gfx::Size()); 170 tab_strip_->GetMinimumSize() : gfx::Size());
173 gfx::Size toolbar_size( 171 gfx::Size toolbar_size(
174 (browser()->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || 172 (browser()->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) ||
175 browser()->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) ? 173 browser()->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR)) ?
176 toolbar_->GetMinimumSize() : gfx::Size()); 174 toolbar_->GetMinimumSize() : gfx::Size());
177 if (tabstrip_size.height() && toolbar_size.height()) 175 if (tabstrip_size.height() && toolbar_size.height())
178 toolbar_size.Enlarge(0, -kToolbarTabStripVerticalOverlap); 176 toolbar_size.Enlarge(0, -GetLayoutConstant(TABSTRIP_TOOLBAR_OVERLAP));
179 gfx::Size bookmark_bar_size; 177 gfx::Size bookmark_bar_size;
180 if (bookmark_bar_ && 178 if (bookmark_bar_ &&
181 bookmark_bar_->visible() && 179 bookmark_bar_->visible() &&
182 browser()->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR)) { 180 browser()->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR)) {
183 bookmark_bar_size = bookmark_bar_->GetMinimumSize(); 181 bookmark_bar_size = bookmark_bar_->GetMinimumSize();
184 bookmark_bar_size.Enlarge(0, -bookmark_bar_->GetToolbarOverlap()); 182 bookmark_bar_size.Enlarge(0, -bookmark_bar_->GetToolbarOverlap());
185 } 183 }
186 gfx::Size infobar_container_size(infobar_container_->GetMinimumSize()); 184 gfx::Size infobar_container_size(infobar_container_->GetMinimumSize());
187 // TODO: Adjust the minimum height for the find bar. 185 // TODO: Adjust the minimum height for the find bar.
188 186
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 tab_strip_->SetBoundsRect(tabstrip_bounds); 392 tab_strip_->SetBoundsRect(tabstrip_bounds);
395 393
396 return tabstrip_bounds.bottom(); 394 return tabstrip_bounds.bottom();
397 } 395 }
398 396
399 int BrowserViewLayout::LayoutToolbar(int top) { 397 int BrowserViewLayout::LayoutToolbar(int top) {
400 int browser_view_width = vertical_layout_rect_.width(); 398 int browser_view_width = vertical_layout_rect_.width();
401 bool toolbar_visible = delegate_->IsToolbarVisible(); 399 bool toolbar_visible = delegate_->IsToolbarVisible();
402 int y = top; 400 int y = top;
403 y -= (toolbar_visible && delegate_->IsTabStripVisible()) ? 401 y -= (toolbar_visible && delegate_->IsTabStripVisible()) ?
404 kToolbarTabStripVerticalOverlap : 0; 402 GetLayoutConstant(TABSTRIP_TOOLBAR_OVERLAP) : 0;
405 int height = toolbar_visible ? toolbar_->GetPreferredSize().height() : 0; 403 int height = toolbar_visible ? toolbar_->GetPreferredSize().height() : 0;
406 toolbar_->SetVisible(toolbar_visible); 404 toolbar_->SetVisible(toolbar_visible);
407 toolbar_->SetBounds(vertical_layout_rect_.x(), y, browser_view_width, height); 405 toolbar_->SetBounds(vertical_layout_rect_.x(), y, browser_view_width, height);
408 406
409 return y + height; 407 return y + height;
410 } 408 }
411 409
412 int BrowserViewLayout::LayoutBookmarkAndInfoBars(int top, int browser_view_y) { 410 int BrowserViewLayout::LayoutBookmarkAndInfoBars(int top, int browser_view_y) {
413 web_contents_modal_dialog_top_y_ = 411 web_contents_modal_dialog_top_y_ =
414 top + browser_view_y - kConstrainedWindowOverlap; 412 top + browser_view_y - kConstrainedWindowOverlap;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 return bottom; 541 return bottom;
544 } 542 }
545 543
546 bool BrowserViewLayout::InfobarVisible() const { 544 bool BrowserViewLayout::InfobarVisible() const {
547 // Cast to a views::View to access GetPreferredSize(). 545 // Cast to a views::View to access GetPreferredSize().
548 views::View* infobar_container = infobar_container_; 546 views::View* infobar_container = infobar_container_;
549 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. 547 // NOTE: Can't check if the size IsEmpty() since it's always 0-width.
550 return browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && 548 return browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR) &&
551 (infobar_container->GetPreferredSize().height() != 0); 549 (infobar_container->GetPreferredSize().height() != 0);
552 } 550 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698