Commit b65dfd41 authored by Tom Anderson's avatar Tom Anderson Committed by Commit Bot

[GTK] Fix DCHECK when themes don't provide opaque frame colors

Issue can be triggered by running Chrome with testing/xvfb.py.  The check looks
like the following:

[130960:130960:0921/173814.814345:FATAL:color_utils.cc(356)] Check failed: (((base) >> 24) & 0xFF) == SK_AlphaOPAQUE (0 vs. �)
0 0x7f05478f815d base::debug::StackTrace::StackTrace()
1 0x7f05475ff9ac base::debug::StackTrace::StackTrace()
2 0x7f054766f47a logging::LogMessage::~LogMessage()
3 0x7f0545ec4e19 color_utils::GetBlendValueWithMinimumContrast()
4 0x7f0545ec4d25 color_utils::GetColorWithMinimumContrast()
5 0x7f05319ec298 libgtkui::GtkUi::LoadGtkValues()
6 0x7f05319eb2ae libgtkui::GtkUi::Initialize()
7 0x55847d44a79b ChromeBrowserMainExtraPartsViewsLinux::ToolkitInitialized()
8 0x558478c10b15 ChromeBrowserMainParts::ToolkitInitialized()
9 0x558478c0a9c5 ChromeBrowserMainPartsLinux::ToolkitInitialized()
10 0x7f0540a4b64d content::BrowserMainLoop::InitializeToolkit()
11 0x7f0540a4e7b5 content::BrowserMainRunnerImpl::Initialize()
12 0x7f0540a39a6b content::BrowserMain()
13 0x7f05428fefe4 content::RunBrowserProcessMain()
14 0x7f05429018cb content::ContentMainRunnerImpl::Run()
15 0x7f05428f67cc content::ContentServiceManagerMainDelegate::RunEmbedderProcess()
16 0x7f0547ba37fa service_manager::Main()
17 0x7f05428fca23 content::ContentMain()
18 0x558476d46246 ChromeMain
19 0x558476d46152 main
20 0x7f051c7152b1 __libc_start_main
21 0x558476d4602a _start

R=pkasting

