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

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

Issue 137483007: [DevTools] Use special resizing strategy instead of insets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed more comments Created 6 years, 10 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
« no previous file with comments | « chrome/browser/ui/views/frame/contents_layout_manager.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/contents_layout_manager.h" 5 #include "chrome/browser/ui/views/frame/contents_layout_manager.h"
6 6
7 #include "ui/views/view.h" 7 #include "ui/views/view.h"
8 8
9 ContentsLayoutManager::ContentsLayoutManager( 9 ContentsLayoutManager::ContentsLayoutManager(
10 views::View* devtools_view, 10 views::View* devtools_view,
11 views::View* contents_view) 11 views::View* contents_view)
12 : devtools_view_(devtools_view), 12 : devtools_view_(devtools_view),
13 contents_view_(contents_view), 13 contents_view_(contents_view),
14 host_(NULL), 14 host_(NULL),
15 active_top_margin_(0) { 15 active_top_margin_(0) {
16 } 16 }
17 17
18 ContentsLayoutManager::~ContentsLayoutManager() { 18 ContentsLayoutManager::~ContentsLayoutManager() {
19 } 19 }
20 20
21 void ContentsLayoutManager::SetContentsViewInsets(const gfx::Insets& insets) { 21 void ContentsLayoutManager::SetContentsResizingStrategy(
22 if (insets_ == insets) 22 const DevToolsContentsResizingStrategy& strategy) {
23 if (strategy_.Equals(strategy))
23 return; 24 return;
24 25
25 insets_ = insets; 26 strategy_.CopyFrom(strategy);
26 if (host_) 27 if (host_)
27 host_->InvalidateLayout(); 28 host_->InvalidateLayout();
28 } 29 }
29 30
30 void ContentsLayoutManager::SetActiveTopMargin(int margin) { 31 void ContentsLayoutManager::SetActiveTopMargin(int margin) {
31 if (active_top_margin_ == margin) 32 if (active_top_margin_ == margin)
32 return; 33 return;
33 34
34 active_top_margin_ = margin; 35 active_top_margin_ = margin;
35 if (host_) 36 if (host_)
36 host_->InvalidateLayout(); 37 host_->InvalidateLayout();
37 } 38 }
38 39
39 void ContentsLayoutManager::Layout(views::View* contents_container) { 40 void ContentsLayoutManager::Layout(views::View* contents_container) {
40 DCHECK(host_ == contents_container); 41 DCHECK(host_ == contents_container);
41 42
42 int top = active_top_margin_; 43 int top = active_top_margin_;
43 int height = std::max(0, contents_container->height() - top); 44 int height = std::max(0, contents_container->height() - top);
44 int width = contents_container->width(); 45 int width = contents_container->width();
45 devtools_view_->SetBounds(0, top, width, height);
46 46
47 int contents_width = std::max(0, width - insets_.width()); 47 gfx::Size container_size(width, height);
48 int contents_height = std::max(0, height - insets_.height()); 48 gfx::Rect old_devtools_bounds(devtools_view_->bounds());
49 contents_view_->SetBounds( 49 gfx::Rect old_contents_bounds(contents_view_->bounds());
50 std::min(insets_.left(), width), 50 gfx::Rect new_devtools_bounds;
51 top + std::min(insets_.top(), height), 51 gfx::Rect new_contents_bounds;
52 contents_width, 52
53 contents_height); 53 old_devtools_bounds.Offset(0, -top);
54 old_contents_bounds.Offset(0, -top);
55 ApplyDevToolsContentsResizingStrategy(strategy_, container_size,
56 old_devtools_bounds, old_contents_bounds,
57 &new_devtools_bounds, &new_contents_bounds);
58 new_devtools_bounds.Offset(0, top);
59 new_contents_bounds.Offset(0, top);
60
61 devtools_view_->SetBoundsRect(new_devtools_bounds);
62 contents_view_->SetBoundsRect(new_contents_bounds);
54 } 63 }
55 64
56 gfx::Size ContentsLayoutManager::GetPreferredSize(views::View* host) { 65 gfx::Size ContentsLayoutManager::GetPreferredSize(views::View* host) {
57 return gfx::Size(); 66 return gfx::Size();
58 } 67 }
59 68
60 void ContentsLayoutManager::Installed(views::View* host) { 69 void ContentsLayoutManager::Installed(views::View* host) {
61 DCHECK(!host_); 70 DCHECK(!host_);
62 host_ = host; 71 host_ = host;
63 } 72 }
64 73
65 void ContentsLayoutManager::Uninstalled(views::View* host) { 74 void ContentsLayoutManager::Uninstalled(views::View* host) {
66 DCHECK(host_ == host); 75 DCHECK(host_ == host);
67 host_ = NULL; 76 host_ = NULL;
68 } 77 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/contents_layout_manager.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698