[webkit-changes] [WebKit/WebKit] 5413aa: Default link colors lack sufficient contrast in th...

Aditya Keerthi noreply at github.com
Sun Sep 10 18:22:13 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 5413aa7d4157f6ff5865f169742255366e984c60
      https://github.com/WebKit/WebKit/commit/5413aa7d4157f6ff5865f169742255366e984c60
  Author: Aditya Keerthi <akeerthi at apple.com>
  Date:   2023-09-10 (Sun, 10 Sep 2023)

  Changed paths:
    A LayoutTests/css-dark-mode/link-colors-expected.html
    A LayoutTests/css-dark-mode/link-colors.html
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/dom/Document.h
    M Source/WebCore/rendering/RenderTheme.cpp
    M Source/WebCore/style/ColorFromPrimitiveValue.cpp

  Log Message:
  -----------
  Default link colors lack sufficient contrast in the dark color scheme
https://bugs.webkit.org/show_bug.cgi?id=209851
rdar://61149466

Reviewed by Tim Nguyen and Megan Gardner.

Currently, link colors are the same in both the light and dark color schemes.
This results in a lack of contrast against dark backgrounds.

To fix, dark-mode specific link colors are defined. The definitions match the
values used by Chromium, and are not taken from the system link color. This
approach was chosen as the default link color in the light color scheme is
defined by https://html.spec.whatwg.org/multipage/rendering.html#phrasing-content-3,
and also does not come from the system.

* LayoutTests/css-dark-mode/link-colors-expected.html: Added.
* LayoutTests/css-dark-mode/link-colors.html: Added.
* Source/WebCore/dom/Document.cpp:

Link colors can be adjusted by HTML using the `link`, `alink`, and `vlink`
attributes. Adjust logic to ensure that a static link color is only used if the
corresponding attribute is specified. Without these changes, the dark mode
color would never be used, as the light mode color is stored as the default.

(WebCore::Document::linkColor const):
(WebCore::Document::visitedLinkColor const):
(WebCore::Document::activeLinkColor const):
(WebCore::Document::resetLinkColor):
(WebCore::Document::resetVisitedLinkColor):
(WebCore::Document::resetActiveLinkColor):
* Source/WebCore/dom/Document.h:
(WebCore::Document::linkColor const): Deleted.
(WebCore::Document::visitedLinkColor const): Deleted.
(WebCore::Document::activeLinkColor const): Deleted.
* Source/WebCore/rendering/RenderTheme.cpp:
(WebCore::RenderTheme::systemColor const):

Add definitions for colors under the dark color scheme.

* Source/WebCore/style/ColorFromPrimitiveValue.cpp:
(WebCore::Style::colorFromPrimitiveValue):

Pass in `StyleColorOptions` when determining the link color, so that it can be
resolved against the used color scheme.

Canonical link: https://commits.webkit.org/267847@main




More information about the webkit-changes mailing list