Truly independent web browser
LibWeb: Substitute the value of a container style query
Andreas Klingfbf2f0410fae
diff --git a/Libraries/LibWeb/Rust/src/css/custom_properties.rs b/Libraries/LibWeb/Rust/src/css/custom_properties.rsindex d91e06359a9..e3af9d3d14a 100644--- a/Libraries/LibWeb/Rust/src/css/custom_properties.rs+++ b/Libraries/LibWeb/Rust/src/css/custom_properties.rs@@ -2763,6 +2763,25 @@ pub(crate) fn evaluate_retained_container_style_feature(let registry = Some(registry);let result = match feature {StyleFeature::Boolean(name) => evaluate_named_style_feature(store, registry, name, None, &mut context, 0),+ // The value is computed with respect to the query container, as the property it is compared with was.+ StyleFeature::Plain { name, value, .. }+ if name.starts_with_ascii("--") && contains_arbitrary_substitution_function(value) =>+ {+ match substitute_tokens(store, registry, value.as_slice(), &mut context, 0) {+ TokenResolution::Resolved(query) => {+ evaluate_named_style_feature(store, registry, name, Some(&query), &mut context, 0)+ }+ // NB: A value that substitutes to nothing valid matches a property that holds nothing valid either.+ TokenResolution::Invalid | TokenResolution::Cyclic => {+ match resolve_custom_property(store, registry, name.fly_string().as_ref(), &mut context, 1) {+ TokenResolution::Resolved(_) => ConditionEvaluation::Match(false),+ TokenResolution::Invalid | TokenResolution::Cyclic => ConditionEvaluation::Match(true),+ TokenResolution::NotHandled => ConditionEvaluation::NotHandled,+ }+ }+ TokenResolution::NotHandled => ConditionEvaluation::NotHandled,+ }+ }StyleFeature::Plain { name, value, .. } => {evaluate_named_style_feature(store, registry, name, Some(value), &mut context, 0)}diff --git a/Libraries/LibWeb/Rust/src/css/parser/query_parser.rs b/Libraries/LibWeb/Rust/src/css/parser/query_parser.rsindex 98ce2f3b8f5..5be16e83736 100644--- a/Libraries/LibWeb/Rust/src/css/parser/query_parser.rs+++ b/Libraries/LibWeb/Rust/src/css/parser/query_parser.rs@@ -526,6 +526,11 @@ fn contains_only_declaration_value(values: &[ComponentValue]) -> bool {&& values.iter().all(|value| {!matches!(value.kind, ComponentKind::Token(ParserTokenKind::Semicolon)) && !value.is_delim(b'!')})+ && crate::css::parser::arbitrary_substitution::collect_arbitrary_substitution_function_presence(+ values,+ &mut Default::default(),+ )+ .is_ok()}fn strip_important(values: &[ComponentValue]) -> &[ComponentValue] {diff --git a/Tests/LibWeb/Text/expected/css/style-engine/container-style-query-substitutes-its-value.txt b/Tests/LibWeb/Text/expected/css/style-engine/container-style-query-substitutes-its-value.txtindex 48b884da024..359c249ebf5 100644--- a/Tests/LibWeb/Text/expected/css/style-engine/container-style-query-substitutes-its-value.txt+++ b/Tests/LibWeb/Text/expected/css/style-engine/container-style-query-substitutes-its-value.txt@@ -1,14 +1,14 @@-registered: no+registered: yesregistered-other: no-registered-fallback: no-registered-calc: no-unregistered: no+registered-fallback: yes+registered-calc: yes+unregistered: yesunregistered-other: no-unregistered-fallback: no+unregistered-fallback: yesunregistered-missing: yes-itself: no-both-missing: no-no-arguments: yes+itself: yes+both-missing: yes+no-arguments: nofunction: yesregistered, after its value moves: no-registered, moved back: no+registered, moved back: yes