Issue #2982 - Follow-up: allow color-mix to work with oklab and oklch

Tag #2489 and #3003
This commit is contained in:
Basilisk-Dev 2026-05-08 14:29:43 -04:00 • committed by EAZYBLACK
commit 7e0818c9ec
7 changed files with 460 additions and 59 deletions

View file

@ -525,8 +525,10 @@ enum nsCSSUnit {
// allowed.
eCSSUnit_HSLColor = 89, // (nsCSSValueFloatColor*)
eCSSUnit_HSLAColor = 90, // (nsCSSValueFloatColor*)
eCSSUnit_ComplexColor = 91, // (ComplexColorValue*)
eCSSUnit_ColorMix = 92, // (ColorMixValue*)
eCSSUnit_OklabColor = 91, // (nsCSSValueFloatColor*)
eCSSUnit_OklchColor = 92, // (nsCSSValueFloatColor*)
eCSSUnit_ComplexColor = 93, // (ComplexColorValue*)
eCSSUnit_ColorMix = 94, // (ColorMixValue*)
eCSSUnit_Percent = 100, // (float) 1.0 == 100%) value is percentage of something
eCSSUnit_Number = 101, // (float) value is numeric (usually multiplier, different behavior than percent)
@ -738,6 +740,8 @@ public:
// eCSSUnit_PercentageRGBAColor -- rgba(%,%,%,float)
// eCSSUnit_HSLColor -- hsl(float,%,%)
// eCSSUnit_HSLAColor -- hsla(float,%,%,float)
// eCSSUnit_OklabColor -- oklab(float,float,float,float)
// eCSSUnit_OklchColor -- oklch(float,float,float,float)
//
// - IsNumericColorUnit returns true for any of the above units.
//
@ -750,7 +754,7 @@ public:
{ return eCSSUnit_RGBColor <= aUnit && aUnit <= eCSSUnit_ShortHexColorAlpha; }
static bool IsFloatColorUnit(nsCSSUnit aUnit)
{ return eCSSUnit_PercentageRGBColor <= aUnit &&
aUnit <= eCSSUnit_HSLAColor; }
aUnit <= eCSSUnit_OklchColor; }
static bool IsNumericColorUnit(nsCSSUnit aUnit)
{ return IsIntegerColorUnit(aUnit) || IsFloatColorUnit(aUnit); }
@ -1933,6 +1937,9 @@ private:
// [0, 1] for hue represents
// [0deg, 360deg].
//
// OklabColor stores L in mComponent1, a in mComponent2, b in mComponent3.
// OklchColor stores L in mComponent1, C in mComponent2, H in mComponent3.
//
// [-float::max(), float::max()] for PercentageRGBColor, PercentageRGBAColor.
// 1.0 means 100%.
float mComponent1;
@ -1999,7 +2006,9 @@ namespace css {
enum class ColorMixColorSpace {
sRGB,
HSL
HSL,
Oklab,
Oklch
};
struct ColorMixValue final