Skip to content

Truly independent web browser

LibWeb: Parse tree counting functions in color channels

Andreas Kling2f90d9499b35
diff --git a/Libraries/LibWeb/Rust/src/css/parser/color_parser.rs b/Libraries/LibWeb/Rust/src/css/parser/color_parser.rs
index e2e67b929a6..16b2b5a5c98 100644
--- a/Libraries/LibWeb/Rust/src/css/parser/color_parser.rs
+++ b/Libraries/LibWeb/Rust/src/css/parser/color_parser.rs
@@ -444,6 +444,15 @@ fn parse_numeric(
});
}
}
+ if accepted.contains(&NumericKind::Number)
+ && let Some(value) = super::value_parser::parse_tree_counting_value(context, value, 0)
+ {
+ stream.discard_a_token();
+ return Some(ParsedNumeric {
+ value,
+ kind: NumericKind::Number,
+ });
+ }
let parsed = match &value.kind {
ComponentKind::Token(ParserTokenKind::Number { value, .. }) if accepted.contains(&NumericKind::Number) => {
Some(ParsedNumeric {
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 d14355d4b62..46c84cb25f6 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,8 +2,7 @@ Harness status: OK
Found 45 tests
-43 Pass
-2 Fail
+45 Pass
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
@@ -35,8 +34,8 @@ Pass e.style['color'] = "alpha(from lch(50% 20 30) / 0.5)" should set the proper
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
+Pass e.style['color'] = "alpha(from green / sibling-index())" should set the property value
+Pass e.style['color'] = "alpha(from green / sibling-count())" 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
Pass e.style['color'] = "alpha(from alpha(from currentcolor / 0.5) / alpha)" should set the property value
diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-properties-values-api/resolved-color-value.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-properties-values-api/resolved-color-value.txt
index 255a0d9dc5c..ae73db30922 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/css/css-properties-values-api/resolved-color-value.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-properties-values-api/resolved-color-value.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Resolved <color> value with sibling-index()
\ No newline at end of file
+1 Pass
+Pass Resolved <color> value with sibling-index()
\ No newline at end of file