Commit 39192057 authored by Peter Beverloo's avatar Peter Beverloo Committed by Commit Bot

Fix a number of DCHECKs in NotificationHeaderView

The header view includes a number of DCHECKs to verify that the metrics
of the created layout match the mocks. This is fine, but there's a
subtlety in the preferred height of views::Label: the text's size is
determined by using the maximum of the font height and the line height.

The line height is set in Label's constructor based on the text style,
where it consults the typography provider available from the layout
provider. There are three versions of this: DefaultTypographyProvider,
LegacyTypographyProvider and HarmonyTypographyProvider.

The first two return 0, and thereby defer to the font list. The harmony
provider has a calculation involving platform-specific values. This
grows the height of the labels, thereby failing the DCHECKs.

Instead, change the labels to always defer to the font list for their
line height. This removes the platform-specific dependency.

BUG=

Change-Id: I6530b4517bd7bf6ba62f36cd595e05e616b580d4
Reviewed-on: https://chromium-review.googlesource.com/788957Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519574}
parent f5010e83
...@@ -189,14 +189,16 @@ NotificationHeaderView::NotificationHeaderView( ...@@ -189,14 +189,16 @@ NotificationHeaderView::NotificationHeaderView(
DCHECK_EQ(kInnerHeaderHeight, app_icon_view_->GetPreferredSize().height()); DCHECK_EQ(kInnerHeaderHeight, app_icon_view_->GetPreferredSize().height());
app_info_container->AddChildView(app_icon_view_); app_info_container->AddChildView(app_icon_view_);
// Font list for text views. // Font list for text views. The height must be 15px to match with the mock.
const gfx::FontList& font_list = GetHeaderTextFontList(); gfx::FontList font_list = GetHeaderTextFontList();
// The height must be 15px to match with the mock.
DCHECK_EQ(15, font_list.GetHeight()); DCHECK_EQ(15, font_list.GetHeight());
const int font_list_height = font_list.GetHeight();
// App name view // App name view
app_name_view_ = new views::Label(base::string16()); app_name_view_ = new views::Label(base::string16());
app_name_view_->SetFontList(font_list); app_name_view_->SetFontList(font_list);
app_name_view_->SetLineHeight(font_list_height);
app_name_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); app_name_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
app_name_view_->SetEnabledColor(accent_color_); app_name_view_->SetEnabledColor(accent_color_);
app_name_view_->SetBorder(views::CreateEmptyBorder(kTextViewPadding)); app_name_view_->SetBorder(views::CreateEmptyBorder(kTextViewPadding));
...@@ -207,6 +209,7 @@ NotificationHeaderView::NotificationHeaderView( ...@@ -207,6 +209,7 @@ NotificationHeaderView::NotificationHeaderView(
summary_text_divider_ = summary_text_divider_ =
new views::Label(base::WideToUTF16(kNotificationHeaderDivider)); new views::Label(base::WideToUTF16(kNotificationHeaderDivider));
summary_text_divider_->SetFontList(font_list); summary_text_divider_->SetFontList(font_list);
summary_text_divider_->SetLineHeight(font_list_height);
summary_text_divider_->SetHorizontalAlignment(gfx::ALIGN_LEFT); summary_text_divider_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
summary_text_divider_->SetBorder(views::CreateEmptyBorder(kTextViewPadding)); summary_text_divider_->SetBorder(views::CreateEmptyBorder(kTextViewPadding));
summary_text_divider_->SetVisible(false); summary_text_divider_->SetVisible(false);
...@@ -217,6 +220,7 @@ NotificationHeaderView::NotificationHeaderView( ...@@ -217,6 +220,7 @@ NotificationHeaderView::NotificationHeaderView(
// Summary text view // Summary text view
summary_text_view_ = new views::Label(base::string16()); summary_text_view_ = new views::Label(base::string16());
summary_text_view_->SetFontList(font_list); summary_text_view_->SetFontList(font_list);
summary_text_view_->SetLineHeight(font_list_height);
summary_text_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); summary_text_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
summary_text_view_->SetBorder(views::CreateEmptyBorder(kTextViewPadding)); summary_text_view_->SetBorder(views::CreateEmptyBorder(kTextViewPadding));
summary_text_view_->SetVisible(false); summary_text_view_->SetVisible(false);
...@@ -228,6 +232,7 @@ NotificationHeaderView::NotificationHeaderView( ...@@ -228,6 +232,7 @@ NotificationHeaderView::NotificationHeaderView(
timestamp_divider_ = timestamp_divider_ =
new views::Label(base::WideToUTF16(kNotificationHeaderDivider)); new views::Label(base::WideToUTF16(kNotificationHeaderDivider));
timestamp_divider_->SetFontList(font_list); timestamp_divider_->SetFontList(font_list);
timestamp_divider_->SetLineHeight(font_list_height);
timestamp_divider_->SetHorizontalAlignment(gfx::ALIGN_LEFT); timestamp_divider_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
timestamp_divider_->SetBorder(views::CreateEmptyBorder(kTextViewPadding)); timestamp_divider_->SetBorder(views::CreateEmptyBorder(kTextViewPadding));
timestamp_divider_->SetVisible(false); timestamp_divider_->SetVisible(false);
...@@ -238,6 +243,7 @@ NotificationHeaderView::NotificationHeaderView( ...@@ -238,6 +243,7 @@ NotificationHeaderView::NotificationHeaderView(
// Timestamp view // Timestamp view
timestamp_view_ = new views::Label(base::string16()); timestamp_view_ = new views::Label(base::string16());
timestamp_view_->SetFontList(font_list); timestamp_view_->SetFontList(font_list);
timestamp_view_->SetLineHeight(font_list_height);
timestamp_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); timestamp_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
timestamp_view_->SetBorder(views::CreateEmptyBorder(kTextViewPadding)); timestamp_view_->SetBorder(views::CreateEmptyBorder(kTextViewPadding));
timestamp_view_->SetVisible(false); timestamp_view_->SetVisible(false);
......
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