Commit 5003a6a5 authored by Allen Bauer's avatar Allen Bauer Committed by Commit Bot

Use GetColorWithMinimumContrast instead of manually calculating a contrasting color.

The previous patch attempting to fix this, https://crrev.com/c/1188434, didn't blend
in the right direction. It got the background color calculation correct, but the
title color calculation wasn't right.

This change just uses GetColorWithMinimumContrast directly so that the text (and the
close button icon) has sufficient contrast on a selected inactive tab.

Bug: 876794
Change-Id: I8ee0a8f2a38aac60c14d104fbf75c3ef85304720
Reviewed-on: https://chromium-review.googlesource.com/1191189Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Allen Bauer <kylixrd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586359}
parent 59e15bbc
...@@ -1788,18 +1788,16 @@ void Tab::UpdateButtonIconColors(SkColor title_color) { ...@@ -1788,18 +1788,16 @@ void Tab::UpdateButtonIconColors(SkColor title_color) {
IsActive() ? TAB_ACTIVE : TAB_INACTIVE, true); IsActive() ? TAB_ACTIVE : TAB_INACTIVE, true);
SkColor tab_title_color = title_color; SkColor tab_title_color = title_color;
// Make sure the text has enough contrast to be visible if this tab is
// selected.
if (IsSelected() && !IsActive()) { if (IsSelected() && !IsActive()) {
const SkColor tab_inactive_bg_color = tab_bg_color;
const SkColor tab_active_bg_color = const SkColor tab_active_bg_color =
controller_->GetTabBackgroundColor(TAB_ACTIVE, true); controller_->GetTabBackgroundColor(TAB_ACTIVE, true);
tab_bg_color = color_utils::AlphaBlend( tab_bg_color = color_utils::AlphaBlend(
tab_active_bg_color, tab_bg_color, tab_active_bg_color, tab_bg_color,
gfx::ToRoundedInt(kSelectedTabOpacity * SK_AlphaOPAQUE)); gfx::ToRoundedInt(kSelectedTabOpacity * SK_AlphaOPAQUE));
const SkAlpha blend_alpha = color_utils::GetBlendValueWithMinimumContrast(
tab_bg_color, title_color, tab_inactive_bg_color,
kMinimumInactiveContrastRatio);
tab_title_color = tab_title_color =
color_utils::AlphaBlend(title_color, tab_bg_color, blend_alpha); color_utils::GetColorWithMinimumContrast(title_color, tab_bg_color);
} }
title_->SetEnabledColor(tab_title_color); title_->SetEnabledColor(tab_title_color);
......
...@@ -139,7 +139,7 @@ class Tab : public gfx::AnimationDelegate, ...@@ -139,7 +139,7 @@ class Tab : public gfx::AnimationDelegate,
// Called when the frame state color changes. // Called when the frame state color changes.
void FrameColorsChanged(); void FrameColorsChanged();
// Called with the selected state changes. // Called when the selected state changes.
void SelectedStateChanged(); void SelectedStateChanged();
// Returns true if the tab is selected. // Returns true if the tab is selected.
......
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