Chromium Code Reviews| Index: ui/views/bubble/bubble_frame_view.cc |
| diff --git a/ui/views/bubble/bubble_frame_view.cc b/ui/views/bubble/bubble_frame_view.cc |
| index 2dd002e5a7192c4fa1d47b4089a66f845eb4c08c..ddfb2f3781f93bdfb913ec146fc5978b158ff729 100644 |
| --- a/ui/views/bubble/bubble_frame_view.cc |
| +++ b/ui/views/bubble/bubble_frame_view.cc |
| @@ -72,6 +72,24 @@ int GetOffScreenLength(const gfx::Rect& available_bounds, |
| } // namespace |
| +// Simple container to bubble child view changes up the view hierarchy. |
|
msw
2017/07/05 20:45:30
nit: s/bubble/propagate/, or consider "A container
Jared Saul
2017/07/07 20:12:27
Done; took your full suggestion.
|
| +class BubbleFrameView::FootnoteContainerView : public View { |
| + public: |
| + FootnoteContainerView() {} |
| + |
| + void UpdateVisibility() { |
| + if (child_count() >= 1) { |
|
tapted
2017/07/06 01:11:58
I think this is always true? ChildVisibilityChange
Jared Saul
2017/07/07 20:12:27
Done.
|
| + SetVisible(child_at(0)->visible()); |
| + } |
| + } |
| + |
| + // View: |
| + void ChildVisibilityChanged(View* child) override { UpdateVisibility(); } |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(FootnoteContainerView); |
| +}; |
| + |
| // static |
| const char BubbleFrameView::kViewClassName[] = "BubbleFrameView"; |
| @@ -132,7 +150,9 @@ Button* BubbleFrameView::CreateCloseButton(ButtonListener* listener) { |
| gfx::Rect BubbleFrameView::GetBoundsForClientView() const { |
| gfx::Rect client_bounds = GetContentsBounds(); |
| client_bounds.Inset(GetInsets()); |
| - if (footnote_container_) { |
| + // Only account for footnote_container_'s height if it's visible, because |
| + // content_margins_ adds extra padding even if all child views are invisible. |
| + if (footnote_container_ && footnote_container_->visible()) { |
| client_bounds.set_height(client_bounds.height() - |
| footnote_container_->height()); |
| } |
| @@ -340,7 +360,9 @@ void BubbleFrameView::Layout() { |
| bounds.set_width(title_->bounds().right() - bounds.x()); |
| bounds.set_height(title_height); |
| - if (footnote_container_) { |
| + // Only account for footnote_container_'s height if it's visible, because |
| + // content_margins_ adds extra padding even if all child views are invisible. |
| + if (footnote_container_ && footnote_container_->visible()) { |
| const int width = contents_bounds.width(); |
| const int height = footnote_container_->GetHeightForWidth(width); |
| footnote_container_->SetBounds( |
| @@ -408,7 +430,7 @@ void BubbleFrameView::SetFootnoteView(View* view) { |
| return; |
| DCHECK(!footnote_container_); |
| - footnote_container_ = new views::View(); |
| + footnote_container_ = new FootnoteContainerView(); |
|
tapted
2017/07/06 01:11:59
I see msw commented about this in the test :) - th
Jared Saul
2017/07/07 20:12:27
Thanks; this was really useful.
|
| footnote_container_->SetLayoutManager( |
| new BoxLayout(BoxLayout::kVertical, content_margins_, 0)); |
| footnote_container_->SetBackground( |
| @@ -416,6 +438,7 @@ void BubbleFrameView::SetFootnoteView(View* view) { |
| footnote_container_->SetBorder( |
| CreateSolidSidedBorder(1, 0, 0, 0, kFootnoteBorderColor)); |
| footnote_container_->AddChildView(view); |
| + footnote_container_->UpdateVisibility(); |
|
tapted
2017/07/06 01:11:58
or, perhaps simpler, just call
footnote_container
Jared Saul
2017/07/07 20:12:28
Done.
|
| AddChildView(footnote_container_); |
| } |
| @@ -541,7 +564,9 @@ gfx::Size BubbleFrameView::GetSizeForClientSize( |
| size.Enlarge(client_insets.width(), client_insets.height()); |
| size.SetToMax(gfx::Size(title_bar_width, 0)); |
| - if (footnote_container_) |
| + // Only account for footnote_container_'s height if it's visible, because |
| + // content_margins_ adds extra padding even if all child views are invisible. |
| + if (footnote_container_ && footnote_container_->visible()) |
| size.Enlarge(0, footnote_container_->GetHeightForWidth(size.width())); |
| DialogDelegate* dialog_delegate = |