-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Scroll to text fragment highlight style can create unreadable text, especially in dark mode #52779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
webkit-commit-queue
merged 1 commit into
WebKit:main
from
hortont424:eng/Scroll-to-text-fragment-highlight-style-can-create-unreadable-text-especially-in-dark-mode
Oct 22, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
|
EWS run on previous version of this PR (hash ade6616)
|
aprotyas
approved these changes
Oct 22, 2025
ade6616 to
9166da1
Compare
|
EWS run on current version of this PR (hash 9166da1) |
…specially 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
9166da1 to
32caf7b
Compare
|
Committed 301930@main (32caf7b): https://commits.webkit.org/301930@main Reviewed commits have been landed. Closing PR #52779 and removing active labels. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
WebKit Misc.
For miscellaneous bugs in the WebKit framework (and not JavaScriptCore or WebCore).
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
32caf7b
9166da1
🛠 win🧪 win-tests🧪 ios-wk2-wpt🧪 mac-AS-debug-wk2🧪 mac-intel-wk2🛠 watch