Commit a8b4adb6 authored by Ionel Popescu's avatar Ionel Popescu Committed by Chromium LUCI CQ

Update dark mode text selection colors for Android.

This CL updates the text selection colors for Android to:
- background: #99C8FF
- foreground: #3B3B3B

Bug: 1160107
Change-Id: I2836c040cb3a9ce497acc8a91db9379f7ac108ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2623652
Commit-Queue: Ionel Popescu <iopopesc@microsoft.com>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarYu Han <yuzhehan@chromium.org>
Reviewed-by: default avatarMason Freed <masonfreed@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843843}
parent 744e9971
......@@ -17,6 +17,7 @@
#include "content/public/test/test_utils.h"
#include "content/shell/browser/shell.h"
#include "ui/base/ui_base_features.h"
#include "ui/base/ui_base_switches.h"
#if defined(OS_ANDROID)
#include "base/android/build_info.h"
......@@ -38,7 +39,9 @@ namespace content {
class FormControlsBrowserTest : public ContentBrowserTest {
public:
FormControlsBrowserTest() {
feature_list_.InitWithFeatures({features::kFormControlsRefresh}, {});
feature_list_.InitWithFeatures(
{features::kFormControlsRefresh, features::kCSSColorSchemeUARendering},
{});
}
void SetUp() override {
......@@ -52,6 +55,9 @@ class FormControlsBrowserTest : public ContentBrowserTest {
// The --disable-lcd-text flag helps text render more similarly on
// different bots and platform.
command_line->AppendSwitch(switches::kDisableLCDText);
// This is required to allow dark mode to be used on some platforms.
command_line->AppendSwitch(switches::kForceDarkMode);
}
void RunTest(const std::string& screenshot_filename,
......@@ -61,6 +67,7 @@ class FormControlsBrowserTest : public ContentBrowserTest {
base::ScopedAllowBlockingForTesting allow_blocking;
ASSERT_TRUE(features::IsFormControlsRefreshEnabled());
ASSERT_TRUE(features::IsCSSColorSchemeUARenderingEnabled());
std::string platform_suffix;
#if defined(OS_MAC)
......@@ -90,9 +97,9 @@ class FormControlsBrowserTest : public ContentBrowserTest {
golden_filepath = golden_filepath_platform;
}
ASSERT_TRUE(NavigateToURL(
shell()->web_contents(),
GURL("data:text/html,<!DOCTYPE html><body>" + body_html + "</body>")));
ASSERT_TRUE(
NavigateToURL(shell()->web_contents(),
GURL("data:text/html,<!DOCTYPE html>" + body_html)));
#if defined(OS_MAC)
// This fuzzy pixel comparator handles several mac behaviors:
......@@ -158,6 +165,29 @@ IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, Radio) {
/* screenshot_height */ 40);
}
// TODO(iopopesc): Re-enable test when there is a resolution for
// android-bfcache-rel builder producing different results.
#if defined(OS_ANDROID)
#define MAYBE_DarkModeTextSelection DISABLED_DarkModeTextSelection
#else
#define MAYBE_DarkModeTextSelection DarkModeTextSelection
#endif
IN_PROC_BROWSER_TEST_F(FormControlsBrowserTest, MAYBE_DarkModeTextSelection) {
RunTest("form_controls_browsertest_dark_mode_text_selection",
"<meta name=\"color-scheme\" content=\"dark\">"
"<div id=\"target\">This is some basic text that we are going to "
"select.</div>"
"<script>"
" let container = document.getElementById('target');"
" container.focus();"
" let targetText = container.firstChild;"
" let selectionRange = window.getSelection();"
" selectionRange.setBaseAndExtent(targetText, 5, targetText, 35);"
"</script>",
/* screenshot_width */ 400,
/* screenshot_height */ 40);
}
// TODO(jarhar): Add tests for other elements from
// https://concrete-hardboard.glitch.me
......
......@@ -32,4 +32,20 @@ input[type="range" i]:-internal-has-datalist::-webkit-slider-container {
})CSS";
}
Color LayoutThemeAndroid::PlatformActiveSelectionBackgroundColor(
mojom::blink::ColorScheme color_scheme) const {
return color_scheme == mojom::blink::ColorScheme::kDark
? 0xFF99C8FF
: LayoutThemeMobile::PlatformActiveSelectionBackgroundColor(
color_scheme);
}
Color LayoutThemeAndroid::PlatformActiveSelectionForegroundColor(
mojom::blink::ColorScheme color_scheme) const {
return color_scheme == mojom::blink::ColorScheme::kDark
? 0xFF3B3B3B
: LayoutThemeMobile::PlatformActiveSelectionForegroundColor(
color_scheme);
}
} // namespace blink
......@@ -14,6 +14,10 @@ class LayoutThemeAndroid final : public LayoutThemeMobile {
static scoped_refptr<LayoutTheme> Create();
bool DelegatesMenuListRendering() const override { return true; }
String ExtraDefaultStyleSheet() override;
Color PlatformActiveSelectionBackgroundColor(
mojom::blink::ColorScheme color_scheme) const override;
Color PlatformActiveSelectionForegroundColor(
mojom::blink::ColorScheme color_scheme) const override;
private:
~LayoutThemeAndroid() override;
......
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