mirror of
https://github.com/servo/servo.git
synced 2025-06-21 23:59:00 +01:00
Don't use inherited custom properties for substitution
This commit is contained in:
parent
01adcf69d7
commit
dba19f53f5
1 changed files with 6 additions and 13 deletions
|
@ -503,7 +503,7 @@ pub fn finish_cascade(specified_values_map: Option<OrderedMap<&Name, BorrowedSpe
|
||||||
-> Option<Arc<CustomPropertiesMap>> {
|
-> Option<Arc<CustomPropertiesMap>> {
|
||||||
if let Some(mut map) = specified_values_map {
|
if let Some(mut map) = specified_values_map {
|
||||||
remove_cycles(&mut map);
|
remove_cycles(&mut map);
|
||||||
Some(Arc::new(substitute_all(map, inherited)))
|
Some(Arc::new(substitute_all(map)))
|
||||||
} else {
|
} else {
|
||||||
inherited.clone()
|
inherited.clone()
|
||||||
}
|
}
|
||||||
|
@ -555,8 +555,7 @@ fn remove_cycles(map: &mut OrderedMap<&Name, BorrowedSpecifiedValue>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Replace `var()` functions for all custom properties.
|
/// Replace `var()` functions for all custom properties.
|
||||||
fn substitute_all(specified_values_map: OrderedMap<&Name, BorrowedSpecifiedValue>,
|
fn substitute_all(specified_values_map: OrderedMap<&Name, BorrowedSpecifiedValue>)
|
||||||
inherited: &Option<Arc<CustomPropertiesMap>>)
|
|
||||||
-> CustomPropertiesMap {
|
-> CustomPropertiesMap {
|
||||||
let mut custom_properties_map = CustomPropertiesMap::new();
|
let mut custom_properties_map = CustomPropertiesMap::new();
|
||||||
let mut invalid = HashSet::new();
|
let mut invalid = HashSet::new();
|
||||||
|
@ -566,7 +565,7 @@ fn substitute_all(specified_values_map: OrderedMap<&Name, BorrowedSpecifiedValue
|
||||||
// If this value is invalid at computed-time it won’t be inserted in computed_values_map.
|
// If this value is invalid at computed-time it won’t be inserted in computed_values_map.
|
||||||
// Nothing else to do.
|
// Nothing else to do.
|
||||||
let _ = substitute_one(
|
let _ = substitute_one(
|
||||||
name, value, &specified_values_map, inherited, None,
|
name, value, &specified_values_map, None,
|
||||||
&mut custom_properties_map, &mut invalid);
|
&mut custom_properties_map, &mut invalid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -580,7 +579,6 @@ fn substitute_all(specified_values_map: OrderedMap<&Name, BorrowedSpecifiedValue
|
||||||
fn substitute_one(name: &Name,
|
fn substitute_one(name: &Name,
|
||||||
specified_value: &BorrowedSpecifiedValue,
|
specified_value: &BorrowedSpecifiedValue,
|
||||||
specified_values_map: &OrderedMap<&Name, BorrowedSpecifiedValue>,
|
specified_values_map: &OrderedMap<&Name, BorrowedSpecifiedValue>,
|
||||||
inherited: &Option<Arc<CustomPropertiesMap>>,
|
|
||||||
partial_computed_value: Option<&mut ComputedValue>,
|
partial_computed_value: Option<&mut ComputedValue>,
|
||||||
custom_properties_map: &mut CustomPropertiesMap,
|
custom_properties_map: &mut CustomPropertiesMap,
|
||||||
invalid: &mut HashSet<Name>)
|
invalid: &mut HashSet<Name>)
|
||||||
|
@ -604,7 +602,7 @@ fn substitute_one(name: &Name,
|
||||||
&mut input, &mut position, &mut partial_computed_value,
|
&mut input, &mut position, &mut partial_computed_value,
|
||||||
&mut |name, partial_computed_value| {
|
&mut |name, partial_computed_value| {
|
||||||
if let Some(other_specified_value) = specified_values_map.get(&name) {
|
if let Some(other_specified_value) = specified_values_map.get(&name) {
|
||||||
substitute_one(name, other_specified_value, specified_values_map, inherited,
|
substitute_one(name, other_specified_value, specified_values_map,
|
||||||
Some(partial_computed_value), custom_properties_map, invalid)
|
Some(partial_computed_value), custom_properties_map, invalid)
|
||||||
} else {
|
} else {
|
||||||
Err(())
|
Err(())
|
||||||
|
@ -615,13 +613,8 @@ fn substitute_one(name: &Name,
|
||||||
partial_computed_value.push_from(position, &input, last_token_type);
|
partial_computed_value.push_from(position, &input, last_token_type);
|
||||||
partial_computed_value
|
partial_computed_value
|
||||||
} else {
|
} else {
|
||||||
// Invalid at computed-value time. Use the inherited value.
|
invalid.insert(name.clone());
|
||||||
if let Some(inherited_value) = inherited.as_ref().and_then(|i| i.values.get(name)) {
|
return Err(())
|
||||||
inherited_value.clone()
|
|
||||||
} else {
|
|
||||||
invalid.insert(name.clone());
|
|
||||||
return Err(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// The specified value contains no var() reference
|
// The specified value contains no var() reference
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue