Bug 1892937 - Use a component parser that includes color-mix for origin colors r=layout-reviewers,emilio

Differential Revision: https://phabricator.services.mozilla.com/D208344
This commit is contained in:
Tiaan Louw 2024-04-29 14:44:01 +00:00
parent cdcc48b45f
commit 2ab102955e
3 changed files with 4 additions and 91 deletions

View File

@ -12,7 +12,7 @@ use super::{
AbsoluteColor, ColorFlags, ColorSpace, AbsoluteColor, ColorFlags, ColorSpace,
}; };
use crate::{ use crate::{
parser::ParserContext, parser::{Parse, ParserContext},
values::{ values::{
generics::calc::CalcUnits, generics::calc::CalcUnits,
specified::{ specified::{
@ -173,15 +173,15 @@ fn parse_origin_color<'i, 't>(
let location = arguments.current_source_location(); let location = arguments.current_source_location();
// We still fail if we can't parse the origin color. // We still fail if we can't parse the origin color.
let origin_color = parse_color_with(context, arguments)?; let origin_color = SpecifiedColor::parse(context, arguments)?;
// Right now we only handle absolute colors. // Right now we only handle absolute colors.
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1890972 // See https://bugzilla.mozilla.org/show_bug.cgi?id=1890972
let SpecifiedColor::Absolute(absolute) = origin_color else { let Some(computed) = origin_color.to_computed_color(None) else {
return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError)); return Err(location.new_custom_error(StyleParseErrorKind::UnspecifiedError));
}; };
Ok(Some(absolute.color)) Ok(Some(computed.resolve_to_absolute(&AbsoluteColor::BLACK)))
} }
#[inline] #[inline]

View File

@ -344,60 +344,18 @@
[Property color value 'hwb(from hwb(20 30 40 / 0.8) calc(h + 1) calc(w + 1) calc(b + 1) / calc(alpha + 0.01))'] [Property color value 'hwb(from hwb(20 30 40 / 0.8) calc(h + 1) calc(w + 1) calc(b + 1) / calc(alpha + 0.01))']
expected: FAIL expected: FAIL
[Property color value 'rgb(from color-mix(in srgb, red, red) r g b / alpha)']
expected: FAIL
[Property color value 'hsl(from color-mix(in srgb, red, red) h s l / alpha)'] [Property color value 'hsl(from color-mix(in srgb, red, red) h s l / alpha)']
expected: FAIL expected: FAIL
[Property color value 'hwb(from color-mix(in srgb, red, red) h w b / alpha)'] [Property color value 'hwb(from color-mix(in srgb, red, red) h w b / alpha)']
expected: FAIL expected: FAIL
[Property color value 'lab(from color-mix(in lab, lab(25 20 50), lab(25 20 50)) l a b / alpha)']
expected: FAIL
[Property color value 'oklab(from color-mix(in oklab, oklab(0.25 0.2 0.5), oklab(0.25 0.2 0.5)) l a b / alpha)']
expected: FAIL
[Property color value 'lch(from color-mix(in lch, lch(70 45 30), lch(70 45 30)) l c h / alpha)']
expected: FAIL
[Property color value 'oklch(from color-mix(in oklch, oklch(0.7 0.45 30), oklch(0.7 0.45 30)) l c h / alpha)']
expected: FAIL
[Property color value 'color(from color-mix(in xyz, color(srgb 0.7 0.5 0.3), color(srgb 0.7 0.5 0.3)) srgb r g b / alpha)']
expected: FAIL
[Property color value 'color(from color-mix(in xyz, color(srgb-linear 0.7 0.5 0.3), color(srgb-linear 0.7 0.5 0.3)) srgb-linear r g b / alpha)']
expected: FAIL
[Property color value 'color(from color-mix(in xyz, color(a98-rgb 0.7 0.5 0.3), color(a98-rgb 0.7 0.5 0.3)) a98-rgb r g b / alpha)']
expected: FAIL
[Property color value 'color(from color-mix(in xyz, color(rec2020 0.7 0.5 0.3), color(rec2020 0.7 0.5 0.3)) rec2020 r g b / alpha)']
expected: FAIL
[Property color value 'color(from color-mix(in xyz, color(prophoto-rgb 0.7 0.5 0.3), color(prophoto-rgb 0.7 0.5 0.3)) prophoto-rgb r g b / alpha)']
expected: FAIL
[Property color value 'color(from color-mix(in xyz, color(display-p3 0.7 0.5 0.3), color(display-p3 0.7 0.5 0.3)) display-p3 r g b / alpha)']
expected: FAIL
[Property color value 'hsl(from rebeccapurple calc((h / 360) * 360deg) calc((s / 100) * 100%) calc((l / 100) * 100%) / calc(alpha * 100%))'] [Property color value 'hsl(from rebeccapurple calc((h / 360) * 360deg) calc((s / 100) * 100%) calc((l / 100) * 100%) / calc(alpha * 100%))']
expected: FAIL expected: FAIL
[Property color value 'hwb(from rebeccapurple calc((h / 360) * 360deg) calc((w / 100) * 100%) calc((b / 100) * 100%) / calc(alpha * 100%))'] [Property color value 'hwb(from rebeccapurple calc((h / 360) * 360deg) calc((w / 100) * 100%) calc((b / 100) * 100%) / calc(alpha * 100%))']
expected: FAIL expected: FAIL
[Property color value 'color(from color-mix(in xyz, color(xyz 0.7 0.5 0.3), color(xyz 0.7 0.5 0.3)) xyz x y z / alpha)']
expected: FAIL
[Property color value 'color(from color-mix(in xyz, color(xyz-d50 0.7 0.5 0.3), color(xyz-d50 0.7 0.5 0.3)) xyz-d50 x y z / alpha)']
expected: FAIL
[Property color value 'color(from color-mix(in xyz, color(xyz-d65 0.7 0.5 0.3), color(xyz-d65 0.7 0.5 0.3)) xyz-d65 x y z / alpha)']
expected: FAIL
[Property color value 'color(from hsl(from color(xyz-d50 0.99 0.88 0.77) h s l) xyz-d50 x y z)'] [Property color value 'color(from hsl(from color(xyz-d50 0.99 0.88 0.77) h s l) xyz-d50 x y z)']
expected: FAIL expected: FAIL

View File

@ -365,60 +365,15 @@
[e.style['color'\] = "color(from currentColor xyz-d65 x y z)" should set the property value] [e.style['color'\] = "color(from currentColor xyz-d65 x y z)" should set the property value]
expected: FAIL expected: FAIL
[e.style['color'\] = "rgb(from color-mix(in srgb, red, red) r g b / alpha)" should set the property value]
expected: FAIL
[e.style['color'\] = "hsl(from color-mix(in srgb, red, red) h s l / alpha)" should set the property value] [e.style['color'\] = "hsl(from color-mix(in srgb, red, red) h s l / alpha)" should set the property value]
expected: FAIL expected: FAIL
[e.style['color'\] = "hwb(from color-mix(in srgb, red, red) h w b / alpha)" should set the property value] [e.style['color'\] = "hwb(from color-mix(in srgb, red, red) h w b / alpha)" should set the property value]
expected: FAIL expected: FAIL
[e.style['color'\] = "lab(from color-mix(in lab, lab(25 20 50), lab(25 20 50)) l a b / alpha)" should set the property value]
expected: FAIL
[e.style['color'\] = "oklab(from color-mix(in oklab, oklab(0.25 0.2 0.5), oklab(0.25 0.2 0.5)) l a b / alpha)" should set the property value]
expected: FAIL
[e.style['color'\] = "lch(from color-mix(in lch, lch(70 45 30), lch(70 45 30)) l c h / alpha)" should set the property value]
expected: FAIL
[e.style['color'\] = "oklch(from color-mix(in oklch, oklch(0.7 0.45 30), oklch(0.7 0.45 30)) l c h / alpha)" should set the property value]
expected: FAIL
[e.style['color'\] = "color(from color-mix(in xyz, color(srgb 0.7 0.5 0.3), color(srgb 0.7 0.5 0.3)) srgb r g b / alpha)" should set the property value]
expected: FAIL
[e.style['color'\] = "color(from color-mix(in xyz, color(srgb-linear 0.7 0.5 0.3), color(srgb-linear 0.7 0.5 0.3)) srgb-linear r g b / alpha)" should set the property value]
expected: FAIL
[e.style['color'\] = "color(from color-mix(in xyz, color(a98-rgb 0.7 0.5 0.3), color(a98-rgb 0.7 0.5 0.3)) a98-rgb r g b / alpha)" should set the property value]
expected: FAIL
[e.style['color'\] = "color(from color-mix(in xyz, color(rec2020 0.7 0.5 0.3), color(rec2020 0.7 0.5 0.3)) rec2020 r g b / alpha)" should set the property value]
expected: FAIL
[e.style['color'\] = "color(from color-mix(in xyz, color(prophoto-rgb 0.7 0.5 0.3), color(prophoto-rgb 0.7 0.5 0.3)) prophoto-rgb r g b / alpha)" should set the property value]
expected: FAIL
[e.style['color'\] = "color(from color-mix(in xyz, color(display-p3 0.7 0.5 0.3), color(display-p3 0.7 0.5 0.3)) display-p3 r g b / alpha)" should set the property value]
expected: FAIL
[e.style['color'\] = "color(from color-mix(in xyz, color(xyz 0.7 0.5 0.3), color(xyz 0.7 0.5 0.3)) xyz x y z / alpha)" should set the property value]
expected: FAIL
[e.style['color'\] = "color(from color-mix(in xyz, color(xyz-d50 0.7 0.5 0.3), color(xyz-d50 0.7 0.5 0.3)) xyz-d50 x y z / alpha)" should set the property value]
expected: FAIL
[e.style['color'\] = "color(from color-mix(in xyz, color(xyz-d65 0.7 0.5 0.3), color(xyz-d65 0.7 0.5 0.3)) xyz-d65 x y z / alpha)" should set the property value]
expected: FAIL
[e.style['color'\] = "rgba(from currentColor r g b)" should set the property value] [e.style['color'\] = "rgba(from currentColor r g b)" should set the property value]
expected: FAIL expected: FAIL
[e.style['color'\] = "rgba(from color-mix(in srgb, red, red) r g b / alpha)" should set the property value]
expected: FAIL
[e.style['color'\] = "hsla(from rebeccapurple h s l)" should set the property value] [e.style['color'\] = "hsla(from rebeccapurple h s l)" should set the property value]
expected: FAIL expected: FAIL