Commit dd1b2ea0 authored by Dominic Mazzoni's avatar Dominic Mazzoni Committed by Commit Bot

Set maximum width for all internal page info bubbles.

Page info bubbles just display a single string. To match recent UX
mocks, the text of these bubbles should be multi-line and the bubbles
should be the minimum width for a page info bubble (currently 320px).

Bug: 1124489
Change-Id: I5fbe9e3395b450d8f45b7cc55f5bb09aeb95a1e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2409136Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Commit-Queue: Dominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807124}
parent 06c6798c
......@@ -194,6 +194,8 @@ class InternalPageInfoBubbleView : public PageInfoBubbleViewBase {
const GURL& url);
~InternalPageInfoBubbleView() override;
gfx::Size CalculatePreferredSize() const override;
DISALLOW_COPY_AND_ASSIGN(InternalPageInfoBubbleView);
};
......@@ -405,11 +407,16 @@ InternalPageInfoBubbleView::InternalPageInfoBubbleView(
views::BubbleDialogDelegateView::CreateBubble(this);
SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical, gfx::Insets(),
ChromeLayoutProvider::Get()->GetDistanceMetric(
views::DISTANCE_RELATED_CONTROL_VERTICAL)));
// Use a normal label's style for the title since there is no content.
views::Label* title_label =
static_cast<views::Label*>(GetBubbleFrameView()->title());
title_label->SetFontList(views::Label::GetDefaultFontList());
title_label->SetMultiLine(false);
title_label->SetMultiLine(true);
title_label->SetElideBehavior(gfx::NO_ELIDE);
SizeToContents();
......@@ -417,6 +424,20 @@ InternalPageInfoBubbleView::InternalPageInfoBubbleView(
InternalPageInfoBubbleView::~InternalPageInfoBubbleView() {}
gfx::Size InternalPageInfoBubbleView::CalculatePreferredSize() const {
// Without a layout manager this will recurse infinitely
// (GetHeightForWidth() calls CalculatePreferredSize()).
// TODO(crbug.com/1128500): Fix infinite recursion or always
// install a layout manager.
if (!GetLayoutManager())
return gfx::Size();
const int width = ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_BUBBLE_PREFERRED_WIDTH) -
margins().width();
return gfx::Size(width, GetHeightForWidth(width));
}
////////////////////////////////////////////////////////////////////////////////
// PageInfoBubbleView
////////////////////////////////////////////////////////////////////////////////
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment