Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 32caf7b3a6b7d33bf91842653832615081325b90
https://github.com/WebKit/WebKit/commit/32caf7b3a6b7d33bf91842653832615081325b90
Author: Tim Horton <[email protected]>
Date: 2025-10-21 (Tue, 21 Oct 2025)
Changed paths:
A
LayoutTests/http/tests/scroll-to-text-fragment/highlighted-text-contrast-expected.html
A
LayoutTests/http/tests/scroll-to-text-fragment/highlighted-text-contrast-targettext-expected-mismatch.html
A
LayoutTests/http/tests/scroll-to-text-fragment/highlighted-text-contrast-targettext.html
A
LayoutTests/http/tests/scroll-to-text-fragment/highlighted-text-contrast.html
M Source/WebCore/rendering/RenderReplaced.cpp
M Source/WebCore/rendering/RenderTheme.cpp
M Source/WebCore/rendering/RenderTheme.h
M Source/WebCore/rendering/StyledMarkedText.cpp
M Source/WebCore/rendering/ios/RenderThemeIOS.h
M Source/WebCore/rendering/ios/RenderThemeIOS.mm
M Source/WebCore/rendering/mac/RenderThemeMac.h
M Source/WebCore/rendering/mac/RenderThemeMac.mm
Log Message:
-----------
Scroll to text fragment highlight style can create unreadable text,
especially in dark mode
https://bugs.webkit.org/show_bug.cgi?id=272583
rdar://126539910
Reviewed by Abrar Rahman Protyasha.
Scroll-to-Text-Fragment highlights (and App Highlights) dramatically change
the surrounding color of the highlighted text. In many cases, this is fine, but
on dark pages with light or mid-tone text, the default highlight background
color (yellow) makes it hard to read the text.
Align ourselves with Chrome's behavior: pick a contrasting color, but only
if using the default highlight color; if the author uses ::target-text to style
the background, we leave it alone, assuming they knew what they were doing.
Test: http/tests/scroll-to-text-fragment/highlighted-text-contrast.html,
http/tests/scroll-to-text-fragment/highlighted-text-contrast-targettext.html
*
LayoutTests/http/tests/scroll-to-text-fragment/highlighted-text-contrast-expected.html:
Added.
*
LayoutTests/http/tests/scroll-to-text-fragment/highlighted-text-contrast.html:
Added.
Add a test that ensures that we contrastify highlighted text colors.
*
LayoutTests/http/tests/scroll-to-text-fragment/highlighted-text-contrast-targettext-expected-mismatch.html:
Added.
*
LayoutTests/http/tests/scroll-to-text-fragment/highlighted-text-contrast-targettext.html:
Added.
Add a test that ensures that we do NOT contrastify text colors when the author
overrides the default style.
* Source/WebCore/rendering/RenderReplaced.cpp:
(WebCore::RenderReplaced::calculateHighlightColor const):
* Source/WebCore/rendering/RenderTheme.cpp:
(WebCore::RenderTheme::annotationHighlightBackgroundColor const):
(WebCore::RenderTheme::platformAnnotationHighlightBackgroundColor const):
Rename annotationHighlightColor to annotationHighlightBackgroundColor, to allow
space for our "Foreground" variant.
(WebCore::RenderTheme::annotationHighlightForegroundColor const):
Add annotationHighlightForegroundColor, which is computed by using the CSS
contrast-color() algorithm on the background color.
(WebCore::RenderTheme::annotationHighlightColor const): Deleted.
(WebCore::RenderTheme::platformAnnotationHighlightColor const): Deleted.
* Source/WebCore/rendering/RenderTheme.h:
* Source/WebCore/rendering/StyledMarkedText.cpp:
(WebCore::resolveStyleForMarkedText):
Adopt annotationHighlightForegroundColor for STTF and app highlights, only if
::target-text is not used.
Canonical link: https://commits.webkit.org/301930@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications