mirror of
https://github.com/servo/servo.git
synced 2025-10-04 02:29:12 +01:00
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:
parent
6ce64abe7e
commit
4559546fbb
12 changed files with 512 additions and 90 deletions
|
@ -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()),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue