Skip to content

Commit b538c70

Browse files
committed
LinkText and VisitedText system colors doesn't obey color scheme
https://bugs.webkit.org/show_bug.cgi?id=272299 Reviewed by Tim Nguyen. Change LinkText and VisitedText CSS system colors to use a different value when the used color scheme is dark. The chosen colors are the same as `-webkit-link` and are what is expected by WPT tests. * LayoutTests/imported/w3c/web-platform-tests/css/css-color/system-color-consistency-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-color/system-color-support-expected.txt: * LayoutTests/platform/gtk/imported/w3c/web-platform-tests/css/css-color/system-color-support-expected.txt: * LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-color/system-color-support-expected.txt: * LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-color/system-color-consistency-expected.txt: * Source/WebCore/rendering/RenderTheme.cpp: (WebCore::RenderTheme::systemColor const): * Source/WebCore/rendering/mac/RenderThemeMac.mm: (WebCore::RenderThemeMac::systemColor const): Canonical link: https://commits.webkit.org/277259@main
1 parent 1cece1c commit b538c70

7 files changed

Lines changed: 15 additions & 14 deletions

File tree

‎LayoutTests/imported/w3c/web-platform-tests/css/css-color/system-color-consistency-expected.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ FAIL Property color value 'Field' resolves to the same color as the background-c
5454
FAIL Property color value 'FieldText' resolves to the same color as text on a text area (dark) assert_equals: expected "rgb(255, 255, 255)" but got "rgba(255, 255, 255, 0.847)"
5555
PASS Property color value 'Mark' has the same color as the background-color of a mark element (dark)
5656
PASS Property color value 'MarkText' has the same color as the color of a mark element (dark)
57-
FAIL Property color value 'LinkText' has the same color as the color of an anchor element (dark) assert_equals: expected "rgb(158, 158, 255)" but got "rgb(0, 0, 238)"
57+
PASS Property color value 'LinkText' has the same color as the color of an anchor element (dark)
5858

‎LayoutTests/imported/w3c/web-platform-tests/css/css-color/system-color-support-expected.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
PASS System color Canvas works
33
PASS System color CanvasText works
4-
FAIL System color LinkText works assert_not_equals: LinkText should react to color-scheme got disallowed value "rgb(0, 0, 238)"
5-
FAIL System color VisitedText works assert_not_equals: VisitedText should react to color-scheme got disallowed value "rgb(85, 26, 139)"
4+
PASS System color LinkText works
5+
PASS System color VisitedText works
66
PASS System color ActiveText works
77
FAIL System color ButtonFace works assert_not_equals: ButtonFace should react to color-scheme got disallowed value "rgb(192, 192, 192)"
88
PASS System color ButtonText works

‎LayoutTests/platform/gtk/imported/w3c/web-platform-tests/css/css-color/system-color-support-expected.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
PASS System color Canvas works
33
PASS System color CanvasText works
4-
FAIL System color LinkText works assert_not_equals: LinkText should react to color-scheme got disallowed value "rgb(0, 0, 238)"
5-
FAIL System color VisitedText works assert_not_equals: VisitedText should react to color-scheme got disallowed value "rgb(85, 26, 139)"
4+
PASS System color LinkText works
5+
PASS System color VisitedText works
66
PASS System color ActiveText works
77
FAIL System color ButtonFace works assert_not_equals: ButtonFace should react to color-scheme got disallowed value "rgb(192, 192, 192)"
88
PASS System color ButtonText works

‎LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-color/system-color-support-expected.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
PASS System color Canvas works
33
PASS System color CanvasText works
4-
FAIL System color LinkText works assert_not_equals: LinkText should react to color-scheme got disallowed value "rgb(0, 0, 238)"
5-
FAIL System color VisitedText works assert_not_equals: VisitedText should react to color-scheme got disallowed value "rgb(85, 26, 139)"
4+
PASS System color LinkText works
5+
PASS System color VisitedText works
66
PASS System color ActiveText works
77
FAIL System color ButtonFace works assert_not_equals: ButtonFace should react to color-scheme got disallowed value "rgb(192, 192, 192)"
88
FAIL System color ButtonText works assert_not_equals: ButtonText should react to color-scheme got disallowed value "rgb(0, 0, 0)"

‎LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/css-color/system-color-consistency-expected.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ FAIL Property color value 'Field' resolves to the same color as the background-c
5454
FAIL Property color value 'FieldText' resolves to the same color as text on a text area (dark) assert_equals: expected "rgb(255, 255, 255)" but got "rgba(255, 255, 255, 0.847)"
5555
PASS Property color value 'Mark' has the same color as the background-color of a mark element (dark)
5656
PASS Property color value 'MarkText' has the same color as the color of a mark element (dark)
57-
FAIL Property color value 'LinkText' has the same color as the color of an anchor element (dark) assert_equals: expected "rgb(158, 158, 255)" but got "rgb(0, 0, 238)"
57+
PASS Property color value 'LinkText' has the same color as the color of an anchor element (dark)
5858

‎Source/WebCore/rendering/RenderTheme.cpp‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,12 +1559,12 @@ Color RenderTheme::systemColor(CSSValueID cssValueId, OptionSet<StyleColorOption
15591559
// https://drafts.csswg.org/css-color-4/#valdef-system-color-linktext
15601560
// Text in non-active, non-visited links. For light backgrounds, traditionally blue.
15611561
case CSSValueLinktext:
1562-
return SRGBA<uint8_t> { 0, 0, 238 };
1562+
return useDarkAppearance ? SRGBA<uint8_t> { 158, 158, 255 } : SRGBA<uint8_t> { 0, 0, 238 };
15631563

15641564
// https://drafts.csswg.org/css-color-4/#valdef-system-color-visitedtext
15651565
// Text in visited links. For light backgrounds, traditionally purple.
15661566
case CSSValueVisitedtext:
1567-
return SRGBA<uint8_t> { 85, 26, 139 };
1567+
return useDarkAppearance ? SRGBA<uint8_t> { 208, 173, 240 } : SRGBA<uint8_t> { 85, 26, 139 };
15681568

15691569
// https://drafts.csswg.org/css-color-4/#valdef-system-color-activetext
15701570
// Text in active links. For light backgrounds, traditionally red.
@@ -1652,9 +1652,9 @@ Color RenderTheme::systemColor(CSSValueID cssValueId, OptionSet<StyleColorOption
16521652

16531653
// Non-standard addition.
16541654
case CSSValueWebkitLink: {
1655-
if (useDarkAppearance)
1656-
return forVisitedLink ? SRGBA<uint8_t> { 208, 173, 240 } : SRGBA<uint8_t> { 158, 158, 255 };
1657-
return forVisitedLink ? SRGBA<uint8_t> { 85, 26, 139 } : SRGBA<uint8_t> { 0, 0, 238 };
1655+
if (forVisitedLink)
1656+
return systemColor(CSSValueVisitedtext, options);
1657+
return systemColor(CSSValueLinktext, options);
16581658
}
16591659

16601660
// Deprecated system-colors:

‎Source/WebCore/rendering/mac/RenderThemeMac.mm‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,8 @@ static Color activeButtonTextColor()
471471
return RenderTheme::systemColor(cssValueID, options);
472472
}
473473

474-
ASSERT(!forVisitedLink);
474+
// -webkit-link requests Visitedtext when the link is visited, let it fetch Visitedtext from the cache if possible.
475+
ASSERT(!forVisitedLink || cssValueID == CSSValueVisitedtext);
475476

476477
auto it = cache.systemStyleColors.find(cssValueID);
477478
if (it != cache.systemStyleColors.end())

0 commit comments

Comments
 (0)