Skip to content

Commit 33ad82c

Browse files
emilioLoirooriol
authored andcommitted
style: Make custom properties that are IACVT guaranteed-invalid
This effectively backs out bug 1623396. See: w3c/csswg-drafts#6006 https://drafts.csswg.org/css-variables/#guaranteed-invalid-value And related discussion. Matches Chrome stable as per https://groups.google.com/a/chromium.org/g/blink-dev/c/0xrbzYe_vxU/m/7bsL76n9CgAJ Depends on D116459 Differential Revision: https://phabricator.services.mozilla.com/D116460
1 parent 71ec52f commit 33ad82c

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

components/style/custom_properties.rs

+5-20
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,7 @@ impl<'a> CustomPropertiesBuilder<'a> {
597597
match result {
598598
Ok(new_value) => new_value,
599599
Err(..) => {
600-
// Don't touch the map, this has the same effect as
601-
// making it compute to the inherited one.
600+
map.remove(name);
602601
return;
603602
},
604603
}
@@ -672,8 +671,7 @@ impl<'a> CustomPropertiesBuilder<'a> {
672671
None => return self.inherited.cloned(),
673672
};
674673
if self.may_have_cycles {
675-
let inherited = self.inherited.as_ref().map(|m| &***m);
676-
substitute_all(&mut map, inherited, self.device);
674+
substitute_all(&mut map, self.device);
677675
}
678676
map.shrink_to_fit();
679677
Some(Arc::new(map))
@@ -686,7 +684,6 @@ impl<'a> CustomPropertiesBuilder<'a> {
686684
/// It does cycle dependencies removal at the same time as substitution.
687685
fn substitute_all(
688686
custom_properties_map: &mut CustomPropertiesMap,
689-
inherited: Option<&CustomPropertiesMap>,
690687
device: &Device,
691688
) {
692689
// The cycle dependencies removal in this function is a variant
@@ -724,10 +721,7 @@ fn substitute_all(
724721
/// all unfinished strong connected components.
725722
stack: SmallVec<[usize; 5]>,
726723
map: &'a mut CustomPropertiesMap,
727-
/// The inherited variables. We may need to restore some if we fail
728-
/// substitution.
729-
inherited: Option<&'a CustomPropertiesMap>,
730-
/// to resolve the environment to substitute `env()` variables.
724+
/// To resolve the environment to substitute `env()` variables.
731725
device: &'a Device,
732726
}
733727

@@ -869,16 +863,8 @@ fn substitute_all(
869863
context.map.insert(name, computed_value);
870864
},
871865
Err(..) => {
872-
// This is invalid, reset it to the unset (inherited) value.
873-
let inherited = context.inherited.and_then(|m| m.get(&name)).cloned();
874-
match inherited {
875-
Some(computed_value) => {
876-
context.map.insert(name, computed_value);
877-
},
878-
None => {
879-
context.map.remove(&name);
880-
},
881-
};
866+
// This is invalid, reset it to the guaranteed-invalid value.
867+
context.map.remove(&name);
882868
},
883869
}
884870

@@ -896,7 +882,6 @@ fn substitute_all(
896882
stack: SmallVec::new(),
897883
var_info: SmallVec::new(),
898884
map: custom_properties_map,
899-
inherited,
900885
device,
901886
};
902887
traverse(name, &mut context);

0 commit comments

Comments
 (0)