Skip to content

Commit

Permalink
CrOS GMC V2: Remove the global kTextFont
Browse files Browse the repository at this point in the history
Use a local const variable for text fonts since using a global may have
caused crashes in Chrome OS.

Bug: 1482363
Change-Id: Ia3ef624c4ff750a3a39f038c7fef1f86e0563e95
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4939852
Commit-Queue: Yiren Wang <yrw@chromium.org>
Reviewed-by: Tommy Steimel <steimel@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1209739}
  • Loading branch information
Yiren Wang authored and Chromium LUCI CQ committed Oct 13, 2023
1 parent 1b01cf7 commit 9de9a6b
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,14 @@ constexpr int kArtworkCornerRadius = 12;
constexpr int kSourceLineHeight = 18;
constexpr int kTitleArtistLineHeight = 20;
constexpr int kNotMediaActionButtonId = -1;
constexpr int kFontSize = 12;

constexpr float kFocusRingHaloInset = -3.0f;

constexpr auto kArtworkSize = gfx::Size(80, 80);
constexpr auto kPlayPauseButtonSize = gfx::Size(48, 48);
constexpr auto kControlsButtonSize = gfx::Size(32, 32);

const views::Label::CustomFont kTextFont = {
.font_list = gfx::FontList(gfx::FontList({"Google Sans", "Roboto"},
gfx::Font::NORMAL,
/*font_size=*/12,
gfx::Font::Weight::NORMAL))};

const char kMediaDisplayPageHistogramName[] = "Media.Notification.DisplayPage";

class MediaButton : public views::ImageButton {
Expand Down Expand Up @@ -191,8 +186,12 @@ MediaNotificationViewAshImpl::MediaNotificationViewAshImpl(
kMediaInfoSeparator));
main_row_layout->SetFlexForView(media_info_column, 1);

const views::Label::CustomFont text_fonts = {
gfx::FontList({"Google Sans", "Roboto"}, gfx::Font::NORMAL, kFontSize,
gfx::Font::Weight::NORMAL)};

source_label_ = media_info_column->AddChildView(
std::make_unique<views::Label>(base::EmptyString16(), kTextFont));
std::make_unique<views::Label>(base::EmptyString16(), text_fonts));
source_label_->SetLineHeight(kSourceLineHeight);
source_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
source_label_->SetEnabledColorId(theme_.secondary_foreground_color_id);
Expand All @@ -204,7 +203,7 @@ MediaNotificationViewAshImpl::MediaNotificationViewAshImpl(
views::BoxLayout::CrossAxisAlignment::kCenter);

title_label_ = title_row_->AddChildView(
std::make_unique<views::Label>(base::EmptyString16(), kTextFont));
std::make_unique<views::Label>(base::EmptyString16(), text_fonts));
title_label_->SetLineHeight(kTitleArtistLineHeight);
title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
title_label_->SetEnabledColorId(theme_.primary_foreground_color_id);
Expand All @@ -221,7 +220,7 @@ MediaNotificationViewAshImpl::MediaNotificationViewAshImpl(
}

artist_label_ = media_info_column->AddChildView(
std::make_unique<views::Label>(base::EmptyString16(), kTextFont));
std::make_unique<views::Label>(base::EmptyString16(), text_fonts));
artist_label_->SetLineHeight(kTitleArtistLineHeight);
artist_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
artist_label_->SetEnabledColorId(theme_.secondary_foreground_color_id);
Expand Down

0 comments on commit 9de9a6b

Please sign in to comment.