Commit ee448d5f authored by Sam Sebree's avatar Sam Sebree Committed by Commit Bot

[Controls Refresh] Pages with `color-scheme: dark` have too low link color contrast

This change updates the styling for the link controls in dark mode.

Bug: 1107287
Change-Id: I62b7a05320c9a6e2597614411eee627bc72e4813
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2437822
Commit-Queue: Sam Sebree <sasebree@microsoft.com>
Reviewed-by: default avatarYu Han <yuzhehan@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813945}
parent 0d7bb6db
...@@ -38,22 +38,69 @@ ...@@ -38,22 +38,69 @@
namespace blink { namespace blink {
constexpr Color kDefaultLinkColorLight = Color::CreateUnchecked(0, 0, 238);
constexpr Color kDefaultLinkColorDark = Color::CreateUnchecked(158, 158, 255);
constexpr Color kDefaultVisitedLinkColorLight =
Color::CreateUnchecked(85, 26, 139);
constexpr Color kDefaultVisitedLinkColorDark =
Color::CreateUnchecked(208, 173, 240);
constexpr Color kDefaultActiveLinkColorLight =
Color::CreateUnchecked(255, 0, 0);
constexpr Color kDefaultActiveLinkColorDark =
Color::CreateUnchecked(255, 158, 158);
TextLinkColors::TextLinkColors() : text_color_(Color::kBlack) { TextLinkColors::TextLinkColors() : text_color_(Color::kBlack) {
ResetLinkColor(); ResetLinkColor();
ResetVisitedLinkColor(); ResetVisitedLinkColor();
ResetActiveLinkColor(); ResetActiveLinkColor();
} }
void TextLinkColors::ResetLinkColor() { void TextLinkColors::SetTextColor(const Color& color) {
link_color_ = Color(0, 0, 238); text_color_ = color;
has_custom_text_color_ = true;
}
Color TextLinkColors::TextColor(ColorScheme color_scheme) const {
return has_custom_text_color_
? text_color_
: color_scheme == ColorScheme::kLight ? Color::kBlack
: Color::kWhite;
}
void TextLinkColors::SetLinkColor(const Color& color) {
link_color_ = color;
has_custom_link_color_ = true;
}
const Color& TextLinkColors::LinkColor(ColorScheme color_scheme) const {
return has_custom_link_color_
? link_color_
: color_scheme == ColorScheme::kLight ? kDefaultLinkColorLight
: kDefaultLinkColorDark;
}
void TextLinkColors::SetVisitedLinkColor(const Color& color) {
visited_link_color_ = color;
has_custom_visited_link_color_ = true;
}
const Color& TextLinkColors::VisitedLinkColor(ColorScheme color_scheme) const {
return has_custom_visited_link_color_ ? visited_link_color_
: color_scheme == ColorScheme::kLight
? kDefaultVisitedLinkColorLight
: kDefaultVisitedLinkColorDark;
} }
void TextLinkColors::ResetVisitedLinkColor() { void TextLinkColors::SetActiveLinkColor(const Color& color) {
visited_link_color_ = Color(85, 26, 139); active_link_color_ = color;
has_custom_active_link_color_ = true;
} }
void TextLinkColors::ResetActiveLinkColor() { const Color& TextLinkColors::ActiveLinkColor(ColorScheme color_scheme) const {
active_link_color_ = Color(255, 0, 0); return has_custom_active_link_color_ ? active_link_color_
: color_scheme == ColorScheme::kLight
? kDefaultActiveLinkColorLight
: kDefaultActiveLinkColorDark;
} }
Color TextLinkColors::ColorFromCSSValue(const CSSValue& value, Color TextLinkColors::ColorFromCSSValue(const CSSValue& value,
...@@ -76,11 +123,12 @@ Color TextLinkColors::ColorFromCSSValue(const CSSValue& value, ...@@ -76,11 +123,12 @@ Color TextLinkColors::ColorFromCSSValue(const CSSValue& value,
NOTREACHED(); NOTREACHED();
return Color(); return Color();
case CSSValueID::kInternalQuirkInherit: case CSSValueID::kInternalQuirkInherit:
return TextColor(); return TextColor(color_scheme);
case CSSValueID::kWebkitLink: case CSSValueID::kWebkitLink:
return for_visited_link ? VisitedLinkColor() : LinkColor(); return for_visited_link ? VisitedLinkColor(color_scheme)
: LinkColor(color_scheme);
case CSSValueID::kWebkitActivelink: case CSSValueID::kWebkitActivelink:
return ActiveLinkColor(); return ActiveLinkColor(color_scheme);
case CSSValueID::kWebkitFocusRingColor: case CSSValueID::kWebkitFocusRingColor:
return LayoutTheme::GetTheme().FocusRingColor(); return LayoutTheme::GetTheme().FocusRingColor();
case CSSValueID::kCurrentcolor: case CSSValueID::kCurrentcolor:
......
...@@ -46,18 +46,20 @@ class TextLinkColors { ...@@ -46,18 +46,20 @@ class TextLinkColors {
TextLinkColors(const TextLinkColors&) = delete; TextLinkColors(const TextLinkColors&) = delete;
TextLinkColors& operator=(const TextLinkColors&) = delete; TextLinkColors& operator=(const TextLinkColors&) = delete;
void SetTextColor(const Color& color) { text_color_ = color; } void SetTextColor(const Color& color);
Color TextColor() const { return text_color_; } Color TextColor(ColorScheme color_scheme = ColorScheme::kLight) const;
const Color& LinkColor() const { return link_color_; } const Color& LinkColor(ColorScheme color_scheme = ColorScheme::kLight) const;
const Color& VisitedLinkColor() const { return visited_link_color_; } const Color& VisitedLinkColor(
const Color& ActiveLinkColor() const { return active_link_color_; } ColorScheme color_scheme = ColorScheme::kLight) const;
void SetLinkColor(const Color& color) { link_color_ = color; } const Color& ActiveLinkColor(
void SetVisitedLinkColor(const Color& color) { visited_link_color_ = color; } ColorScheme color_scheme = ColorScheme::kLight) const;
void SetActiveLinkColor(const Color& color) { active_link_color_ = color; } void SetLinkColor(const Color& color);
void ResetLinkColor(); void SetVisitedLinkColor(const Color& color);
void ResetVisitedLinkColor(); void SetActiveLinkColor(const Color& color);
void ResetActiveLinkColor(); void ResetLinkColor() { has_custom_link_color_ = false; }
void ResetVisitedLinkColor() { has_custom_visited_link_color_ = false; }
void ResetActiveLinkColor() { has_custom_active_link_color_ = false; }
Color ColorFromCSSValue(const CSSValue&, Color ColorFromCSSValue(const CSSValue&,
Color current_color, Color current_color,
ColorScheme color_scheme, ColorScheme color_scheme,
...@@ -68,6 +70,11 @@ class TextLinkColors { ...@@ -68,6 +70,11 @@ class TextLinkColors {
Color link_color_; Color link_color_;
Color visited_link_color_; Color visited_link_color_;
Color active_link_color_; Color active_link_color_;
bool has_custom_text_color_{false};
bool has_custom_link_color_{false};
bool has_custom_visited_link_color_{false};
bool has_custom_active_link_color_{false};
}; };
} // namespace blink } // namespace blink
......
<!DOCTYPE html>
<head>
<meta name="color-scheme" content="light dark">
</head>
<body>
<ul>
<li><a href="#" id="website1">Website</a></li>
<li><a href="#" id="website2">Website - Active</a></li>
</ul>
</body>
<script>
var website2 = document.getElementById("website2");
var mouseX = website2.offsetLeft;
var mouseY = website2.offsetTop;
eventSender.mouseMoveTo(mouseX, mouseY);
eventSender.mouseDown();
</script>
\ No newline at end of file
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