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) { ...@@ -1246,28 +1246,24 @@ void NotificationViewMD::UpdateViewForExpandedState(bool expanded) {
list_items_count_ - list_items_count_ -
(expanded ? item_views_.size() : kMaxLinesForMessageView)); (expanded ? item_views_.size() : kMaxLinesForMessageView));
right_content_->SetVisible(icon_view_ && bool has_icon = icon_view_ && (!hide_icon_on_expanded_ || !expanded);
(!hide_icon_on_expanded_ || !expanded)); right_content_->SetVisible(has_icon);
if (right_content_->GetVisible()) { left_content_->SetBorder(views::CreateEmptyBorder(
left_content_->SetBorder( has_icon ? kLeftContentPaddingWithIcon : kLeftContentPadding));
views::CreateEmptyBorder(kLeftContentPaddingWithIcon));
// TODO(tetsui): Workaround https://crbug.com/682266 by explicitly setting
// TODO(tetsui): Workaround https://crbug.com/682266 by explicitly setting // the width.
// the width. // Ideally, we should fix the original bug, but it seems there's no obvious
// 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
// 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.
// ensure that the change won't break any of the users of BoxLayout class. const int message_view_width =
if (title_view_) (has_icon ? kMessageViewWidthWithIcon : kMessageViewWidth) -
title_view_->SizeToFit(kMessageViewWidthWithIcon); GetInsets().width();
if (message_view_) if (title_view_)
message_view_->SizeToFit(kMessageViewWidthWithIcon); title_view_->SizeToFit(message_view_width);
} else { if (message_view_)
left_content_->SetBorder(views::CreateEmptyBorder(kLeftContentPadding)); message_view_->SizeToFit(message_view_width);
if (title_view_)
title_view_->SizeToFit(kMessageViewWidth);
if (message_view_)
message_view_->SizeToFit(kMessageViewWidth);
}
content_row_->InvalidateLayout(); 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