Commit f8ce6aa6 authored by Peter Kasting's avatar Peter Kasting Committed by Chromium LUCI CQ

Lower the contrast threshold icons must hit to avoid recoloring.

This prevents recoloring the favicon in the default (light) theme.  It
also seems more theoretically correct, since an icon is not text, and
we've generally been using distinct contrast thresholds for the two.

Bug: 1158748
Change-Id: I36448d69986e93e49693b5f02cced05e9646468f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2593517
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Charlene Yan <cyan@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: default avatarCharlene Yan <cyan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837303}
parent 7d1191c8
......@@ -457,7 +457,7 @@ gfx::ImageSkia TabIcon::ThemeImage(const gfx::ImageSkia& source) {
// Recolor the image if the original has low minimum contrast and recoloring
// will improve it.
return ((original_contrast < color_utils::kMinimumReadableContrastRatio) &&
return ((original_contrast < color_utils::kMinimumVisibleContrastRatio) &&
(alternate_contrast > original_contrast))
? gfx::ImageSkiaOperations::CreateColorMask(source,
alternate_color)
......
......@@ -34,6 +34,11 @@ struct BlendResult {
// This value is taken from w3c accessibility guidelines.
constexpr float kMinimumReadableContrastRatio = 4.5f;
// The minimum contrast between button glyphs, focus indicators, large text, or
// other "have to see it but perhaps don't have to read fine detail" cases and
// background.
constexpr float kMinimumVisibleContrastRatio = 3.0f;
// Determines the contrast ratio of two colors or two relative luminance values
// (as computed by RelativeLuminance()), calculated according to
// http://www.w3.org/TR/WCAG20/#contrast-ratiodef .
......
......@@ -111,11 +111,9 @@ SkColor FrameCaptionButton::GetButtonColor(SkColor background_color) {
: gfx::kGoogleGrey700;
const SkColor high_contrast_foreground =
color_utils::GetColorWithMaxContrast(background_color);
// Guarantee the caption buttons reach at least contrast ratio 3; this ratio
// matches that used for focus indicators, large text, and other "have to see
// it but perhaps don't have to read fine detail" cases.
return color_utils::BlendForMinContrast(default_foreground, background_color,
high_contrast_foreground, 3.0f)
return color_utils::BlendForMinContrast(
default_foreground, background_color, high_contrast_foreground,
color_utils::kMinimumVisibleContrastRatio)
.color;
}
......
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