Commit e1dc029e authored by Greg Thompson's avatar Greg Thompson Committed by Commit Bot

Fix Layout() of RelaunchRequiredDialogView.

It was reporting a preferred size inconsistent with its Layout(),
causing potential clipping.

To fix, anticipate the required alignment using constants.

BUG=847904
R=bsep@chromium.org
CC=tapted@chromium.org

Change-Id: I775dbe8a346839914b6dda4965a9c0e97c852661
Reviewed-on: https://chromium-review.googlesource.com/1087965Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Commit-Queue: Greg Thompson <grt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565026}
parent cacb85e3
...@@ -31,6 +31,12 @@ ...@@ -31,6 +31,12 @@
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
#include "ui/views/window/non_client_view.h" #include "ui/views/window/non_client_view.h"
namespace {
constexpr int kTitleIconSize = 20;
} // namespace
// static // static
views::Widget* RelaunchRequiredDialogView::Show( views::Widget* RelaunchRequiredDialogView::Show(
Browser* browser, Browser* browser,
...@@ -122,8 +128,8 @@ bool RelaunchRequiredDialogView::ShouldShowCloseButton() const { ...@@ -122,8 +128,8 @@ bool RelaunchRequiredDialogView::ShouldShowCloseButton() const {
gfx::ImageSkia RelaunchRequiredDialogView::GetWindowIcon() { gfx::ImageSkia RelaunchRequiredDialogView::GetWindowIcon() {
return gfx::CreateVectorIcon(gfx::IconDescription( return gfx::CreateVectorIcon(gfx::IconDescription(
vector_icons::kBusinessIcon, 20, gfx::kChromeIconGrey, base::TimeDelta(), vector_icons::kBusinessIcon, kTitleIconSize, gfx::kChromeIconGrey,
gfx::kNoneIcon)); base::TimeDelta(), gfx::kNoneIcon));
} }
bool RelaunchRequiredDialogView::ShouldShowWindowIcon() const { bool RelaunchRequiredDialogView::ShouldShowWindowIcon() const {
...@@ -137,15 +143,7 @@ int RelaunchRequiredDialogView::GetHeightForWidth(int width) const { ...@@ -137,15 +143,7 @@ int RelaunchRequiredDialogView::GetHeightForWidth(int width) const {
} }
void RelaunchRequiredDialogView::Layout() { void RelaunchRequiredDialogView::Layout() {
// Align the body label with the left edge of the dialog's title. body_label_->SetBoundsRect(GetContentsBounds());
// TODO(bsep): Remove this when fixing https://crbug.com/810970.
gfx::Point origin;
views::View::ConvertPointToWidget(GetBubbleFrameView()->title(), &origin);
views::View::ConvertPointFromWidget(this, &origin);
gfx::Rect bounds = GetContentsBounds();
bounds.Inset(origin.x(), 0, 0, 0);
body_label_->SetBoundsRect(bounds);
} }
// static // static
...@@ -243,6 +241,16 @@ RelaunchRequiredDialogView::RelaunchRequiredDialogView( ...@@ -243,6 +241,16 @@ RelaunchRequiredDialogView::RelaunchRequiredDialogView(
views::style::CONTEXT_MESSAGE_BOX_BODY_TEXT); views::style::CONTEXT_MESSAGE_BOX_BODY_TEXT);
body_label_->SetMultiLine(true); body_label_->SetMultiLine(true);
body_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); body_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
// Align the body label with the left edge of the dialog's title.
// TODO(bsep): Remove this when fixing https://crbug.com/810970.
int title_offset = 2 * views::LayoutProvider::Get()
->GetInsetsMetric(views::INSETS_DIALOG_TITLE)
.left() +
kTitleIconSize;
body_label_->SetBorder(views::CreateEmptyBorder(
gfx::Insets(0, title_offset - margins().left(), 0, 0)));
AddChildView(body_label_); AddChildView(body_label_);
base::RecordAction(base::UserMetricsAction("RelaunchRequiredShown")); base::RecordAction(base::UserMetricsAction("RelaunchRequiredShown"));
......
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