style: Add lab(), lch(), oklab(), oklch() to specified colors

Use new changes from cssparser and use the new lab/lch/oklab/oklch color
formats.

Introduced a new color type AbsoluteColor.  It represents any kind of
color that has absolute numerical values.  It is also tied to a color
space and therefore can be trivially converted to another color space.

Differential Revision: https://phabricator.services.mozilla.com/D163579
This commit is contained in:
Tiaan Louw 2023-01-20 10:55:51 +00:00 committed by Martin Robinson
parent 6ce64abe7e
commit 4559546fbb
12 changed files with 512 additions and 90 deletions

View file

@ -433,9 +433,11 @@ fn tweak_when_ignoring_colors(
return;
}
fn alpha_channel(color: &Color, context: &computed::Context) -> u8 {
fn alpha_channel(color: &Color, context: &computed::Context) -> f32 {
// We assume here currentColor is opaque.
let color = color.to_computed_value(context).into_rgba(RGBA::new(0, 0, 0, 255));
let color = color
.to_computed_value(context)
.into_rgba(RGBA::new(0, 0, 0, 1.0));
color.alpha
}
@ -458,7 +460,7 @@ fn tweak_when_ignoring_colors(
// otherwise, this is needed to preserve semi-transparent
// backgrounds.
let alpha = alpha_channel(color, context);
if alpha == 0 {
if alpha == 0.0 {
return;
}
let mut color = context.builder.device.default_background_color();
@ -474,7 +476,7 @@ fn tweak_when_ignoring_colors(
// If the inherited color would be transparent, but we would
// override this with a non-transparent color, then override it with
// the default color. Otherwise just let it inherit through.
if context.builder.get_parent_inherited_text().clone_color().alpha == 0 {
if context.builder.get_parent_inherited_text().clone_color().alpha == 0.0 {
let color = context.builder.device.default_color();
declarations_to_apply_unless_overriden.push(PropertyDeclaration::Color(
specified::ColorPropertyValue(color.into()),