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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/views/frame/contents_layout_manager.h"
7 #include "ui/views/view.h"
9 ContentsLayoutManager::ContentsLayoutManager(
10 views::View
* devtools_view
,
11 views::View
* contents_view
)
12 : devtools_view_(devtools_view
),
13 contents_view_(contents_view
),
15 active_top_margin_(0) {
18 ContentsLayoutManager::~ContentsLayoutManager() {
21 void ContentsLayoutManager::SetContentsViewInsets(const gfx::Insets
& insets
) {
22 if (insets_
== insets
)
27 host_
->InvalidateLayout();
30 void ContentsLayoutManager::SetActiveTopMargin(int margin
) {
31 if (active_top_margin_
== margin
)
34 active_top_margin_
= margin
;
36 host_
->InvalidateLayout();
39 void ContentsLayoutManager::Layout(views::View
* contents_container
) {
40 DCHECK(host_
== contents_container
);
42 int top
= active_top_margin_
;
43 int height
= std::max(0, contents_container
->height() - top
);
44 int width
= contents_container
->width();
45 devtools_view_
->SetBounds(0, top
, width
, height
);
47 int contents_width
= std::max(0, width
- insets_
.width());
48 int contents_height
= std::max(0, height
- insets_
.height());
49 contents_view_
->SetBounds(
50 std::min(insets_
.left(), width
),
51 top
+ std::min(insets_
.top(), height
),
56 gfx::Size
ContentsLayoutManager::GetPreferredSize(views::View
* host
) {
60 void ContentsLayoutManager::Installed(views::View
* host
) {
65 void ContentsLayoutManager::Uninstalled(views::View
* host
) {
66 DCHECK(host_
== host
);