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.
Hi,
I notice that contrast ratio is only related to the value (in preferred color space) of color pair (two contrast colors). Contrast ratio of the same color pair varies by color space since colors are differently encoded. I've tested it out on Pika of a recent stable build (52, 1.0.2) and a recent one from source (85c3546).
WCAG 2.1 recommends sRGB for color contrast ratio:
After the simple code tweak, contrast ratio will be independent of the color space and always comply with WCAG 2.1.
Color values are converted in sRGB for relative luminance. Extended range beyond [0, 1] is used so bright colors are unclamped for contrast ratio. The introduction of extended range might make negative luminance (Though I can't imagine how to trigger such bug), so luminance values are conservatively clamped to non-negative. The signature of
toRGBAComponents()
in extension ofNSColor
will changed without impact on other code.That's it. Hope it helps the development of Pika!