OLD | NEW |
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/top_container_view.h" | 5 #include "chrome/browser/ui/views/frame/top_container_view.h" |
6 | 6 |
7 #include "chrome/browser/ui/views/frame/browser_frame.h" | 7 #include "chrome/browser/ui/views/frame/browser_frame.h" |
8 #include "chrome/browser/ui/views/frame/browser_view.h" | 8 #include "chrome/browser/ui/views/frame/browser_view.h" |
9 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" | 9 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" |
10 | 10 |
11 TopContainerView::TopContainerView(BrowserView* browser_view) | 11 TopContainerView::TopContainerView(BrowserView* browser_view) |
12 : browser_view_(browser_view) { | 12 : browser_view_(browser_view) { |
13 } | 13 } |
14 | 14 |
15 TopContainerView::~TopContainerView() { | 15 TopContainerView::~TopContainerView() { |
16 } | 16 } |
17 | 17 |
| 18 gfx::Rect TopContainerView::GetTargetBoundsInScreen() const { |
| 19 if (!parent()) |
| 20 return bounds(); |
| 21 |
| 22 gfx::Point origin(parent()->GetBoundsInScreen().origin()); |
| 23 origin.Offset(GetMirroredX(), y()); |
| 24 if (layer()) |
| 25 layer()->GetTargetTransform().TransformPoint(origin); |
| 26 return gfx::Rect(origin, size()); |
| 27 } |
| 28 |
18 gfx::Size TopContainerView::GetPreferredSize() { | 29 gfx::Size TopContainerView::GetPreferredSize() { |
19 // The view wants to be as wide as its parent and tall enough to fully show | 30 // The view wants to be as wide as its parent and tall enough to fully show |
20 // its last child view. | 31 // its last child view. |
21 int last_child_bottom = | 32 int last_child_bottom = |
22 child_count() > 0 ? child_at(child_count() - 1)->bounds().bottom() : 0; | 33 child_count() > 0 ? child_at(child_count() - 1)->bounds().bottom() : 0; |
23 return gfx::Size(browser_view_->width(), last_child_bottom); | 34 return gfx::Size(browser_view_->width(), last_child_bottom); |
24 } | 35 } |
25 | 36 |
26 std::string TopContainerView::GetClassName() const { | 37 std::string TopContainerView::GetClassName() const { |
27 return "TopContainerView"; | 38 return "TopContainerView"; |
28 } | 39 } |
29 | 40 |
| 41 void TopContainerView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 42 ImmersiveModeController* immersive_controller = |
| 43 browser_view_->immersive_mode_controller(); |
| 44 if (immersive_controller->IsEnabled()) |
| 45 immersive_controller->OnTopContainerBoundsChanged(); |
| 46 } |
| 47 |
30 void TopContainerView::PaintChildren(gfx::Canvas* canvas) { | 48 void TopContainerView::PaintChildren(gfx::Canvas* canvas) { |
31 if (browser_view_->immersive_mode_controller()->IsRevealed()) { | 49 if (browser_view_->immersive_mode_controller()->IsRevealed()) { |
32 // Top-views depend on parts of the frame (themes, window buttons) being | 50 // Top-views depend on parts of the frame (themes, window buttons) being |
33 // painted underneath them. Clip rect has already been set to the bounds | 51 // painted underneath them. Clip rect has already been set to the bounds |
34 // of this view, so just paint the frame. | 52 // of this view, so just paint the frame. |
35 views::View* frame = browser_view_->frame()->GetFrameView(); | 53 views::View* frame = browser_view_->frame()->GetFrameView(); |
36 frame->Paint(canvas); | 54 frame->Paint(canvas); |
37 } | 55 } |
38 | 56 |
39 views::View::PaintChildren(canvas); | 57 views::View::PaintChildren(canvas); |
40 } | 58 } |
OLD | NEW |