Commit 5139bf71 authored by Yu Han's avatar Yu Han Committed by Commit Bot

[Form Controls Refresh] Fixes mac text selection color for dark mode.

Prior to this CL, the text selection color on Mac/dark mode is too dark.
It doesn't provide enough of a contrast between the selected text
and its background highlight color. The reason is that Chrome blends
the Mac specific highlight color with white, Color::BlendWithWhite().
It adds a .6 alpha channel which results the color being too dark.

The fix is to mimic Safari's logic[1] and apply a greater alpha value,
making the alpha channel more transparent. Thus, the selection
background color is lighter.

[1] https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/rendering/RenderThemeMac.mm#L385

Bug: 1146379
Change-Id: Ib4d54f0b3dbe5c32038e10af65c644db2f4e8dc7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2525368
Commit-Queue: Yu Han <yuzhehan@chromium.org>
Reviewed-by: default avatarMason Freed <masonfreed@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825488}
parent 72b61e44
......@@ -306,7 +306,14 @@ String LayoutTheme::ExtraFullscreenStyleSheet() {
Color LayoutTheme::ActiveSelectionBackgroundColor(
mojom::blink::ColorScheme color_scheme) const {
return PlatformActiveSelectionBackgroundColor(color_scheme).BlendWithWhite();
Color color = PlatformActiveSelectionBackgroundColor(color_scheme);
#if defined(OS_MAC)
// BlendWithWhite() darkens Mac system colors too much.
// Apply .8 (204/255) alpha instead, same as Safari.
if (color_scheme == mojom::blink::ColorScheme::kDark)
return Color(color.Red(), color.Green(), color.Blue(), 204);
#endif
return color.BlendWithWhite();
}
Color LayoutTheme::InactiveSelectionBackgroundColor(
......
......@@ -6054,7 +6054,6 @@ crbug.com/1113127 fast/canvas/downsample-quality.html [ Pass Failure Crash ]
crbug.com/1113791 [ Win ] media/video-zoom.html [ Pass Failure ]
# Virtual dark mode tests currently fails.
crbug.com/1111937 virtual/dark-color-scheme/fast/forms/color-scheme/text-selection-outside-control.html [ Failure ]
crbug.com/1111932 virtual/dark-color-scheme/fast/forms/color-scheme/suggestion-picker/date-suggestion-picker-appearance.html [ Failure ]
crbug.com/1111932 virtual/dark-color-scheme/fast/forms/color-scheme/suggestion-picker/datetimelocal-suggestion-picker-appearance.html [ Failure ]
crbug.com/1111932 virtual/dark-color-scheme/fast/forms/color-scheme/suggestion-picker/month-suggestion-picker-appearance.html [ Failure ]
......
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