From 2ab102955e581e6370bbea0fbf79e1a425daf380 Mon Sep 17 00:00:00 2001 From: Tiaan Louw Date: Mon, 29 Apr 2024 14:44:01 +0000 Subject: [PATCH] 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 --- servo/components/style/color/parsing.rs | 8 ++-- .../color-computed-relative-color.html.ini | 42 ----------------- .../color-valid-relative-color.html.ini | 45 ------------------- 3 files changed, 4 insertions(+), 91 deletions(-) diff --git a/servo/components/style/color/parsing.rs b/servo/components/style/color/parsing.rs index de907eb1c08d..a83e369864ae 100644 --- a/servo/components/style/color/parsing.rs +++ b/servo/components/style/color/parsing.rs @@ -12,7 +12,7 @@ use super::{ AbsoluteColor, ColorFlags, ColorSpace, }; use crate::{ - parser::ParserContext, + parser::{Parse, ParserContext}, values::{ generics::calc::CalcUnits, specified::{ @@ -173,15 +173,15 @@ fn parse_origin_color<'i, 't>( let location = arguments.current_source_location(); // 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. // 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)); }; - Ok(Some(absolute.color)) + Ok(Some(computed.resolve_to_absolute(&AbsoluteColor::BLACK))) } #[inline] diff --git a/testing/web-platform/meta/css/css-color/parsing/color-computed-relative-color.html.ini b/testing/web-platform/meta/css/css-color/parsing/color-computed-relative-color.html.ini index 7d2d51bb5e88..5e02c75a4b96 100644 --- a/testing/web-platform/meta/css/css-color/parsing/color-computed-relative-color.html.ini +++ b/testing/web-platform/meta/css/css-color/parsing/color-computed-relative-color.html.ini @@ -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))'] 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)'] expected: FAIL [Property color value 'hwb(from color-mix(in srgb, red, red) h w b / alpha)'] 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%))'] expected: FAIL [Property color value 'hwb(from rebeccapurple calc((h / 360) * 360deg) calc((w / 100) * 100%) calc((b / 100) * 100%) / calc(alpha * 100%))'] 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)'] expected: FAIL diff --git a/testing/web-platform/meta/css/css-color/parsing/color-valid-relative-color.html.ini b/testing/web-platform/meta/css/css-color/parsing/color-valid-relative-color.html.ini index 36cbdf799aec..4cd689920bda 100644 --- a/testing/web-platform/meta/css/css-color/parsing/color-valid-relative-color.html.ini +++ b/testing/web-platform/meta/css/css-color/parsing/color-valid-relative-color.html.ini @@ -365,60 +365,15 @@ [e.style['color'\] = "color(from currentColor xyz-d65 x y z)" should set the property value] 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] expected: FAIL [e.style['color'\] = "hwb(from color-mix(in srgb, red, red) h w b / alpha)" should set the property value] 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] 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] expected: FAIL