Skip to content

Commit d4728d9

Browse files
committed
Bug 2024601 - patch 3 - Evaluate substitution functions in style query expression values. r=firefox-style-system-reviewers,emilio
This makes the examples with var(--foo, default) pass, as well as those with attr() that depend on the attribute lookup failing (so they use the default); actual attr lookups will require an AttributeTracker in the substitute() call. Differential Revision: https://phabricator.services.mozilla.com/D290904
1 parent a7d6b5c commit d4728d9

3 files changed

Lines changed: 23 additions & 16 deletions

File tree

servo/components/style/custom_properties.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,6 +2392,7 @@ impl<'a> Substitution<'a> {
23922392
}
23932393

23942394
/// Result of var(), env(), and attr() substitution.
2395+
#[derive(Debug)]
23952396
pub struct SubstitutionResult<'a> {
23962397
/// The resolved CSS string after substitution.
23972398
pub css: Cow<'a, str>,

servo/components/style/queries/feature_expression.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
use super::feature::{Evaluator, QueryFeatureDescription};
99
use super::feature::{FeatureFlags, KeywordDiscriminant};
1010
use crate::context::QuirksMode;
11-
use crate::custom_properties::VariableValue as CustomVariableValue;
11+
use crate::custom_properties::{
12+
self, ComputedSubstitutionFunctions, VariableValue as CustomVariableValue,
13+
};
1214
use crate::derives::*;
1315
use crate::parser::{Parse, ParserContext};
1416
use crate::properties::CSSWideKeyword;
@@ -1016,6 +1018,25 @@ impl QueryStyleRange {
10161018
},
10171019
}
10181020
},
1021+
QueryExpressionValue::Function(value) => {
1022+
let sub_funcs = ComputedSubstitutionFunctions::new(
1023+
Some(context.inherited_custom_properties().clone()),
1024+
None,
1025+
);
1026+
let stylist = context
1027+
.builder
1028+
.stylist
1029+
.expect("container queries should have a stylist around");
1030+
let substituted = custom_properties::substitute(
1031+
&value,
1032+
&sub_funcs,
1033+
stylist,
1034+
context,
1035+
&mut crate::dom::AttributeTracker::new_dummy(),
1036+
)
1037+
.ok()?;
1038+
Self::resolve_universal(&substituted.css, &value.url_data, context, visited_set)
1039+
},
10191040
QueryExpressionValue::Length(v) => {
10201041
Some(Component::Length(v.to_computed_value(context)))
10211042
},

testing/web-platform/meta/css/css-conditional/container-queries/query-evaluation-style.html.ini

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,3 @@
22

33
[style(1px < attr(xyzzy type(<length>)) < 10px)]
44
expected: FAIL
5-
6-
[style(1px < attr(plugh, 5px) < 10px)]
7-
expected: FAIL
8-
9-
[style(1px < attr(plugh type(<length>), 5px) < 10px)]
10-
expected: FAIL
11-
12-
[style(var(--unknown-prop, 20px) > 10px)]
13-
expected: FAIL
14-
15-
[style(var(--prop, 5px) > 10px)]
16-
expected: FAIL
17-
18-
[style(var(--length, 20px) < 10px)]
19-
expected: FAIL

0 commit comments

Comments
 (0)