Change-Id: Ib6d421dc3cd0f8fb9a41afd4b1487548404f58f0
Reviewed-on: https://chromium-review.googlesource.com/1238487Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593726}
parent 5de70a38
......@@ -877,22 +877,16 @@ void GtkUi::OnDeviceScaleFactorMaybeChanged(void*, GParamSpec*) {
}
void GtkUi::LoadGtkValues() {
// TODO(erg): GtkThemeService had a comment here about having to muck with
// the raw Prefs object to remove prefs::kCurrentThemeImages or else we'd
// regress startup time. Figure out how to do that when we can't access the
// prefs system from here.
// TODO(thomasanderson): GtkThemeService had a comment here about having to
// muck with the raw Prefs object to remove prefs::kCurrentThemeImages or else
// we'd regress startup time. Figure out how to do that when we can't access
// the prefs system from here.
UpdateDeviceScaleFactor();
UpdateCursorTheme();
UpdateColors();
}
SkColor tab_color = GetBgColor("");
SkColor tab_text_color = GetFgColor("GtkLabel");
colors_[ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON] = tab_text_color;
colors_[ThemeProperties::COLOR_TAB_TEXT] = tab_text_color;
colors_[ThemeProperties::COLOR_BOOKMARK_TEXT] = tab_text_color;
void GtkUi::UpdateColors() {
SkColor location_bar_border = GetBorderColor("GtkEntry#entry");
if (SkColorGetA(location_bar_border))
colors_[ThemeProperties::COLOR_LOCATION_BAR_BORDER] = location_bar_border;
......@@ -907,9 +901,6 @@ void GtkUi::LoadGtkValues() {
: "GtkTextView.view:selected:backdrop");
SkColor tab_border = GetBorderColor("GtkButton#button");
colors_[ThemeProperties::COLOR_DETACHED_BOOKMARK_BAR_BACKGROUND] = tab_color;
colors_[ThemeProperties::COLOR_BOOKMARK_BAR_INSTRUCTIONS_TEXT] =
tab_text_color;
// Separates the toolbar from the bookmark bar or butter bars.
colors_[ThemeProperties::COLOR_TOOLBAR_CONTENT_AREA_SEPARATOR] = tab_border;
// Separates entries in the downloads bar.
......@@ -925,6 +916,43 @@ void GtkUi::LoadGtkValues() {
colors_[ThemeProperties::COLOR_NTP_HEADER] =
GetBorderColor("GtkButton#button");
SkColor tab_text_color = GetFgColor("GtkLabel");
colors_[ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON] = tab_text_color;
colors_[ThemeProperties::COLOR_TAB_TEXT] = tab_text_color;
colors_[ThemeProperties::COLOR_BOOKMARK_TEXT] = tab_text_color;
colors_[ThemeProperties::COLOR_BOOKMARK_BAR_INSTRUCTIONS_TEXT] =
tab_text_color;
colors_[ThemeProperties::COLOR_BACKGROUND_TAB] = SK_ColorTRANSPARENT;
colors_[ThemeProperties::COLOR_BACKGROUND_TAB_INACTIVE] = SK_ColorTRANSPARENT;
colors_[ThemeProperties::COLOR_BACKGROUND_TAB_INCOGNITO] =
SK_ColorTRANSPARENT;
colors_[ThemeProperties::COLOR_BACKGROUND_TAB_INCOGNITO_INACTIVE] =
SK_ColorTRANSPARENT;
colors_[ThemeProperties::COLOR_NTP_LINK] = native_theme_->GetSystemColor(
ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused);
// Generate the colors that we pass to WebKit.
focus_ring_color_ = native_theme_->GetSystemColor(
ui::NativeTheme::kColorId_FocusedBorderColor);
// Some GTK themes only define the text selection colors on the GtkEntry
// class, so we need to use that for getting selection colors.
active_selection_bg_color_ = native_theme_->GetSystemColor(
ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused);
active_selection_fg_color_ = native_theme_->GetSystemColor(
ui::NativeTheme::kColorId_TextfieldSelectionColor);
colors_[ThemeProperties::COLOR_TAB_THROBBER_SPINNING] =
native_theme_->GetSystemColor(
ui::NativeTheme::kColorId_ThrobberSpinningColor);
colors_[ThemeProperties::COLOR_TAB_THROBBER_WAITING] =
native_theme_->GetSystemColor(
ui::NativeTheme::kColorId_ThrobberWaitingColor);
// Generate colors that depend on whether or not a custom window frame is
// used. These colors belong in |color_map| below, not |colors_|.
for (bool custom_frame : {false, true}) {
ColorMap& color_map =
custom_frame ? custom_frame_colors_ : native_frame_colors_;
......@@ -932,10 +960,12 @@ void GtkUi::LoadGtkValues() {
? "#headerbar.header-bar.titlebar"
: "GtkMenuBar#menubar";
const std::string header_selector_inactive = header_selector + ":backdrop";
const SkColor frame_color = GetBgColor(header_selector);
const SkColor frame_color =
SkColorSetA(GetBgColor(header_selector), SK_AlphaOPAQUE);
const SkColor frame_color_incognito =
color_utils::HSLShift(frame_color, kDefaultTintFrameIncognito);
const SkColor frame_color_inactive = GetBgColor(header_selector_inactive);
const SkColor frame_color_inactive =
SkColorSetA(GetBgColor(header_selector_inactive), SK_AlphaOPAQUE);
const SkColor frame_color_incognito_inactive =
color_utils::HSLShift(frame_color_inactive, kDefaultTintFrameIncognito);
......@@ -945,14 +975,16 @@ void GtkUi::LoadGtkValues() {
color_map[ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE] =
frame_color_incognito_inactive;
if (ui::MaterialDesignController::IsRefreshUi()) {
colors_[ThemeProperties::COLOR_BACKGROUND_TAB] = SK_ColorTRANSPARENT;
colors_[ThemeProperties::COLOR_BACKGROUND_TAB_INACTIVE] =
SK_ColorTRANSPARENT;
colors_[ThemeProperties::COLOR_BACKGROUND_TAB_INCOGNITO] =
SK_ColorTRANSPARENT;
colors_[ThemeProperties::COLOR_BACKGROUND_TAB_INCOGNITO_INACTIVE] =
SK_ColorTRANSPARENT;
// Compose the window color on the frame color to ensure the resulting tab
// color is opaque.
SkColor tab_color =
color_utils::GetResultingPaintColor(GetBgColor(""), frame_color);
color_map[ThemeProperties::COLOR_TOOLBAR] = tab_color;
color_map[ThemeProperties::COLOR_CONTROL_BACKGROUND] = tab_color;
color_map[ThemeProperties::COLOR_DETACHED_BOOKMARK_BAR_BACKGROUND] =
tab_color;
const SkColor background_tab_text_color =
GetFgColor(header_selector + " GtkLabel.title");
......@@ -973,58 +1005,6 @@ void GtkUi::LoadGtkValues() {
color_utils::HSLShift(background_tab_text_color_inactive,
kDefaultTintFrameIncognito),
frame_color_incognito_inactive);
} else {
color_utils::HSL frame_hsl;
color_utils::SkColorToHSL(frame_color, &frame_hsl);
color_utils::HSL frame_hsl_inactive;
color_utils::SkColorToHSL(frame_color_inactive, &frame_hsl_inactive);
const color_utils::HSL inactive_shift =
color_utils::HSL{-1, (frame_hsl_inactive.s - frame_hsl.s + 1) / 2,
(frame_hsl_inactive.l - frame_hsl.l + 1) / 2};
const SkColor background_tab_color =
color_utils::HSLShift(tab_color, kDefaultTintBackgroundTab);
const SkColor background_tab_color_inactive =
color_utils::HSLShift(background_tab_color, inactive_shift);
const SkColor background_tab_color_incognito =
color_utils::HSLShift(tab_color, kDefaultTintBackgroundTabIncognito);
const SkColor background_tab_color_incognito_inactive =
color_utils::HSLShift(background_tab_color_incognito, inactive_shift);
colors_[ThemeProperties::COLOR_BACKGROUND_TAB] = background_tab_color;
colors_[ThemeProperties::COLOR_BACKGROUND_TAB_INACTIVE] =
background_tab_color_inactive;
colors_[ThemeProperties::COLOR_BACKGROUND_TAB_INCOGNITO] =
background_tab_color_incognito;
colors_[ThemeProperties::COLOR_BACKGROUND_TAB_INCOGNITO_INACTIVE] =
background_tab_color_incognito_inactive;
const SkColor background_tab_text_color =
color_utils::BlendTowardOppositeLuma(tab_text_color, 50);
const SkColor background_tab_text_color_incognito = color_utils::HSLShift(
background_tab_text_color, kDefaultTintFrameIncognito);
const SkColor background_tab_text_color_inactive =
color_utils::HSLShift(background_tab_text_color, inactive_shift);
const SkColor background_tab_text_color_incognito_inactive =
color_utils::HSLShift(background_tab_text_color_incognito,
inactive_shift);
color_map[ThemeProperties::COLOR_BACKGROUND_TAB_TEXT] =
color_utils::GetColorWithMinimumContrast(background_tab_text_color,
background_tab_color);
color_map[ThemeProperties::COLOR_BACKGROUND_TAB_TEXT_INCOGNITO] =
color_utils::GetColorWithMinimumContrast(
background_tab_text_color_incognito,
background_tab_color_incognito);
color_map[ThemeProperties::COLOR_BACKGROUND_TAB_TEXT_INACTIVE] =
color_utils::GetColorWithMinimumContrast(
background_tab_text_color_inactive,
background_tab_color_inactive);
color_map[ThemeProperties::COLOR_BACKGROUND_TAB_TEXT_INCOGNITO_INACTIVE] =
color_utils::GetColorWithMinimumContrast(
background_tab_text_color_incognito_inactive,
background_tab_color_incognito_inactive);
}
// These colors represent the border drawn around tabs and between
// the tabstrip and toolbar.
......@@ -1050,30 +1030,6 @@ void GtkUi::LoadGtkValues() {
toolbar_top_separator_inactive;
}
}
colors_[ThemeProperties::COLOR_TOOLBAR] = tab_color;
colors_[ThemeProperties::COLOR_CONTROL_BACKGROUND] = tab_color;
colors_[ThemeProperties::COLOR_NTP_LINK] = native_theme_->GetSystemColor(
ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused);
// Generate the colors that we pass to WebKit.
focus_ring_color_ = native_theme_->GetSystemColor(
ui::NativeTheme::kColorId_FocusedBorderColor);
// Some GTK themes only define the text selection colors on the GtkEntry
// class, so we need to use that for getting selection colors.
active_selection_bg_color_ = native_theme_->GetSystemColor(
ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused);
active_selection_fg_color_ = native_theme_->GetSystemColor(
ui::NativeTheme::kColorId_TextfieldSelectionColor);
colors_[ThemeProperties::COLOR_TAB_THROBBER_SPINNING] =
native_theme_->GetSystemColor(
ui::NativeTheme::kColorId_ThrobberSpinningColor);
colors_[ThemeProperties::COLOR_TAB_THROBBER_WAITING] =
native_theme_->GetSystemColor(
ui::NativeTheme::kColorId_ThrobberWaitingColor);
}
void GtkUi::UpdateCursorTheme() {
......
......@@ -128,9 +128,12 @@ class GtkUi : public views::LinuxUI {
void*,
GParamSpec*);
// Loads all GTK-provided settings.
void LoadGtkValues();
// Extracts colors and tints from the GTK theme, both for the
// ThemeService interface and the colors we send to webkit.
void LoadGtkValues();
void UpdateColors();
// Sets the Xcursor theme and size with the GTK theme and size.
void UpdateCursorTheme();
......
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