mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 20:07:30 +09:00
Issue #2489: Add color-mix computation support
This commit is contained in:
parent
b42cca5fa5
commit
58d7206259
1 changed files with 15 additions and 0 deletions
|
|
@ -1137,6 +1137,21 @@ static bool SetColor(const nsCSSValue& aValue, const nscolor aParentColor,
|
|||
aResult = aParentColor;
|
||||
result = true;
|
||||
aConditions.SetUncacheable();
|
||||
} else if (eCSSUnit_ColorMix == unit) {
|
||||
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)) {
|
||||
// simple linear interpolation (50/50 sRGB mix)
|
||||
uint8_t r = (NS_GET_R(color1) + NS_GET_R(color2)) / 2;
|
||||
uint8_t g = (NS_GET_G(color1) + NS_GET_G(color2)) / 2;
|
||||
uint8_t b = (NS_GET_B(color1) + NS_GET_B(color2)) / 2;
|
||||
uint8_t a = (NS_GET_A(color1) + NS_GET_A(color2)) / 2;
|
||||
aResult = NS_RGBA(r, g, b, a);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
} else if (eCSSUnit_Enumerated == unit &&
|
||||
aValue.GetIntValue() == NS_STYLE_COLOR_INHERIT_FROM_BODY) {
|
||||
NS_ASSERTION(aPresContext->CompatibilityMode() == eCompatibility_NavQuirks,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue