Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: d4b8d84d74905621878d557c02315a54e1c72f43
https://github.com/WebKit/WebKit/commit/d4b8d84d74905621878d557c02315a54e1c72f43
Author: Tim Horton <[email protected]>
Date: 2026-03-20 (Fri, 20 Mar 2026)
Changed paths:
M LayoutTests/platform/gtk/TestExpectations
M LayoutTests/platform/wpe/TestExpectations
A LayoutTests/printing/light-text-dark-background-economy-expected.html
A LayoutTests/printing/light-text-dark-background-economy.html
M Source/WebCore/rendering/TextPaintStyle.cpp
Log Message:
-----------
Printing light text on dark background with backgrounds disabled can result
in invisible text
https://bugs.webkit.org/show_bug.cgi?id=306884
rdar://170070133
Reviewed by Aditya Keerthi.
When printing with backgrounds disabled, we adjust text colors for legibility on
white paper. The heuristic in adjustColorForVisibilityOnBackground used a
luminance threshold of 0.5 to decide whether to darken or lighten the text.
For some colors, this resulted in illegible text (near-white on white).
Replace the luminance threshold heuristic with a contrast-ratio comparison:
compute both the darkened and lightened variants of the text color, and pick
whichever has higher contrast against the background.
Test: printing/light-text-dark-background-economy.html
* LayoutTests/printing/light-text-dark-background-economy-expected.html: Added.
* LayoutTests/printing/light-text-dark-background-economy.html: Added.
* Source/WebCore/rendering/TextPaintStyle.cpp:
(WebCore::adjustColorForVisibilityOnBackground):
Canonical link: https://commits.webkit.org/309604@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications