Skip to content

Commit

Permalink
Unify disabled and secondary foreground color concepts.
Browse files Browse the repository at this point in the history
These were both based off GG600 and both used for text, but one was made to have
4.5 contrast and one wasn't.  Since they're both used for text, we always want
to ensure 4.5 contrast.  Unify these.

This results in slight changes to disabled buttons and disabled menu items.  See
the ButtonDisabledForeground and MenuItemDisabledForeground entries in
https://docs.google.com/spreadsheets/d/1JoxAN5E-92ziNhIyWySVW4qzwRYtdNdVDsUtk894R3s/edit?usp=sharing
for more.

Bug: 1024091
Change-Id: I11e31e6784a3d8e651b3a936bb285edf1a8a36ce
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1922453
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: Robert Liao <robliao@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#716410}
  • Loading branch information
pkasting authored and Commit Bot committed Nov 19, 2019
1 parent df83d88 commit 9073e82
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
1 change: 0 additions & 1 deletion ui/color/color_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ enum ColorIds : ColorId {
kColorAlertHighSeverity,
kColorAlertLowSeverity,
kColorAlertMediumSeverity,
kColorDisabledForeground,
kColorBodyForeground,
kColorLinkForeground,
kColorPrimaryBackground,
Expand Down
7 changes: 2 additions & 5 deletions ui/color/core_default_color_mixer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ ColorMixer& AddMixerForDarkMode(ColorProvider* provider) {
{kColorAlertHighSeverity, gfx::kGoogleRed300},
{kColorAlertLowSeverity, gfx::kGoogleGreen300},
{kColorAlertMediumSeverity, gfx::kGoogleYellow300},
{kColorDisabledForeground, gfx::kGoogleGrey600},
{kColorBodyForeground, gfx::kGoogleGrey500},
{kColorLinkForeground, gfx::kGoogleBlue300},
{kColorPrimaryBackground, SkColorSetRGB(0x29, 0x2A, 0x2D)},
Expand All @@ -48,7 +47,6 @@ ColorMixer& AddMixerForLightMode(ColorProvider* provider) {
{kColorAlertHighSeverity, gfx::kGoogleRed600},
{kColorAlertLowSeverity, gfx::kGoogleGreen700},
{kColorAlertMediumSeverity, gfx::kGoogleYellow700},
{kColorDisabledForeground, gfx::kGoogleGrey600},
{kColorBodyForeground, gfx::kGoogleGrey700},
{kColorLinkForeground, gfx::kGoogleBlue700},
{kColorPrimaryBackground, SK_ColorWHITE},
Expand All @@ -67,9 +65,8 @@ void AddCoreDefaultColorMixers(ColorProvider* provider, bool dark_window) {
: AddMixerForLightMode(provider);
mixer[kColorSecondaryBackground] =
BlendForMinContrastWithSelf(kColorPrimaryBackground, 1.67f);
mixer[kColorSecondaryForeground] =
BlendForMinContrast(kColorDisabledForeground, kColorPrimaryBackground,
kColorPrimaryForeground);
mixer[kColorSecondaryForeground] = BlendForMinContrast(
gfx::kGoogleGrey600, kColorPrimaryBackground, kColorPrimaryForeground);
// TODO(pkasting): High contrast?
}

Expand Down
4 changes: 2 additions & 2 deletions ui/color/ui_color_mixer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void AddUiColorMixers(ColorProvider* provider) {
mixer[kColorBubbleFooterBackground] = {kColorSecondaryBackgroundSubtle};
mixer[kColorButtonBackground] = {kColorPrimaryBackground};
mixer[kColorButtonBorder] = {kColorSecondaryBackground};
mixer[kColorButtonDisabledForeground] = {kColorDisabledForeground};
mixer[kColorButtonDisabledForeground] = {kColorSecondaryForeground};
mixer[kColorButtonForeground] = {kColorAccent};
mixer[kColorButtonProminentBackground] = {kColorAccent};
mixer[kColorButtonProminentDisabledBackground] =
Expand All @@ -44,7 +44,7 @@ void AddUiColorMixers(ColorProvider* provider) {
mixer[kColorMenuBackground] = {kColorPrimaryBackground};
mixer[kColorMenuBorder] = {kColorSecondaryBackground};
mixer[kColorMenuItemAlertedBackground] = {kColorAccent};
mixer[kColorMenuItemDisabledForeground] = {kColorDisabledForeground};
mixer[kColorMenuItemDisabledForeground] = {kColorSecondaryForeground};
mixer[kColorMenuItemForeground] = {kColorPrimaryForeground};
mixer[kColorMenuItemHighlightedBackground] = {
kColorSecondaryBackgroundSubtle};
Expand Down
15 changes: 10 additions & 5 deletions ui/native_theme/common_theme.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ SkColor GetAuraColor(NativeTheme::ColorId color_id,
}

constexpr SkColor kPrimaryTextColor = gfx::kGoogleGrey900;
constexpr SkColor kDisabledTextColor = gfx::kGoogleGrey600;

// Text selection colors:
constexpr SkColor kTextSelectionBackgroundFocused =
Expand Down Expand Up @@ -192,8 +191,14 @@ SkColor GetAuraColor(NativeTheme::ColorId color_id,
return SK_ColorWHITE;
case NativeTheme::kColorId_ButtonPressedShade:
return SK_ColorTRANSPARENT;
case NativeTheme::kColorId_ButtonDisabledColor:
return kDisabledTextColor;
case NativeTheme::kColorId_ButtonDisabledColor: {
const SkColor bg = base_theme->GetSystemColor(
NativeTheme::kColorId_DialogBackground, color_scheme);
const SkColor fg = base_theme->GetSystemColor(
NativeTheme::kColorId_LabelEnabledColor, color_scheme);
return color_utils::BlendForMinContrast(gfx::kGoogleGrey600, bg, fg)
.color;
}
case NativeTheme::kColorId_ProminentButtonDisabledColor:
return gfx::kGoogleGrey100;
case NativeTheme::kColorId_ButtonBorderColor:
Expand All @@ -216,13 +221,13 @@ SkColor GetAuraColor(NativeTheme::ColorId color_id,
case NativeTheme::kColorId_MenuBackgroundColor:
return SK_ColorWHITE;
case NativeTheme::kColorId_DisabledMenuItemForegroundColor:
return kDisabledTextColor;
case NativeTheme::kColorId_MenuItemMinorTextColor: {
const SkColor bg = base_theme->GetSystemColor(
NativeTheme::kColorId_MenuBackgroundColor, color_scheme);
const SkColor fg = base_theme->GetSystemColor(
NativeTheme::kColorId_EnabledMenuItemForegroundColor, color_scheme);
return color_utils::BlendForMinContrast(kDisabledTextColor, bg, fg).color;
return color_utils::BlendForMinContrast(gfx::kGoogleGrey600, bg, fg)
.color;
}
case NativeTheme::kColorId_HighlightedMenuItemBackgroundColor:
return gfx::kGoogleGrey050;
Expand Down

0 comments on commit 9073e82

Please sign in to comment.