fix fatal recursion bug

This commit is contained in:
EAZYBLACK 2026-09-24 20:42:47 +03:00
commit e602080115

View file

@ -1236,8 +1236,20 @@ static bool SetColor(const nsCSSValue& aValue, const nscolor aParentColor,
const mozilla::css::ColorMixValue* colorMix = aValue.GetColorMixValue();
if (colorMix) {
nscolor color1, color2;
if (SetColor(colorMix->mColor1, aParentColor, aPresContext, aContext, color1, aConditions) &&
SetColor(colorMix->mColor2, aParentColor, aPresContext, aContext, color2, aConditions)) {
// XXX: Avoid fatal recursion when either color resolves to NS_COLOR_CURRENTCOLOR.
if (colorMix->mColor1.GetUnit() == eCSSUnit_EnumColor &&
colorMix->mColor1.GetIntValue() == NS_COLOR_CURRENTCOLOR) {
color1 = aParentColor;
} else {
SetColor(colorMix->mColor1, aParentColor, aPresContext, aContext, color1, aConditions);
}
if (colorMix->mColor2.GetUnit() == eCSSUnit_EnumColor &&
colorMix->mColor2.GetIntValue() == NS_COLOR_CURRENTCOLOR) {
color2 = aParentColor;
} else {
SetColor(colorMix->mColor2, aParentColor, aPresContext, aContext, color2, aConditions);
}
if (color1 && color2) {
// interpolate each RGBA component with proper percentage handling
float w1 = colorMix->mWeight1;