Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Unified Diff: ui/views/bubble/bubble_frame_view.cc

Issue 2955963002: Update Chrome Upstream flow to reflect new UI mocks (Closed)
Patch Set: Actioning code review comments from Patch Set 4 Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..61cdf4c5a90cb33120624aaeb25ef25f023583d2 100644
--- a/ui/views/bubble/bubble_frame_view.cc
+++ b/ui/views/bubble/bubble_frame_view.cc
@@ -72,6 +72,21 @@ int GetOffScreenLength(const gfx::Rect& available_bounds,
} // namespace
+// A container that changes visibility with its contents.
+class FootnoteContainerView : public View {
+ public:
+ FootnoteContainerView() {}
+
+ // View:
+ void ChildVisibilityChanged(View* child) override {
+ DCHECK(child_count() >= 1);
tapted 2017/07/10 03:52:05 nit: Is there a reason to use >= rather than == ?
Jared Saul 2017/07/10 19:24:40 No big reason; just an abundance of caution in cas
+ SetVisible(child_at(0)->visible());
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(FootnoteContainerView);
+};
+
// static
const char BubbleFrameView::kViewClassName[] = "BubbleFrameView";
@@ -132,7 +147,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 +357,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,15 +427,17 @@ void BubbleFrameView::SetFootnoteView(View* view) {
return;
DCHECK(!footnote_container_);
- footnote_container_ = new views::View();
- footnote_container_->SetLayoutManager(
+ FootnoteContainerView* footnote_container = new FootnoteContainerView();
+ footnote_container->SetLayoutManager(
new BoxLayout(BoxLayout::kVertical, content_margins_, 0));
- footnote_container_->SetBackground(
+ footnote_container->SetBackground(
CreateSolidBackground(kFootnoteBackgroundColor));
- footnote_container_->SetBorder(
+ footnote_container->SetBorder(
CreateSolidSidedBorder(1, 0, 0, 0, kFootnoteBorderColor));
- footnote_container_->AddChildView(view);
- AddChildView(footnote_container_);
+ footnote_container->AddChildView(view);
+ footnote_container->SetVisible(view->visible());
tapted 2017/07/10 03:52:05 Using SetVisible (rather than UpdateVisibility), m
Jared Saul 2017/07/10 19:24:40 np, done.
+ AddChildView(footnote_container);
+ footnote_container_ = footnote_container;
}
gfx::Rect BubbleFrameView::GetUpdatedWindowBounds(const gfx::Rect& anchor_rect,
@@ -541,7 +562,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 =

Powered by Google App Engine
This is Rietveld 408576698