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::Size TopContainerView::GetPreferredSize() { | 18 gfx::Size TopContainerView::GetPreferredSize() { |
19 // The view wants to be as wide as its parent and tall enough to fully show | 19 // The view wants to be as wide as its parent and tall enough to fully show |
20 // all its children. In particular, the bottom of the bookmark bar can be | 20 // all its children. In particular, the bottom of the bookmark bar can be |
21 // be above the bottom of the toolbar while the bookmark bar is animating. | 21 // be above the bottom of the toolbar while the bookmark bar is animating. |
22 int height = 0; | 22 int height = 0; |
23 for (int i = 0; i < child_count(); ++i) { | 23 for (int i = 0; i < child_count(); ++i) { |
24 int child_bottom = child_at(i)->bounds().bottom(); | 24 views::View* child = child_at(i); |
| 25 if (!child->visible()) |
| 26 continue; |
| 27 int child_bottom = child->bounds().bottom(); |
25 if (child_bottom > height) | 28 if (child_bottom > height) |
26 height = child_bottom; | 29 height = child_bottom; |
27 } | 30 } |
| 31 if (browser_view_->immersive_mode_controller()->IsRevealed()) { |
| 32 // In immersive fullscreen, the TopContainerView paints the window header |
| 33 // (themes, window title, window controls). The TopContainerView must still |
| 34 // paint these even if it does not have any visible children. |
| 35 height = std::max(height, browser_view_->frame()->GetTopInset()); |
| 36 } |
28 return gfx::Size(browser_view_->width(), height); | 37 return gfx::Size(browser_view_->width(), height); |
29 } | 38 } |
30 | 39 |
31 const char* TopContainerView::GetClassName() const { | 40 const char* TopContainerView::GetClassName() const { |
32 return "TopContainerView"; | 41 return "TopContainerView"; |
33 } | 42 } |
34 | 43 |
35 void TopContainerView::PaintChildren(gfx::Canvas* canvas) { | 44 void TopContainerView::OnPaintBackground(gfx::Canvas* canvas) { |
36 if (browser_view_->immersive_mode_controller()->IsRevealed()) { | 45 if (browser_view_->immersive_mode_controller()->IsRevealed()) { |
37 // Top-views depend on parts of the frame (themes, window buttons) being | 46 // Top-views depend on parts of the frame (themes, window title, |
38 // painted underneath them. Clip rect has already been set to the bounds | 47 // window controls) being painted underneath them. Clip rect has already |
39 // of this view, so just paint the frame. | 48 // been set to the bounds of this view, so just paint the frame. |
40 views::View* frame = browser_view_->frame()->GetFrameView(); | 49 views::View* frame = browser_view_->frame()->GetFrameView(); |
41 frame->Paint(canvas); | 50 frame->Paint(canvas); |
42 } | 51 } |
43 | |
44 views::View::PaintChildren(canvas); | |
45 } | 52 } |
OLD | NEW |