mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
style: Make custom properties that are IACVT guaranteed-invalid
This effectively backs out bug 1623396. See: https://github.com/w3c/csswg-drafts/pull/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
This commit is contained in:
parent
71ec52f140
commit
33ad82c3da
1 changed files with 5 additions and 20 deletions
|
@ -597,8 +597,7 @@ impl<'a> CustomPropertiesBuilder<'a> {
|
||||||
match result {
|
match result {
|
||||||
Ok(new_value) => new_value,
|
Ok(new_value) => new_value,
|
||||||
Err(..) => {
|
Err(..) => {
|
||||||
// Don't touch the map, this has the same effect as
|
map.remove(name);
|
||||||
// making it compute to the inherited one.
|
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -672,8 +671,7 @@ impl<'a> CustomPropertiesBuilder<'a> {
|
||||||
None => return self.inherited.cloned(),
|
None => return self.inherited.cloned(),
|
||||||
};
|
};
|
||||||
if self.may_have_cycles {
|
if self.may_have_cycles {
|
||||||
let inherited = self.inherited.as_ref().map(|m| &***m);
|
substitute_all(&mut map, self.device);
|
||||||
substitute_all(&mut map, inherited, self.device);
|
|
||||||
}
|
}
|
||||||
map.shrink_to_fit();
|
map.shrink_to_fit();
|
||||||
Some(Arc::new(map))
|
Some(Arc::new(map))
|
||||||
|
@ -686,7 +684,6 @@ impl<'a> CustomPropertiesBuilder<'a> {
|
||||||
/// It does cycle dependencies removal at the same time as substitution.
|
/// It does cycle dependencies removal at the same time as substitution.
|
||||||
fn substitute_all(
|
fn substitute_all(
|
||||||
custom_properties_map: &mut CustomPropertiesMap,
|
custom_properties_map: &mut CustomPropertiesMap,
|
||||||
inherited: Option<&CustomPropertiesMap>,
|
|
||||||
device: &Device,
|
device: &Device,
|
||||||
) {
|
) {
|
||||||
// The cycle dependencies removal in this function is a variant
|
// The cycle dependencies removal in this function is a variant
|
||||||
|
@ -724,10 +721,7 @@ fn substitute_all(
|
||||||
/// all unfinished strong connected components.
|
/// all unfinished strong connected components.
|
||||||
stack: SmallVec<[usize; 5]>,
|
stack: SmallVec<[usize; 5]>,
|
||||||
map: &'a mut CustomPropertiesMap,
|
map: &'a mut CustomPropertiesMap,
|
||||||
/// The inherited variables. We may need to restore some if we fail
|
/// To resolve the environment to substitute `env()` variables.
|
||||||
/// substitution.
|
|
||||||
inherited: Option<&'a CustomPropertiesMap>,
|
|
||||||
/// to resolve the environment to substitute `env()` variables.
|
|
||||||
device: &'a Device,
|
device: &'a Device,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -869,16 +863,8 @@ fn substitute_all(
|
||||||
context.map.insert(name, computed_value);
|
context.map.insert(name, computed_value);
|
||||||
},
|
},
|
||||||
Err(..) => {
|
Err(..) => {
|
||||||
// This is invalid, reset it to the unset (inherited) value.
|
// This is invalid, reset it to the guaranteed-invalid value.
|
||||||
let inherited = context.inherited.and_then(|m| m.get(&name)).cloned();
|
context.map.remove(&name);
|
||||||
match inherited {
|
|
||||||
Some(computed_value) => {
|
|
||||||
context.map.insert(name, computed_value);
|
|
||||||
},
|
|
||||||
None => {
|
|
||||||
context.map.remove(&name);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -896,7 +882,6 @@ fn substitute_all(
|
||||||
stack: SmallVec::new(),
|
stack: SmallVec::new(),
|
||||||
var_info: SmallVec::new(),
|
var_info: SmallVec::new(),
|
||||||
map: custom_properties_map,
|
map: custom_properties_map,
|
||||||
inherited,
|
|
||||||
device,
|
device,
|
||||||
};
|
};
|
||||||
traverse(name, &mut context);
|
traverse(name, &mut context);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue