Chromium Code Reviews| 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 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 static_cast<float>(y())); | 28 static_cast<float>(y())); |
| 29 transform.ConcatTransform(translation); | 29 transform.ConcatTransform(translation); |
| 30 | 30 |
| 31 gfx::Point origin(parent()->GetBoundsInScreen().origin()); | 31 gfx::Point origin(parent()->GetBoundsInScreen().origin()); |
| 32 transform.TransformPoint(origin); | 32 transform.TransformPoint(origin); |
| 33 return gfx::Rect(origin, size()); | 33 return gfx::Rect(origin, size()); |
| 34 } | 34 } |
| 35 | 35 |
| 36 gfx::Size TopContainerView::GetPreferredSize() { | 36 gfx::Size TopContainerView::GetPreferredSize() { |
| 37 // 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 |
| 38 // its last child view. | 38 // all its children. In particular, the bottom of the bookmark bar can be |
| 39 int last_child_bottom = | 39 // be above the bottom of the toolbar while the bookmark bar is animating. |
|
James Cook
2013/04/25 21:45:21
Good catch.
| |
| 40 child_count() > 0 ? child_at(child_count() - 1)->bounds().bottom() : 0; | 40 int height = 0; |
| 41 return gfx::Size(browser_view_->width(), last_child_bottom); | 41 for (int i = 0; i < child_count(); ++i) { |
| 42 int child_bottom = child_at(i)->bounds().bottom(); | |
| 43 if (child_bottom > height) | |
| 44 height = child_bottom; | |
| 45 } | |
| 46 return gfx::Size(browser_view_->width(), height); | |
| 42 } | 47 } |
| 43 | 48 |
| 44 std::string TopContainerView::GetClassName() const { | 49 std::string TopContainerView::GetClassName() const { |
| 45 return "TopContainerView"; | 50 return "TopContainerView"; |
| 46 } | 51 } |
| 47 | 52 |
| 48 void TopContainerView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 53 void TopContainerView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 49 ImmersiveModeController* immersive_controller = | 54 ImmersiveModeController* immersive_controller = |
| 50 browser_view_->immersive_mode_controller(); | 55 browser_view_->immersive_mode_controller(); |
| 51 if (immersive_controller->IsEnabled()) | 56 if (immersive_controller->IsEnabled()) |
| 52 immersive_controller->OnTopContainerBoundsChanged(); | 57 immersive_controller->OnTopContainerBoundsChanged(); |
| 53 } | 58 } |
| 54 | 59 |
| 55 void TopContainerView::PaintChildren(gfx::Canvas* canvas) { | 60 void TopContainerView::PaintChildren(gfx::Canvas* canvas) { |
| 56 if (browser_view_->immersive_mode_controller()->IsRevealed()) { | 61 if (browser_view_->immersive_mode_controller()->IsRevealed()) { |
| 57 // Top-views depend on parts of the frame (themes, window buttons) being | 62 // Top-views depend on parts of the frame (themes, window buttons) being |
| 58 // painted underneath them. Clip rect has already been set to the bounds | 63 // painted underneath them. Clip rect has already been set to the bounds |
| 59 // of this view, so just paint the frame. | 64 // of this view, so just paint the frame. |
| 60 views::View* frame = browser_view_->frame()->GetFrameView(); | 65 views::View* frame = browser_view_->frame()->GetFrameView(); |
| 61 frame->Paint(canvas); | 66 frame->Paint(canvas); |
| 62 } | 67 } |
| 63 | 68 |
| 64 views::View::PaintChildren(canvas); | 69 views::View::PaintChildren(canvas); |
| 65 } | 70 } |
| OLD | NEW |