1
0
mirror of https://github.com/roytam1/UXP.git synced 2026-05-26 13:58:49 +00:00

Issue #2982 - clamp oklab/oklch to [0,1] before conversion to closer match spec

This commit is contained in:
Basilisk-Dev
2026-03-06 13:45:26 -05:00
committed by roytam1
parent 217f699ce7
commit cfe5b73e0c
2 changed files with 8 additions and 3 deletions
+6 -3
View File
@@ -181,9 +181,12 @@ LinearSRGBToEncoded(float aValue)
static nscolor
OKLabToSRGBColor(float aL, float aA, float aB, float aAlpha)
{
float lRoot = aL + 0.3963377774f * aA + 0.2158037573f * aB;
float mRoot = aL - 0.1055613458f * aA - 0.0638541728f * aB;
float sRoot = aL - 0.0894841775f * aA - 1.2914855480f * aB;
// Per CSS Color, the lightness component for Oklab/Oklch is clamped.
float lightness = mozilla::clamped(aL, 0.0f, 1.0f);
float lRoot = lightness + 0.3963377774f * aA + 0.2158037573f * aB;
float mRoot = lightness - 0.1055613458f * aA - 0.0638541728f * aB;
float sRoot = lightness - 0.0894841775f * aA - 1.2914855480f * aB;
float l = lRoot * lRoot * lRoot;
float m = mRoot * mRoot * mRoot;
@@ -401,8 +401,10 @@ var noframe_container = document.getElementById("content");
["hsl(0 0% 0% / 0.5)", "rgba(0, 0, 0, 0.5)"],
["oklab(0 0 0 / 1)", "rgb(0, 0, 0)"],
["oklab(0 0 0 / 0.5)", "rgba(0, 0, 0, 0.5)"],
["oklab(150% 0.5 0.2 / 1)", "rgb(255, 0, 0)"],
["oklch(0 0 0 / 1)", "rgb(0, 0, 0)"],
["oklch(0 0 0 / 0.5)", "rgba(0, 0, 0, 0.5)"],
["oklch(150% 0.5 50 / 1)", "rgb(255, 0, 0)"],
];
var p = document.createElement("p");