Bug 1898468 - When converting legacy rgb(..) to color(srgb ..), ensure the flags are set accordingly r=layout-reviewers,emilio

Differential Revision: https://phabricator.services.mozilla.com/D211341
This commit is contained in:
Tiaan Louw 2024-05-23 20:54:23 +00:00
Родитель edcd6dcf8c
Коммит 97ed797d2f
2 изменённых файлов: 11 добавлений и 3 удалений

Просмотреть файл

@ -425,9 +425,13 @@ fn parse_color_with_color_space<'i, 't>(
let color_space = PredefinedColorSpace::parse(arguments)?;
let component_parser = ComponentParser {
context: component_parser.context,
origin_color: component_parser
.origin_color
.map(|c| c.to_color_space(ColorSpace::from(color_space))),
origin_color: component_parser.origin_color.map(|c| {
// If the origin color was in legacy srgb, converting it won't
// change it to modern syntax. So make sure it's in modern syntax.
let mut c = c.to_color_space(ColorSpace::from(color_space));
c.flags.remove(ColorFlags::IS_LEGACY_SRGB);
c
}),
};
let c1 = component_parser.parse_number_or_percentage(arguments, true)?;

Просмотреть файл

@ -763,6 +763,10 @@
fuzzy_test_valid_color(`lch(from var(--mycolor) l 0 h)`);
fuzzy_test_valid_color(`var(--mygray)`);
fuzzy_test_valid_color(`lch(from var(--mygray) l 30 h)`);
// Ensure that converting between legacy and modern sRGB color spaces work as expected.
fuzzy_test_valid_color(`color(from rebeccapurple srgb r g b)`, `color(srgb 0.4 0.2 0.6)`, 0.01);
fuzzy_test_valid_color(`rgb(from color(srgb 0.4 0.2 0.6) r g b)`, `color(srgb 0.4 0.2 0.6)`, 0.01);
</script>
</body>
</html>