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 // Compute transform relative to parent. |
| 23 gfx::Transform transform; |
| 24 if (layer()) |
| 25 transform = layer()->GetTargetTransform(); |
| 26 gfx::Transform translation; |
| 27 translation.Translate(static_cast<float>(GetMirroredX()), |
| 28 static_cast<float>(y())); |
| 29 transform.ConcatTransform(translation); |
| 30 |
| 31 gfx::Point origin(parent()->GetBoundsInScreen().origin()); |
| 32 transform.TransformPoint(origin); |
| 33 return gfx::Rect(origin, size()); |
| 34 } |
| 35 |
18 gfx::Size TopContainerView::GetPreferredSize() { | 36 gfx::Size TopContainerView::GetPreferredSize() { |
19 // The view wants to be as wide as its parent and tall enough to fully show | 37 // The view wants to be as wide as its parent and tall enough to fully show |
20 // its last child view. | 38 // its last child view. |
21 int last_child_bottom = | 39 int last_child_bottom = |
22 child_count() > 0 ? child_at(child_count() - 1)->bounds().bottom() : 0; | 40 child_count() > 0 ? child_at(child_count() - 1)->bounds().bottom() : 0; |
23 return gfx::Size(browser_view_->width(), last_child_bottom); | 41 return gfx::Size(browser_view_->width(), last_child_bottom); |
24 } | 42 } |
25 | 43 |
26 std::string TopContainerView::GetClassName() const { | 44 std::string TopContainerView::GetClassName() const { |
27 return "TopContainerView"; | 45 return "TopContainerView"; |
28 } | 46 } |
29 | 47 |
| 48 void TopContainerView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 49 ImmersiveModeController* immersive_controller = |
| 50 browser_view_->immersive_mode_controller(); |
| 51 if (immersive_controller->IsEnabled()) |
| 52 immersive_controller->OnTopContainerBoundsChanged(); |
| 53 } |
| 54 |
30 void TopContainerView::PaintChildren(gfx::Canvas* canvas) { | 55 void TopContainerView::PaintChildren(gfx::Canvas* canvas) { |
31 if (browser_view_->immersive_mode_controller()->IsRevealed()) { | 56 if (browser_view_->immersive_mode_controller()->IsRevealed()) { |
32 // Top-views depend on parts of the frame (themes, window buttons) being | 57 // 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 | 58 // painted underneath them. Clip rect has already been set to the bounds |
34 // of this view, so just paint the frame. | 59 // of this view, so just paint the frame. |
35 views::View* frame = browser_view_->frame()->GetFrameView(); | 60 views::View* frame = browser_view_->frame()->GetFrameView(); |
36 frame->Paint(canvas); | 61 frame->Paint(canvas); |
37 } | 62 } |
38 | 63 |
39 views::View::PaintChildren(canvas); | 64 views::View::PaintChildren(canvas); |
40 } | 65 } |
OLD | NEW |