From b42cca5fa5884e680ec9099efb6bf81a71719e0b Mon Sep 17 00:00:00 2001 From: erixreyes Date: Sat, 19 Jul 2025 07:49:42 +0800 Subject: [PATCH] Issue #2489: Add color-mix serialization support --- layout/style/nsCSSValue.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/layout/style/nsCSSValue.cpp b/layout/style/nsCSSValue.cpp index 9503e09f57..1dc7e71792 100644 --- a/layout/style/nsCSSValue.cpp +++ b/layout/style/nsCSSValue.cpp @@ -1731,6 +1731,28 @@ nsCSSValue::AppendToString(nsCSSPropertyID aProperty, nsAString& aResult, } serializable.AppendToString(aProperty, aResult, aSerialization); } + else if (eCSSUnit_ColorMix == unit) { + const ColorMixValue* colorMix = GetColorMixValue(); + aResult.AppendLiteral("color-mix(in "); + + // append color space + switch (colorMix->mColorSpace) { + case eColorMixColorSpace_sRGB: + aResult.AppendLiteral("srgb"); + break; + case eColorMixColorSpace_HSL: + aResult.AppendLiteral("hsl"); + break; + } + + // append color1 and color2 + aResult.AppendLiteral(", "); + colorMix->mColor1.AppendToString(aProperty, aResult, aSerialization); + aResult.AppendLiteral(", "); + colorMix->mColor2.AppendToString(aProperty, aResult, aSerialization); + + aResult.Append(')'); + } else if (eCSSUnit_URL == unit || eCSSUnit_Image == unit) { aResult.AppendLiteral("url("); nsStyleUtil::AppendEscapedCSSString(