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

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

Issue 63173016: DevTools: place DevTools WebContents underneath inspected WebContents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed the preference. Created 7 years, 1 month 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"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // BrowserViewLayout, public: 134 // BrowserViewLayout, public:
135 135
136 BrowserViewLayout::BrowserViewLayout() 136 BrowserViewLayout::BrowserViewLayout()
137 : browser_(NULL), 137 : browser_(NULL),
138 browser_view_(NULL), 138 browser_view_(NULL),
139 top_container_(NULL), 139 top_container_(NULL),
140 tab_strip_(NULL), 140 tab_strip_(NULL),
141 toolbar_(NULL), 141 toolbar_(NULL),
142 bookmark_bar_(NULL), 142 bookmark_bar_(NULL),
143 infobar_container_(NULL), 143 infobar_container_(NULL),
144 contents_split_(NULL),
145 contents_container_(NULL), 144 contents_container_(NULL),
146 download_shelf_(NULL), 145 download_shelf_(NULL),
147 immersive_mode_controller_(NULL), 146 immersive_mode_controller_(NULL),
148 dialog_host_(new WebContentsModalDialogHostViews(this)), 147 dialog_host_(new WebContentsModalDialogHostViews(this)),
149 web_contents_modal_dialog_top_y_(-1) {} 148 web_contents_modal_dialog_top_y_(-1) {}
150 149
151 BrowserViewLayout::~BrowserViewLayout() { 150 BrowserViewLayout::~BrowserViewLayout() {
152 } 151 }
153 152
154 void BrowserViewLayout::Init( 153 void BrowserViewLayout::Init(
155 BrowserViewLayoutDelegate* delegate, 154 BrowserViewLayoutDelegate* delegate,
156 Browser* browser, 155 Browser* browser,
157 BrowserView* browser_view, 156 BrowserView* browser_view,
158 views::View* top_container, 157 views::View* top_container,
159 TabStrip* tab_strip, 158 TabStrip* tab_strip,
160 views::View* toolbar, 159 views::View* toolbar,
161 InfoBarContainerView* infobar_container, 160 InfoBarContainerView* infobar_container,
162 views::View* contents_split,
163 ContentsContainer* contents_container, 161 ContentsContainer* contents_container,
164 ImmersiveModeController* immersive_mode_controller) { 162 ImmersiveModeController* immersive_mode_controller) {
165 delegate_.reset(delegate); 163 delegate_.reset(delegate);
166 browser_ = browser; 164 browser_ = browser;
167 browser_view_ = browser_view; 165 browser_view_ = browser_view;
168 top_container_ = top_container; 166 top_container_ = top_container;
169 tab_strip_ = tab_strip; 167 tab_strip_ = tab_strip;
170 toolbar_ = toolbar; 168 toolbar_ = toolbar;
171 infobar_container_ = infobar_container; 169 infobar_container_ = infobar_container;
172 contents_split_ = contents_split;
173 contents_container_ = contents_container; 170 contents_container_ = contents_container;
174 immersive_mode_controller_ = immersive_mode_controller; 171 immersive_mode_controller_ = immersive_mode_controller;
175 } 172 }
176 173
177 WebContentsModalDialogHost* 174 WebContentsModalDialogHost*
178 BrowserViewLayout::GetWebContentsModalDialogHost() { 175 BrowserViewLayout::GetWebContentsModalDialogHost() {
179 return dialog_host_.get(); 176 return dialog_host_.get();
180 } 177 }
181 178
182 gfx::Size BrowserViewLayout::GetMinimumSize() { 179 gfx::Size BrowserViewLayout::GetMinimumSize() {
(...skipping 10 matching lines...) Expand all
193 toolbar_size.Enlarge(0, -kToolbarTabStripVerticalOverlap); 190 toolbar_size.Enlarge(0, -kToolbarTabStripVerticalOverlap);
194 gfx::Size bookmark_bar_size; 191 gfx::Size bookmark_bar_size;
195 if (bookmark_bar_ && 192 if (bookmark_bar_ &&
196 bookmark_bar_->visible() && 193 bookmark_bar_->visible() &&
197 browser()->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR)) { 194 browser()->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR)) {
198 bookmark_bar_size = bookmark_bar_->GetMinimumSize(); 195 bookmark_bar_size = bookmark_bar_->GetMinimumSize();
199 bookmark_bar_size.Enlarge(0, -bookmark_bar_->GetToolbarOverlap()); 196 bookmark_bar_size.Enlarge(0, -bookmark_bar_->GetToolbarOverlap());
200 } 197 }
201 // TODO: Adjust the minimum height for the find bar. 198 // TODO: Adjust the minimum height for the find bar.
202 199
203 gfx::Size contents_size(contents_split_->GetMinimumSize()); 200 gfx::Size contents_size(contents_container_->GetMinimumSize());
204 201
205 int min_height = tabstrip_size.height() + toolbar_size.height() + 202 int min_height = tabstrip_size.height() + toolbar_size.height() +
206 bookmark_bar_size.height() + contents_size.height(); 203 bookmark_bar_size.height() + contents_size.height();
207 int widths[] = { 204 int widths[] = {
208 tabstrip_size.width() + tab_strip_insets.left + tab_strip_insets.right, 205 tabstrip_size.width() + tab_strip_insets.left + tab_strip_insets.right,
209 toolbar_size.width(), 206 toolbar_size.width(),
210 bookmark_bar_size.width(), 207 bookmark_bar_size.width(),
211 contents_size.width() }; 208 contents_size.width() };
212 int min_width = *std::max_element(&widths[0], &widths[arraysize(widths)]); 209 int min_width = *std::max_element(&widths[0], &widths[arraysize(widths)]);
213 return gfx::Size(min_width, min_height); 210 return gfx::Size(min_width, min_height);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 351
355 // Top container requires updated toolbar and bookmark bar to compute bounds. 352 // Top container requires updated toolbar and bookmark bar to compute bounds.
356 UpdateTopContainerBounds(); 353 UpdateTopContainerBounds();
357 354
358 int bottom = LayoutDownloadShelf(browser_view->height()); 355 int bottom = LayoutDownloadShelf(browser_view->height());
359 // Treat a detached bookmark bar as if the web contents container is shifted 356 // Treat a detached bookmark bar as if the web contents container is shifted
360 // upwards and overlaps it. 357 // upwards and overlaps it.
361 int active_top_margin = GetContentsOffsetForBookmarkBar(); 358 int active_top_margin = GetContentsOffsetForBookmarkBar();
362 contents_container_->SetActiveTopMargin(active_top_margin); 359 contents_container_->SetActiveTopMargin(active_top_margin);
363 top -= active_top_margin; 360 top -= active_top_margin;
364 LayoutContentsSplitView(top, bottom); 361 LayoutContentsContainerView(top, bottom);
365 362
366 // This must be done _after_ we lay out the WebContents since this 363 // This must be done _after_ we lay out the WebContents since this
367 // code calls back into us to find the bounding box the find bar 364 // code calls back into us to find the bounding box the find bar
368 // must be laid out within, and that code depends on the 365 // must be laid out within, and that code depends on the
369 // TabContentsContainer's bounds being up to date. 366 // TabContentsContainer's bounds being up to date.
370 if (browser()->HasFindBarController()) { 367 if (browser()->HasFindBarController()) {
371 browser()->GetFindBarController()->find_bar()->MoveWindowIfNecessary( 368 browser()->GetFindBarController()->find_bar()->MoveWindowIfNecessary(
372 gfx::Rect(), true); 369 gfx::Rect(), true);
373 } 370 }
374 371
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 infobar_container_->SetVisible(InfobarVisible()); 509 infobar_container_->SetVisible(InfobarVisible());
513 int height; 510 int height;
514 int overlapped_top = top - infobar_container_->GetVerticalOverlap(&height); 511 int overlapped_top = top - infobar_container_->GetVerticalOverlap(&height);
515 infobar_container_->SetBounds(vertical_layout_rect_.x(), 512 infobar_container_->SetBounds(vertical_layout_rect_.x(),
516 overlapped_top, 513 overlapped_top,
517 vertical_layout_rect_.width(), 514 vertical_layout_rect_.width(),
518 height); 515 height);
519 return overlapped_top + height; 516 return overlapped_top + height;
520 } 517 }
521 518
522 void BrowserViewLayout::LayoutContentsSplitView(int top, int bottom) { 519 void BrowserViewLayout::LayoutContentsContainerView(int top, int bottom) {
523 // |contents_split_| contains web page contents and devtools. 520 // |contents_container_| contains web page contents and devtools.
524 // See browser_view.h for details. 521 // See browser_view.h for details.
525 gfx::Rect contents_split_bounds(vertical_layout_rect_.x(), 522 gfx::Rect contents_container_bounds(vertical_layout_rect_.x(),
526 top, 523 top,
527 vertical_layout_rect_.width(), 524 vertical_layout_rect_.width(),
528 std::max(0, bottom - top)); 525 std::max(0, bottom - top));
529 contents_split_->SetBoundsRect(contents_split_bounds); 526 contents_container_->SetBoundsRect(contents_container_bounds);
530 } 527 }
531 528
532 void BrowserViewLayout::UpdateTopContainerBounds() { 529 void BrowserViewLayout::UpdateTopContainerBounds() {
533 gfx::Rect top_container_bounds(top_container_->GetPreferredSize()); 530 gfx::Rect top_container_bounds(top_container_->GetPreferredSize());
534 531
535 // If the immersive mode controller is animating the top-of-window views, 532 // If the immersive mode controller is animating the top-of-window views,
536 // part of the top container may be offscreen. 533 // part of the top container may be offscreen.
537 top_container_bounds.set_y( 534 top_container_bounds.set_y(
538 immersive_mode_controller_->GetTopContainerVerticalOffset( 535 immersive_mode_controller_->GetTopContainerVerticalOffset(
539 top_container_bounds.size())); 536 top_container_bounds.size()));
540 top_container_->SetBoundsRect(top_container_bounds); 537 top_container_->SetBoundsRect(top_container_bounds);
541 } 538 }
542 539
543 int BrowserViewLayout::GetContentsOffsetForBookmarkBar() { 540 int BrowserViewLayout::GetContentsOffsetForBookmarkBar() {
544 // If the bookmark bar is hidden or attached to the omnibox the web contents 541 // 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. 542 // will appear directly underneath it and does not need an offset.
546 if (!bookmark_bar_ || 543 if (!bookmark_bar_ ||
547 !browser_view_->IsBookmarkBarVisible() || 544 !browser_view_->IsBookmarkBarVisible() ||
548 !bookmark_bar_->IsDetached()) { 545 !bookmark_bar_->IsDetached()) {
549 return 0; 546 return 0;
550 } 547 }
551 548
552 // Dev tools. 549 // Dev tools.
553 if (contents_split_->child_at(1) && contents_split_->child_at(1)->visible()) 550 // if (contents_split_->child_at(1) && contents_split_->child_at(1)->visible() )
pfeldman 2013/11/18 14:18:27 Drop?
554 return 0; 551 // return 0;
555 552
556 // Offset for the detached bookmark bar. 553 // Offset for the detached bookmark bar.
557 return bookmark_bar_->height() - 554 return bookmark_bar_->height() -
558 bookmark_bar_->GetFullyDetachedToolbarOverlap(); 555 bookmark_bar_->GetFullyDetachedToolbarOverlap();
559 } 556 }
560 557
561 int BrowserViewLayout::LayoutDownloadShelf(int bottom) { 558 int BrowserViewLayout::LayoutDownloadShelf(int bottom) {
562 if (delegate_->DownloadShelfNeedsLayout()) { 559 if (delegate_->DownloadShelfNeedsLayout()) {
563 bool visible = browser()->SupportsWindowFeature( 560 bool visible = browser()->SupportsWindowFeature(
564 Browser::FEATURE_DOWNLOADSHELF); 561 Browser::FEATURE_DOWNLOADSHELF);
565 DCHECK(download_shelf_); 562 DCHECK(download_shelf_);
566 int height = visible ? download_shelf_->GetPreferredSize().height() : 0; 563 int height = visible ? download_shelf_->GetPreferredSize().height() : 0;
567 download_shelf_->SetVisible(visible); 564 download_shelf_->SetVisible(visible);
568 download_shelf_->SetBounds(vertical_layout_rect_.x(), bottom - height, 565 download_shelf_->SetBounds(vertical_layout_rect_.x(), bottom - height,
569 vertical_layout_rect_.width(), height); 566 vertical_layout_rect_.width(), height);
570 download_shelf_->Layout(); 567 download_shelf_->Layout();
571 bottom -= height; 568 bottom -= height;
572 } 569 }
573 return bottom; 570 return bottom;
574 } 571 }
575 572
576 bool BrowserViewLayout::InfobarVisible() const { 573 bool BrowserViewLayout::InfobarVisible() const {
577 // Cast to a views::View to access GetPreferredSize(). 574 // Cast to a views::View to access GetPreferredSize().
578 views::View* infobar_container = infobar_container_; 575 views::View* infobar_container = infobar_container_;
579 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. 576 // NOTE: Can't check if the size IsEmpty() since it's always 0-width.
580 return browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && 577 return browser_->SupportsWindowFeature(Browser::FEATURE_INFOBAR) &&
581 (infobar_container->GetPreferredSize().height() != 0); 578 (infobar_container->GetPreferredSize().height() != 0);
582 } 579 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698