Commit a91b2e23 authored by Richard Knoll's avatar Richard Knoll Committed by Commit Bot

Fix notification view message sizing.

The MessageView renders a drop shadow[1] on Windows that adds insets to
the content view of notifications. We need to set the reduced width as
size of the |message_view_| to correctly calculate bounds and wrapping
behavior.

Before: https://imgur.com/pftjgrG
After: https://imgur.com/wEsv5EN

[1]: https://cs.chromium.org/chromium/src/ui/message_center/views/message_view.cc?l=107&rcl=2b3975c5de2635f5a436fb950b42fd5b657ae09f

Bug: 1001047
Change-Id: I8a8b75aea4bdb800596d7790fafa541f2b50a6e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1895333Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Commit-Queue: Richard Knoll <knollr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712962}
parent a9bb78d9
......@@ -1246,28 +1246,24 @@ void NotificationViewMD::UpdateViewForExpandedState(bool expanded) {
list_items_count_ -
(expanded ? item_views_.size() : kMaxLinesForMessageView));
right_content_->SetVisible(icon_view_ &&
(!hide_icon_on_expanded_ || !expanded));
if (right_content_->GetVisible()) {
left_content_->SetBorder(
views::CreateEmptyBorder(kLeftContentPaddingWithIcon));
// TODO(tetsui): Workaround https://crbug.com/682266 by explicitly setting
// the width.
// Ideally, we should fix the original bug, but it seems there's no obvious
// solution for the bug according to https://crbug.com/678337#c7, we should
// ensure that the change won't break any of the users of BoxLayout class.
if (title_view_)
title_view_->SizeToFit(kMessageViewWidthWithIcon);
if (message_view_)
message_view_->SizeToFit(kMessageViewWidthWithIcon);
} else {
left_content_->SetBorder(views::CreateEmptyBorder(kLeftContentPadding));
if (title_view_)
title_view_->SizeToFit(kMessageViewWidth);
if (message_view_)
message_view_->SizeToFit(kMessageViewWidth);
}
bool has_icon = icon_view_ && (!hide_icon_on_expanded_ || !expanded);
right_content_->SetVisible(has_icon);
left_content_->SetBorder(views::CreateEmptyBorder(
has_icon ? kLeftContentPaddingWithIcon : kLeftContentPadding));
// TODO(tetsui): Workaround https://crbug.com/682266 by explicitly setting
// the width.
// Ideally, we should fix the original bug, but it seems there's no obvious
// solution for the bug according to https://crbug.com/678337#c7, we should
// ensure that the change won't break any of the users of BoxLayout class.
const int message_view_width =
(has_icon ? kMessageViewWidthWithIcon : kMessageViewWidth) -
GetInsets().width();
if (title_view_)
title_view_->SizeToFit(message_view_width);
if (message_view_)
message_view_->SizeToFit(message_view_width);
content_row_->InvalidateLayout();
}
......
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