- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / frame / contents_container.cc
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/views/frame/contents_container.h"
6
7 ContentsContainer::ContentsContainer(views::View* active_web_view)
8     : active_web_view_(active_web_view),
9       active_top_margin_(0) {
10   AddChildView(active_web_view_);
11 }
12
13 ContentsContainer::~ContentsContainer() {
14 }
15
16 bool ContentsContainer::SetActiveTopMargin(int margin) {
17   if (active_top_margin_ == margin)
18     return false;
19
20   active_top_margin_ = margin;
21   // Make sure we layout next time around. We need this in case our bounds
22   // haven't changed.
23   InvalidateLayout();
24   return true;
25 }
26
27 void ContentsContainer::Layout() {
28   int content_y = active_top_margin_;
29   int content_height = std::max(0, height() - content_y);
30
31   active_web_view_->SetBounds(0, content_y, width(), content_height);
32
33   // Need to invoke views::View in case any views whose bounds didn't change
34   // still need a layout.
35   views::View::Layout();
36 }
37
38 const char* ContentsContainer::GetClassName() const {
39   return "ContentsContainer";
40 }