mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
style: Avoid being so Arc-happy in the custom properties code.
This commit is contained in:
parent
65d9b345bb
commit
2adfd84636
7 changed files with 88 additions and 79 deletions
|
@ -152,7 +152,7 @@ pub struct AnimationValueIterator<'a, 'cx, 'cx_a:'cx> {
|
|||
context: &'cx mut Context<'cx_a>,
|
||||
default_values: &'a ComputedValues,
|
||||
/// Custom properties in a keyframe if exists.
|
||||
extra_custom_properties: &'a Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
||||
extra_custom_properties: Option<&'a Arc<::custom_properties::CustomPropertiesMap>>,
|
||||
}
|
||||
|
||||
impl<'a, 'cx, 'cx_a:'cx> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
||||
|
@ -160,7 +160,7 @@ impl<'a, 'cx, 'cx_a:'cx> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
|||
declarations: &'a PropertyDeclarationBlock,
|
||||
context: &'cx mut Context<'cx_a>,
|
||||
default_values: &'a ComputedValues,
|
||||
extra_custom_properties: &'a Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
||||
extra_custom_properties: Option<&'a Arc<::custom_properties::CustomPropertiesMap>>,
|
||||
) -> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
||||
AnimationValueIterator {
|
||||
iter: declarations.declaration_importance_iter(),
|
||||
|
@ -259,7 +259,7 @@ impl PropertyDeclarationBlock {
|
|||
&'a self,
|
||||
context: &'cx mut Context<'cx_a>,
|
||||
default_values: &'a ComputedValues,
|
||||
extra_custom_properties: &'a Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
||||
extra_custom_properties: Option<&'a Arc<::custom_properties::CustomPropertiesMap>>,
|
||||
) -> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
||||
AnimationValueIterator::new(self, context, default_values, extra_custom_properties)
|
||||
}
|
||||
|
@ -592,12 +592,14 @@ impl PropertyDeclarationBlock {
|
|||
if self.declarations.len() == 1 {
|
||||
let declaration = &self.declarations[0];
|
||||
let custom_properties = if let Some(cv) = computed_values {
|
||||
// If there are extra custom properties for this declaration block,
|
||||
// factor them in too.
|
||||
// If there are extra custom properties for this
|
||||
// declaration block, factor them in too.
|
||||
if let Some(block) = custom_properties_block {
|
||||
// FIXME(emilio): This is not super-efficient
|
||||
// here...
|
||||
block.cascade_custom_properties(cv.custom_properties())
|
||||
} else {
|
||||
cv.custom_properties()
|
||||
cv.custom_properties().cloned()
|
||||
}
|
||||
} else {
|
||||
None
|
||||
|
@ -610,13 +612,14 @@ impl PropertyDeclarationBlock {
|
|||
// |computed_values| is supplied, we use it to expand such variable
|
||||
// declarations. This will be fixed properly in Gecko bug 1391537.
|
||||
(&PropertyDeclaration::WithVariables(id, ref unparsed),
|
||||
Some(ref _computed_values)) => unparsed
|
||||
.substitute_variables(
|
||||
Some(ref _computed_values)) => {
|
||||
unparsed.substitute_variables(
|
||||
id,
|
||||
&custom_properties,
|
||||
custom_properties.as_ref(),
|
||||
QuirksMode::NoQuirks,
|
||||
)
|
||||
.to_css(dest),
|
||||
.to_css(dest)
|
||||
},
|
||||
(ref d, _) => d.to_css(dest),
|
||||
}
|
||||
} else {
|
||||
|
@ -690,7 +693,7 @@ impl PropertyDeclarationBlock {
|
|||
/// properties.
|
||||
pub fn cascade_custom_properties(
|
||||
&self,
|
||||
inherited_custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
||||
inherited_custom_properties: Option<&Arc<::custom_properties::CustomPropertiesMap>>,
|
||||
) -> Option<Arc<::custom_properties::CustomPropertiesMap>> {
|
||||
let mut custom_properties = None;
|
||||
let mut seen_custom = PrecomputedHashSet::default();
|
||||
|
@ -698,12 +701,18 @@ impl PropertyDeclarationBlock {
|
|||
for declaration in self.normal_declaration_iter() {
|
||||
if let PropertyDeclaration::Custom(ref name, ref value) = *declaration {
|
||||
::custom_properties::cascade(
|
||||
&mut custom_properties, &inherited_custom_properties,
|
||||
&mut seen_custom, name, value.borrow());
|
||||
&mut custom_properties,
|
||||
inherited_custom_properties,
|
||||
&mut seen_custom,
|
||||
name,
|
||||
value.borrow(),
|
||||
);
|
||||
}
|
||||
}
|
||||
::custom_properties::finish_cascade(
|
||||
custom_properties, &inherited_custom_properties)
|
||||
custom_properties,
|
||||
inherited_custom_properties,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue