Skip to content

Truly independent web browser

LibWeb: Implement the alpha() color function

Andreas Kling3c05f8e94808
diff --git a/Libraries/LibWeb/CSS/ColorFunctionDescriptor.cpp b/Libraries/LibWeb/CSS/ColorFunctionDescriptor.cpp
index 46e8efa6b4e..329327915e8 100644
--- a/Libraries/LibWeb/CSS/ColorFunctionDescriptor.cpp
+++ b/Libraries/LibWeb/CSS/ColorFunctionDescriptor.cpp
@@ -10,7 +10,7 @@ namespace Web::CSS {
using ColorType = ColorStyleValue::ColorType;
-static constexpr size_t color_type_count = to_underlying(ColorType::XYZD65) + 1;
+static constexpr size_t color_type_count = to_underlying(ColorType::Alpha) + 1;
namespace {
@@ -135,6 +135,13 @@ Array<ColorFunctionDescriptor, color_type_count> build_color_function_descriptor
ChannelDescriptor { ChannelKind::Number, 1.0f, {}, {} },
ChannelDescriptor { ChannelKind::Number, 1.0f, {}, {} } },
};
+ table[to_underlying(ColorType::Alpha)] = {
+ "alpha"sv,
+ SerializationBehavior::ModernNamed,
+ { ChannelDescriptor { ChannelKind::Number, 1.0f, {}, {} },
+ ChannelDescriptor { ChannelKind::Number, 1.0f, {}, {} },
+ ChannelDescriptor { ChannelKind::Number, 1.0f, {}, {} } },
+ };
return table;
}
diff --git a/Libraries/LibWeb/CSS/StyleValues/ColorStyleValue.h b/Libraries/LibWeb/CSS/StyleValues/ColorStyleValue.h
index c0160dd6ab8..f104ff97916 100644
--- a/Libraries/LibWeb/CSS/StyleValues/ColorStyleValue.h
+++ b/Libraries/LibWeb/CSS/StyleValues/ColorStyleValue.h
@@ -43,6 +43,7 @@ public:
Rec2020,
XYZD50,
XYZD65,
+ Alpha, // This is used for alpha(from ...), whose result is in the color space of its origin color.
};
// AD-HOC: Every color variant payload starts with the same ColorBase prefix, so the base
// class reads it through one arm without knowing which color variant it has. The
diff --git a/Libraries/LibWeb/Rust/src/css/color_conversion.rs b/Libraries/LibWeb/Rust/src/css/color_conversion.rs
index 7f67a73a257..e04c2ea2a55 100644
--- a/Libraries/LibWeb/Rust/src/css/color_conversion.rs
+++ b/Libraries/LibWeb/Rust/src/css/color_conversion.rs
@@ -24,6 +24,8 @@ pub(crate) const PROPHOTO_RGB: u8 = 12;
pub(crate) const REC2020: u8 = 13;
pub(crate) const XYZ_D50: u8 = 14;
pub(crate) const XYZ_D65: u8 = 15;
+// NB: alpha() has no color space of its own; its result is in the color space of its origin color.
+pub(crate) const ALPHA: u8 = 16;
// https://drafts.csswg.org/css-color-4/#predefined-sRGB
// https://drafts.csswg.org/css-color-4/#color-conversion-code
diff --git a/Libraries/LibWeb/Rust/src/css/color_resolution.rs b/Libraries/LibWeb/Rust/src/css/color_resolution.rs
index d38b32c19a7..1776bf19720 100644
--- a/Libraries/LibWeb/Rust/src/css/color_resolution.rs
+++ b/Libraries/LibWeb/Rust/src/css/color_resolution.rs
@@ -401,7 +401,7 @@ const fn color_function(name: &'static str) -> ColorFunctionDescriptor {
}
/// Color function metadata indexed by the frozen color-type codes.
-static COLOR_FUNCTION_DESCRIPTORS: [ColorFunctionDescriptor; 16] = [
+static COLOR_FUNCTION_DESCRIPTORS: [ColorFunctionDescriptor; 17] = [
// RGB
ColorFunctionDescriptor {
name: "rgb",
@@ -497,6 +497,17 @@ static COLOR_FUNCTION_DESCRIPTORS: [ColorFunctionDescriptor; 16] = [
color_function("xyz-d50"),
// XYZD65
color_function("xyz-d65"),
+ // Alpha
+ ColorFunctionDescriptor {
+ name: "alpha",
+ behavior: SerializationBehavior::ModernNamed,
+ channels: [
+ number_channel(1.0, None, None),
+ number_channel(1.0, None, None),
+ number_channel(1.0, None, None),
+ ],
+ absolutizes_to_rgb: false,
+ },
];
pub(crate) fn descriptor_for_color_type(color_type: u8) -> &'static ColorFunctionDescriptor {
@@ -1030,6 +1041,9 @@ fn color_function_to_color(value: &StyleValueData, input: &ColorResolutionInput)
return None;
}
let color_type = color_base.color_type;
+ if color_type == color_conversion::ALPHA {
+ return to_color(&resolve_relative_form(value, input)?, input);
+ }
let relative_channels;
let synthesized_alpha;
@@ -1353,6 +1367,9 @@ pub(crate) fn resolve_relative_form(value: &StyleValueData, input: &ColorResolut
return None;
}
let target_color_type = color_base.color_type;
+ if target_color_type == color_conversion::ALPHA {
+ return resolve_relative_alpha(origin, alpha.optional_data()?, input);
+ }
let (relative_channels, missing_slots) = extract_channels_in_color_space(origin, target_color_type, input)?;
let mut channel_input = *input;
@@ -1419,6 +1436,93 @@ pub(crate) fn resolve_relative_form(value: &StyleValueData, input: &ColorResolut
})
}
+/// Resolves alpha(from <color> / <alpha>) to an absolute color in the color space of its origin color.
+// https://drafts.csswg.org/css-color-5/#relative-alpha
+fn resolve_relative_alpha(
+ origin_color: &StyleValueData,
+ alpha: &StyleValueData,
+ input: &ColorResolutionInput,
+) -> Option<StyleValueData> {
+ let mut effective_origin = origin_color;
+ if let StyleValueData::Keyword { keyword: code } = effective_origin
+ && *code == keyword::CURRENTCOLOR
+ && let Some(current_color_value) = input.current_color_value
+ && !value_depends_on_current_color(current_color_value)
+ {
+ effective_origin = current_color_value;
+ }
+ let resolved_origin_storage;
+ if let StyleValueData::ColorFunction {
+ origin_color: nested_origin,
+ ..
+ } = effective_origin
+ && nested_origin.optional_data().is_some()
+ {
+ resolved_origin_storage = resolve_relative_form(effective_origin, input)?;
+ effective_origin = &resolved_origin_storage;
+ }
+
+ // The color components of the origin color are unchanged, the alpha component is modified or replaced.
+ // The result of this function is in the color space of the origin color.
+ let (color_type, components, missing) = match resolve_origin_native_channels(effective_origin) {
+ Some(native) => native,
+ None => {
+ let color = to_color(effective_origin, input)?;
+ (
+ color_conversion::SRGB,
+ [
+ f32::from(color.r) / 255.0,
+ f32::from(color.g) / 255.0,
+ f32::from(color.b) / 255.0,
+ f32::from(color.a) / 255.0,
+ ],
+ [false; 4],
+ )
+ }
+ };
+ let component = |index: usize| {
+ if missing[index] {
+ StyleValueData::Keyword { keyword: keyword::NONE }
+ } else {
+ StyleValueData::Number {
+ value: f64::from(components[index]),
+ }
+ }
+ };
+
+ // alpha is a <number> that corresponds to the origin color's alpha transparency.
+ let mut channels: RelativeColorContext = [None; 13];
+ channels[usize::from(channel_keyword::ALPHA)] = Some(if missing[3] { 0.0 } else { f64::from(components[3]) });
+ let channel_input = ColorResolutionInput {
+ channels: Some(&channels),
+ ..*input
+ };
+ let refers_to_missing_alpha =
+ missing[3] && matches!(alpha, StyleValueData::Keyword { keyword: code } if *code == keyword::ALPHA);
+ let resolved_alpha = if is_none_keyword(alpha) || refers_to_missing_alpha {
+ StyleValueData::Keyword { keyword: keyword::NONE }
+ } else {
+ StyleValueData::Number {
+ value: resolve_alpha(alpha, &channel_input)?,
+ }
+ };
+
+ Some(StyleValueData::ColorFunction {
+ color_base: ColorBase {
+ has_color_type: true,
+ color_type,
+ color_syntax: crate::css::value_codes::COLOR_SYNTAX_MODERN,
+ },
+ channel_0: retained_value(component(0)),
+ channel_1: retained_value(component(1)),
+ channel_2: retained_value(component(2)),
+ alpha: retained_value(resolved_alpha),
+ has_name: false,
+ name: CssString::none(),
+ origin_color: retained_null(),
+ })
+}
+
/// The computed value form of an absolute rgb(), hsl() or hwb() function: the same color as
/// color(srgb ...). Other color functions compute to themselves.
// https://drafts.csswg.org/css-color-4/#resolving-sRGB-values
diff --git a/Libraries/LibWeb/Rust/src/css/parser/color_parser.rs b/Libraries/LibWeb/Rust/src/css/parser/color_parser.rs
index 686ca967a3d..e9805459c73 100644
--- a/Libraries/LibWeb/Rust/src/css/parser/color_parser.rs
+++ b/Libraries/LibWeb/Rust/src/css/parser/color_parser.rs
@@ -805,6 +805,28 @@ fn parse_color_function(context: &ParseContext, property: u16, values: &[Compone
))
}
+// https://drafts.csswg.org/css-color-5/#relative-alpha
+fn parse_alpha_function(context: &ParseContext, property: u16, values: &[ComponentValue]) -> Option<StyleValueData> {
+ // alpha() = alpha(from <color> / [<alpha-value> | none])
+ let mut stream = TokenStream::new(values);
+ let origin_color = parse_relative_origin(context, property, &mut stream, false).ok()??;
+ let alpha = parse_alpha(context, property, &mut stream, allowed_channels(&[]))?;
+ stream.discard_whitespace();
+ if stream.has_next_token() {
+ return None;
+ }
+ // NB: alpha() keeps the color components of its origin color, so its own channels are unused.
+ let unused_channel = || StyleValueData::Number { value: 0.0 };
+ Some(make_color_function(
+ color_conversion::ALPHA,
+ [unused_channel(), unused_channel(), unused_channel()],
+ Some(alpha),
+ COLOR_SYNTAX_MODERN,
+ None,
+ Some(origin_color),
+ ))
+}
+
pub(crate) fn parse_color_interpolation_method(stream: &mut TokenStream<'_>) -> Option<StyleValueData> {
let start = stream.current_index();
stream.discard_whitespace();
@@ -971,6 +993,8 @@ fn parse_color_function_component(
) -> Option<StyleValueData> {
if equals_ascii_case_insensitive(name, b"color") {
parse_color_function(context, property, values)
+ } else if equals_ascii_case_insensitive(name, b"alpha") {
+ parse_alpha_function(context, property, values)
} else if equals_ascii_case_insensitive(name, b"color-mix") {
parse_color_mix(context, property, values)
} else if equals_ascii_case_insensitive(name, b"rgb")
@@ -997,6 +1021,7 @@ fn parse_color_function_component(
pub(crate) fn is_color_function_name(name: &[u16]) -> bool {
[
+ "alpha",
"color",
"color-mix",
"contrast-color",
@@ -1142,6 +1167,8 @@ mod tests {
"hsl(from red calc(h + 10) s l)",
"lab(from red l calc(a * 2) b)",
"color(from red srgb r g b)",
+ "alpha(from red / 0.5)",
+ "alpha(from currentcolor / calc(alpha * 0.5))",
] {
assert!(parse(source).is_some(), "{source}");
}
@@ -1157,6 +1184,9 @@ mod tests {
"color(unknown 1 2 3)",
"light-dark(red)",
"contrast-color(red, blue)",
+ "alpha(red / 0.5)",
+ "alpha(from red)",
+ "alpha(from red / r)",
] {
assert!(parse(source).is_none(), "{source}");
}
diff --git a/Libraries/LibWeb/Rust/src/css/serialize.rs b/Libraries/LibWeb/Rust/src/css/serialize.rs
index 75a868ac0b5..9bff2530eff 100644
--- a/Libraries/LibWeb/Rust/src/css/serialize.rs
+++ b/Libraries/LibWeb/Rust/src/css/serialize.rs
@@ -2028,6 +2028,16 @@ pub(crate) fn serialize_style_value(sink: &mut TextSink, value: &StyleValueData,
// https://drafts.csswg.org/css-color-5/#serial-relative-color
if let Some(origin) = origin_color.optional_data() {
+ if color_base.color_type == crate::css::color_conversion::ALPHA {
+ sink.push_ascii("alpha(from ");
+ serialize_style_value(sink, origin, mode);
+ if let Some(alpha) = alpha.optional_data() {
+ sink.push_ascii(" / ");
+ serialize_style_value(sink, alpha, mode);
+ }
+ sink.push_ascii(")");
+ return;
+ }
if descriptor.behavior == SerializationBehavior::ColorFunction {
sink.push_ascii("color(from ");
serialize_style_value(sink, origin, mode);
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-color/parsing/alpha-color-computed.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-color/parsing/alpha-color-computed.txt
index d787cce16e8..0bd5719487f 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-color/parsing/alpha-color-computed.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-color/parsing/alpha-color-computed.txt
@@ -2,37 +2,37 @@ Harness status: OK
Found 33 tests
-33 Fail
-Fail Property color value 'alpha(from red / 0.5)'
-Fail Property color value 'alpha(from blue / 0)'
-Fail Property color value 'alpha(from rebeccapurple / 1)'
-Fail Property color value 'alpha(from red / 50%)'
-Fail Property color value 'alpha(from red / 0%)'
-Fail Property color value 'alpha(from red / none)'
-Fail Property color value 'color-mix(in srgb, rgb(255 0 0 / 0.5), alpha(from red / none))'
-Fail Property color value 'alpha(from red / 2)'
-Fail Property color value 'alpha(from red / -1)'
-Fail Property color value 'alpha(from rgba(255, 0, 0, 0.3) / 0.8)'
-Fail Property color value 'alpha(from color(display-p3 1 0 0) / 0.5)'
-Fail Property color value 'alpha(from color(srgb 1 0 0) / 0.5)'
-Fail Property color value 'alpha(from color(srgb 1 0 0) / 50%)'
-Fail Property color value 'alpha(from rgba(255, 0, 0, 0.8) / calc(alpha + 0.1))'
-Fail Property color value 'alpha(from rebeccapurple / calc(alpha / 1))'
-Fail Property color value 'alpha(from alpha(from red / 0.5) / calc(alpha + 0.25))'
-Fail Property color value 'alpha(from alpha(from rebeccapurple / 0%) / 100%)'
-Fail Property color value 'alpha(from color-mix(in srgb, red, blue) / 0.5)'
-Fail Property color value 'alpha(from rgb(from red r g b) / 0.8)'
-Fail Property color value 'alpha(from rgb(none none none / none) / alpha)'
-Fail Property color value 'alpha(from rgb(none none none) / alpha)'
-Fail Property color value 'alpha(from rgb(0 255 0 / none) / alpha)'
-Fail Property color value 'alpha(from rgb(0 none 0) / alpha)'
-Fail Property color value 'rgb(from alpha(from red / 0.5) r g b / alpha)'
-Fail Property color value 'hsl(from alpha(from red / 0.5) h s l / alpha)'
-Fail Property color value 'lab(from alpha(from lab(50% 20 -30) / 0.5) l a b / alpha)'
-Fail Property color value 'oklch(from alpha(from oklch(50% 0.2 120) / 0.5) l c h / alpha)'
-Fail Property color value 'color(from alpha(from red / 1.5) srgb r g b / calc(alpha - 0.2))'
-Fail Property background-color value 'alpha(from currentcolor / 0.5)'
-Fail Property background-color value 'alpha(from currentcolor / alpha)'
-Fail Property background-color value 'alpha(from currentcolor / none)'
-Fail Property background-color value 'alpha(from currentcolor / 50%)'
-Fail Property background-color value 'alpha(from currentcolor / calc(alpha * 0.5))'
\ No newline at end of file
+33 Pass
+Pass Property color value 'alpha(from red / 0.5)'
+Pass Property color value 'alpha(from blue / 0)'
+Pass Property color value 'alpha(from rebeccapurple / 1)'
+Pass Property color value 'alpha(from red / 50%)'
+Pass Property color value 'alpha(from red / 0%)'
+Pass Property color value 'alpha(from red / none)'
+Pass Property color value 'color-mix(in srgb, rgb(255 0 0 / 0.5), alpha(from red / none))'
+Pass Property color value 'alpha(from red / 2)'
+Pass Property color value 'alpha(from red / -1)'
+Pass Property color value 'alpha(from rgba(255, 0, 0, 0.3) / 0.8)'
+Pass Property color value 'alpha(from color(display-p3 1 0 0) / 0.5)'
+Pass Property color value 'alpha(from color(srgb 1 0 0) / 0.5)'
+Pass Property color value 'alpha(from color(srgb 1 0 0) / 50%)'
+Pass Property color value 'alpha(from rgba(255, 0, 0, 0.8) / calc(alpha + 0.1))'
+Pass Property color value 'alpha(from rebeccapurple / calc(alpha / 1))'
+Pass Property color value 'alpha(from alpha(from red / 0.5) / calc(alpha + 0.25))'
+Pass Property color value 'alpha(from alpha(from rebeccapurple / 0%) / 100%)'
+Pass Property color value 'alpha(from color-mix(in srgb, red, blue) / 0.5)'
+Pass Property color value 'alpha(from rgb(from red r g b) / 0.8)'
+Pass Property color value 'alpha(from rgb(none none none / none) / alpha)'
+Pass Property color value 'alpha(from rgb(none none none) / alpha)'
+Pass Property color value 'alpha(from rgb(0 255 0 / none) / alpha)'
+Pass Property color value 'alpha(from rgb(0 none 0) / alpha)'
+Pass Property color value 'rgb(from alpha(from red / 0.5) r g b / alpha)'
+Pass Property color value 'hsl(from alpha(from red / 0.5) h s l / alpha)'
+Pass Property color value 'lab(from alpha(from lab(50% 20 -30) / 0.5) l a b / alpha)'
+Pass Property color value 'oklch(from alpha(from oklch(50% 0.2 120) / 0.5) l c h / alpha)'
+Pass Property color value 'color(from alpha(from red / 1.5) srgb r g b / calc(alpha - 0.2))'
+Pass Property background-color value 'alpha(from currentcolor / 0.5)'
+Pass Property background-color value 'alpha(from currentcolor / alpha)'
+Pass Property background-color value 'alpha(from currentcolor / none)'
+Pass Property background-color value 'alpha(from currentcolor / 50%)'
+Pass Property background-color value 'alpha(from currentcolor / calc(alpha * 0.5))'
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-color/parsing/alpha-color-parsing-valid.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-color/parsing/alpha-color-parsing-valid.txt
index 7557c042e7b..d14355d4b62 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-color/parsing/alpha-color-parsing-valid.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-color/parsing/alpha-color-parsing-valid.txt
@@ -2,50 +2,50 @@ Harness status: OK
Found 45 tests
-1 Pass
-44 Fail
-Fail e.style['color'] = "alpha(from red / 0.5)" should set the property value
-Fail e.style['color'] = "alpha(from blue / 1)" should set the property value
-Fail e.style['color'] = "alpha(from green / 0)" should set the property value
-Fail e.style['color'] = "alpha(from rgba(0, 0, 0, 0.5) / 1)" should set the property value
-Fail e.style['color'] = "alpha(from currentcolor / 1)" should set the property value
-Fail e.style['color'] = "alpha(from currentcolor / 100%)" should set the property value
-Fail e.style['color'] = "alpha(from alpha(from currentcolor / 0.5) / 1)" should set the property value
-Fail e.style['color'] = "alpha(from red / 50%)" should set the property value
-Fail e.style['color'] = "alpha(from red / 0%)" should set the property value
-Fail e.style['color'] = "alpha(from red / 100%)" should set the property value
-Fail e.style['color'] = "alpha(from red / none)" should set the property value
-Fail e.style['color'] = "alpha(from currentcolor / alpha)" should set the property value
-Fail e.style['color'] = "alpha(from currentcolor / calc(alpha * 0.5))" should set the property value
-Fail e.style['color'] = "alpha(from currentcolor / calc(alpha + 0.1))" should set the property value
-Fail e.style['color'] = "color-mix(in srgb, alpha(from red / 0.5), blue)" should set the property value
-Fail e.style['color'] = "rgb(from alpha(from currentcolor / 0.5) r g b)" should set the property value
-Fail e.style['color'] = "alpha(from color-mix(in srgb, red, blue) / 0.5)" should set the property value
-Fail e.style['color'] = "alpha(from rgb(from red r g b) / 0.8)" should set the property value
-Fail e.style['color'] = "alpha(from color(display-p3 1 0 0) / 0.5)" should set the property value
-Fail e.style['color'] = "alpha(from lab(50 20 -30) / 0.5)" should set the property value
-Fail e.style['color'] = "alpha(from oklch(0.5 0.2 120) / 0.5)" should set the property value
-Fail e.style['color'] = "alpha(from currentcolor / 0.5)" should set the property value
-Fail e.style['color'] = "alpha(from red / 2)" should set the property value
-Fail e.style['color'] = "alpha(from red / -1)" should set the property value
-Fail e.style['color'] = "alpha(from rgba(255, 0, 0, 0.8) / alpha)" should set the property value
-Fail e.style['color'] = "alpha(from color(srgb 1 0 0) / 50%)" should set the property value
-Fail e.style['color'] = "alpha(from oklab(0.5 0.2 -0.3) / 0.5)" should set the property value
-Fail e.style['color'] = "alpha(from lch(50% 20 30) / 0.5)" should set the property value
-Fail e.style['color'] = "alpha(from hsl(120 50% 50%) / 0.5)" should set the property value
-Fail e.style['color'] = "alpha(from hwb(120 0% 0%) / 0.5)" should set the property value
-Fail e.style['color'] = "alpha(from ActiveText / 0.5)" should set the property value
+43 Pass
+2 Fail
+Pass e.style['color'] = "alpha(from red / 0.5)" should set the property value
+Pass e.style['color'] = "alpha(from blue / 1)" should set the property value
+Pass e.style['color'] = "alpha(from green / 0)" should set the property value
+Pass e.style['color'] = "alpha(from rgba(0, 0, 0, 0.5) / 1)" should set the property value
+Pass e.style['color'] = "alpha(from currentcolor / 1)" should set the property value
+Pass e.style['color'] = "alpha(from currentcolor / 100%)" should set the property value
+Pass e.style['color'] = "alpha(from alpha(from currentcolor / 0.5) / 1)" should set the property value
+Pass e.style['color'] = "alpha(from red / 50%)" should set the property value
+Pass e.style['color'] = "alpha(from red / 0%)" should set the property value
+Pass e.style['color'] = "alpha(from red / 100%)" should set the property value
+Pass e.style['color'] = "alpha(from red / none)" should set the property value
+Pass e.style['color'] = "alpha(from currentcolor / alpha)" should set the property value
+Pass e.style['color'] = "alpha(from currentcolor / calc(alpha * 0.5))" should set the property value
+Pass e.style['color'] = "alpha(from currentcolor / calc(alpha + 0.1))" should set the property value
+Pass e.style['color'] = "color-mix(in srgb, alpha(from red / 0.5), blue)" should set the property value
+Pass e.style['color'] = "rgb(from alpha(from currentcolor / 0.5) r g b)" should set the property value
+Pass e.style['color'] = "alpha(from color-mix(in srgb, red, blue) / 0.5)" should set the property value
+Pass e.style['color'] = "alpha(from rgb(from red r g b) / 0.8)" should set the property value
+Pass e.style['color'] = "alpha(from color(display-p3 1 0 0) / 0.5)" should set the property value
+Pass e.style['color'] = "alpha(from lab(50 20 -30) / 0.5)" should set the property value
+Pass e.style['color'] = "alpha(from oklch(0.5 0.2 120) / 0.5)" should set the property value
+Pass e.style['color'] = "alpha(from currentcolor / 0.5)" should set the property value
+Pass e.style['color'] = "alpha(from red / 2)" should set the property value
+Pass e.style['color'] = "alpha(from red / -1)" should set the property value
+Pass e.style['color'] = "alpha(from rgba(255, 0, 0, 0.8) / alpha)" should set the property value
+Pass e.style['color'] = "alpha(from color(srgb 1 0 0) / 50%)" should set the property value
+Pass e.style['color'] = "alpha(from oklab(0.5 0.2 -0.3) / 0.5)" should set the property value
+Pass e.style['color'] = "alpha(from lch(50% 20 30) / 0.5)" should set the property value
+Pass e.style['color'] = "alpha(from hsl(120 50% 50%) / 0.5)" should set the property value
+Pass e.style['color'] = "alpha(from hwb(120 0% 0%) / 0.5)" should set the property value
+Pass e.style['color'] = "alpha(from ActiveText / 0.5)" should set the property value
Fail e.style['color'] = "alpha(from green / sibling-index())" should set the property value
Fail e.style['color'] = "alpha(from green / sibling-count())" should set the property value
-Fail e.style['color'] = "alpha(from green / calc(sibling-index() * 0.2))" should set the property value
+Pass e.style['color'] = "alpha(from green / calc(sibling-index() * 0.2))" should set the property value
Pass e.style['color'] = "alpha(from red / var(--alpha))" should set the property value
-Fail e.style['color'] = "alpha(from alpha(from currentcolor / 0.5) / alpha)" should set the property value
-Fail e.style['color'] = "alpha(from alpha(from currentcolor / 0.5) / calc(alpha + 0.25))" should set the property value
-Fail e.style['color'] = "rgb(from alpha(from red / 0.5) r g b / alpha)" should set the property value
-Fail e.style['color'] = "hsl(from alpha(from currentcolor / 0.5) h s l / alpha)" should set the property value
-Fail e.style['color'] = "hwb(from alpha(from currentcolor / 0.5) h w b / alpha)" should set the property value
-Fail e.style['color'] = "lab(from alpha(from currentcolor / 0.5) l a b / alpha)" should set the property value
-Fail e.style['color'] = "lch(from alpha(from currentcolor / 0.5) l c h / alpha)" should set the property value
-Fail e.style['color'] = "oklab(from alpha(from currentcolor / 0.5) l a b / alpha)" should set the property value
-Fail e.style['color'] = "oklch(from alpha(from currentcolor / 0.5) l c h / alpha)" should set the property value
-Fail e.style['color'] = "color(from alpha(from currentcolor / 0.5) display-p3 r g b / alpha)" should set the property value
\ No newline at end of file
+Pass e.style['color'] = "alpha(from alpha(from currentcolor / 0.5) / alpha)" should set the property value
+Pass e.style['color'] = "alpha(from alpha(from currentcolor / 0.5) / calc(alpha + 0.25))" should set the property value
+Pass e.style['color'] = "rgb(from alpha(from red / 0.5) r g b / alpha)" should set the property value
+Pass e.style['color'] = "hsl(from alpha(from currentcolor / 0.5) h s l / alpha)" should set the property value
+Pass e.style['color'] = "hwb(from alpha(from currentcolor / 0.5) h w b / alpha)" should set the property value
+Pass e.style['color'] = "lab(from alpha(from currentcolor / 0.5) l a b / alpha)" should set the property value
+Pass e.style['color'] = "lch(from alpha(from currentcolor / 0.5) l c h / alpha)" should set the property value
+Pass e.style['color'] = "oklab(from alpha(from currentcolor / 0.5) l a b / alpha)" should set the property value
+Pass e.style['color'] = "oklch(from alpha(from currentcolor / 0.5) l c h / alpha)" should set the property value
+Pass e.style['color'] = "color(from alpha(from currentcolor / 0.5) display-p3 r g b / alpha)" should set the property value
\ No newline at end of file