Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / views / frame / contents_layout_manager.cc
blob2d018bd2b3a09cc1d09b0a32f64309190b636948
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),
14 host_(NULL),
15 active_top_margin_(0) {
18 ContentsLayoutManager::~ContentsLayoutManager() {
21 void ContentsLayoutManager::SetContentsViewInsets(const gfx::Insets& insets) {
22 if (insets_ == insets)
23 return;
25 insets_ = insets;
26 if (host_)
27 host_->InvalidateLayout();
30 void ContentsLayoutManager::SetActiveTopMargin(int margin) {
31 if (active_top_margin_ == margin)
32 return;
34 active_top_margin_ = margin;
35 if (host_)
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),
52 contents_width,
53 contents_height);
56 gfx::Size ContentsLayoutManager::GetPreferredSize(views::View* host) {
57 return gfx::Size();
60 void ContentsLayoutManager::Installed(views::View* host) {
61 DCHECK(!host_);
62 host_ = host;
65 void ContentsLayoutManager::Uninstalled(views::View* host) {
66 DCHECK(host_ == host);
67 host_ = NULL;