Skip to content

Commit 6e0fdc9

Browse files
committed
Bug 2024601 - patch 4 - Remove the special-case for simple var() references (without default value) in feature expression values. r=firefox-style-system-reviewers,emilio
Now that we have more general substitution-function support, the special-case for var() with a simple dashed-ident (and no default) isn't really necessary. In theory it would be slightly more efficient, but seems unlikely to be much used as query expressions also support bare custom-property names (without any var() wrapper), so authors have no reason to write the more verbose form. Differential Revision: https://phabricator.services.mozilla.com/D290905
1 parent 65fd1a0 commit 6e0fdc9

1 file changed

Lines changed: 5 additions & 24 deletions

File tree

servo/components/style/queries/feature_expression.rs

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -681,9 +681,6 @@ pub enum QueryExpressionValue {
681681
Time(Time),
682682
/// A custom property name.
683683
Custom(DashedIdent),
684-
/// A simple var(...) reference without a default (equivalent to a bare Custom ident,
685-
/// but will serialize with the `var()` wrapper).
686-
Var(DashedIdent),
687684
/// An arbitrary substitution function (var(), attr(), env()), stored as a string
688685
/// for later evaluation. We store this as a custom-property value to make it easy
689686
/// to resolve later.
@@ -711,11 +708,6 @@ impl QueryExpressionValue {
711708
QueryExpressionValue::Angle(v) => v.to_css(dest),
712709
QueryExpressionValue::Time(v) => v.to_css(dest),
713710
QueryExpressionValue::Custom(ref v) => v.to_css(dest),
714-
QueryExpressionValue::Var(ref v) => {
715-
dest.write_str("var(")?;
716-
v.to_css(dest)?;
717-
dest.write_char(')')
718-
},
719711
QueryExpressionValue::Function(ref f) => f.to_css(dest),
720712
QueryExpressionValue::Enumerated(value) => match for_expr
721713
.expect("caller should have passed for_expr")
@@ -817,21 +809,10 @@ impl QueryExpressionValue {
817809
)
818810
};
819811

820-
if name.eq_ignore_ascii_case("var") {
821-
// For simple `var(--foo)` references used as individual query-expression values,
822-
// we can store as the Var() variant and just look up the custom property at
823-
// evaluation time.
824-
if let Ok(ident) =
825-
input.try_parse(|i| i.parse_nested_block(|i| DashedIdent::parse(context, i)))
826-
{
827-
return Ok(Self::Var(ident));
828-
}
829-
// Otherwise, we store the entire function to be resolved later via
830-
// custom_properties::substitute(), which will also handle fallbacks
831-
// if necessary.
832-
return Ok(Self::Function(Box::new(parse_func(input)?)));
833-
}
834-
if static_prefs::pref!("layout.css.attr.enabled") && name.eq_ignore_ascii_case("attr") {
812+
if name.eq_ignore_ascii_case("var")
813+
|| (static_prefs::pref!("layout.css.attr.enabled")
814+
&& name.eq_ignore_ascii_case("attr"))
815+
{
835816
return Ok(Self::Function(Box::new(parse_func(input)?)));
836817
}
837818
}
@@ -988,7 +969,7 @@ impl QueryStyleRange {
988969
visited_set: &mut PrecomputedHashSet<DashedIdent>,
989970
) -> Option<Component> {
990971
match value {
991-
QueryExpressionValue::Custom(ident) | QueryExpressionValue::Var(ident) => {
972+
QueryExpressionValue::Custom(ident) => {
992973
// `ident` is the dashed ident, but we need the name
993974
// without "--" for custom-property lookup.
994975
let name = ident.undashed();

0 commit comments

Comments
 (0)