mirror of
https://github.com/servo/servo.git
synced 2025-06-25 09:34:32 +01:00
Remove now-redundant Arc inside PropertyDeclarationBlock.
This commit is contained in:
parent
acc38aa8c2
commit
ad3437b98a
6 changed files with 23 additions and 26 deletions
|
@ -330,7 +330,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
|
||||||
fn from_declaration(rule: PropertyDeclaration) -> DeclarationBlock {
|
fn from_declaration(rule: PropertyDeclaration) -> DeclarationBlock {
|
||||||
DeclarationBlock::from_declarations(
|
DeclarationBlock::from_declarations(
|
||||||
Arc::new(PropertyDeclarationBlock {
|
Arc::new(PropertyDeclarationBlock {
|
||||||
declarations: Arc::new(vec![(rule, Importance::Normal)]),
|
declarations: vec![(rule, Importance::Normal)],
|
||||||
important_count: 0,
|
important_count: 0,
|
||||||
}),
|
}),
|
||||||
Importance::Normal)
|
Importance::Normal)
|
||||||
|
@ -778,7 +778,7 @@ impl Element {
|
||||||
});
|
});
|
||||||
if let Some(index) = index {
|
if let Some(index) = index {
|
||||||
let declarations = Arc::make_mut(declarations);
|
let declarations = Arc::make_mut(declarations);
|
||||||
Arc::make_mut(&mut declarations.declarations).remove(index);
|
declarations.declarations.remove(index);
|
||||||
if importance.unwrap().important() {
|
if importance.unwrap().important() {
|
||||||
declarations.important_count -= 1;
|
declarations.important_count -= 1;
|
||||||
}
|
}
|
||||||
|
@ -801,7 +801,7 @@ impl Element {
|
||||||
// Usually, the reference count will be 1 here. But transitions could make it greater
|
// Usually, the reference count will be 1 here. But transitions could make it greater
|
||||||
// than that.
|
// than that.
|
||||||
let declaration_block = Arc::make_mut(declaration_block);
|
let declaration_block = Arc::make_mut(declaration_block);
|
||||||
let existing_declarations = Arc::make_mut(&mut declaration_block.declarations);
|
let existing_declarations = &mut declaration_block.declarations;
|
||||||
|
|
||||||
'outer: for incoming_declaration in declarations {
|
'outer: for incoming_declaration in declarations {
|
||||||
for existing_declaration in &mut *existing_declarations {
|
for existing_declaration in &mut *existing_declarations {
|
||||||
|
@ -835,7 +835,7 @@ impl Element {
|
||||||
};
|
};
|
||||||
|
|
||||||
*inline_declarations = Some(Arc::new(PropertyDeclarationBlock {
|
*inline_declarations = Some(Arc::new(PropertyDeclarationBlock {
|
||||||
declarations: Arc::new(declarations.into_iter().map(|d| (d, importance)).collect()),
|
declarations: declarations.into_iter().map(|d| (d, importance)).collect(),
|
||||||
important_count: important_count,
|
important_count: important_count,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -853,7 +853,7 @@ impl Element {
|
||||||
// Usually, the reference counts of `from` and `to` will be 1 here. But transitions
|
// Usually, the reference counts of `from` and `to` will be 1 here. But transitions
|
||||||
// could make them greater than that.
|
// could make them greater than that.
|
||||||
let block = Arc::make_mut(block);
|
let block = Arc::make_mut(block);
|
||||||
let declarations = Arc::make_mut(&mut block.declarations);
|
let declarations = &mut block.declarations;
|
||||||
for &mut (ref declaration, ref mut importance) in declarations {
|
for &mut (ref declaration, ref mut importance) in declarations {
|
||||||
if properties.iter().any(|p| declaration.name() == **p) {
|
if properties.iter().any(|p| declaration.name() == **p) {
|
||||||
match (*importance, new_importance) {
|
match (*importance, new_importance) {
|
||||||
|
|
|
@ -266,7 +266,7 @@ impl<'a> QualifiedRuleParser for KeyframeListParser<'a> {
|
||||||
Ok(Arc::new(Keyframe {
|
Ok(Arc::new(Keyframe {
|
||||||
selector: prelude,
|
selector: prelude,
|
||||||
block: Arc::new(PropertyDeclarationBlock {
|
block: Arc::new(PropertyDeclarationBlock {
|
||||||
declarations: Arc::new(declarations),
|
declarations: declarations,
|
||||||
important_count: 0,
|
important_count: 0,
|
||||||
}),
|
}),
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -286,7 +286,7 @@ impl Importance {
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
pub struct PropertyDeclarationBlock {
|
pub struct PropertyDeclarationBlock {
|
||||||
#[cfg_attr(feature = "servo", ignore_heap_size_of = "#7038")]
|
#[cfg_attr(feature = "servo", ignore_heap_size_of = "#7038")]
|
||||||
pub declarations: Arc<Vec<(PropertyDeclaration, Importance)>>,
|
pub declarations: Vec<(PropertyDeclaration, Importance)>,
|
||||||
|
|
||||||
/// The number of entries in `self.declaration` with `Importance::Important`
|
/// The number of entries in `self.declaration` with `Importance::Important`
|
||||||
pub important_count: u32,
|
pub important_count: u32,
|
||||||
|
@ -567,7 +567,7 @@ pub fn parse_property_declaration_list(context: &ParserContext, input: &mut Pars
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut block = PropertyDeclarationBlock {
|
let mut block = PropertyDeclarationBlock {
|
||||||
declarations: Arc::new(declarations),
|
declarations: declarations,
|
||||||
important_count: important_count,
|
important_count: important_count,
|
||||||
};
|
};
|
||||||
deduplicate_property_declarations(&mut block);
|
deduplicate_property_declarations(&mut block);
|
||||||
|
@ -583,8 +583,7 @@ fn deduplicate_property_declarations(block: &mut PropertyDeclarationBlock) {
|
||||||
let mut seen_custom_normal = Vec::new();
|
let mut seen_custom_normal = Vec::new();
|
||||||
let mut seen_custom_important = Vec::new();
|
let mut seen_custom_important = Vec::new();
|
||||||
|
|
||||||
let declarations = Arc::get_mut(&mut block.declarations).unwrap();
|
for (declaration, importance) in block.declarations.drain(..).rev() {
|
||||||
for (declaration, importance) in declarations.drain(..).rev() {
|
|
||||||
match declaration {
|
match declaration {
|
||||||
% for property in data.longhands:
|
% for property in data.longhands:
|
||||||
PropertyDeclaration::${property.camel_case}(..) => {
|
PropertyDeclaration::${property.camel_case}(..) => {
|
||||||
|
@ -636,7 +635,7 @@ fn deduplicate_property_declarations(block: &mut PropertyDeclarationBlock) {
|
||||||
deduplicated.push((declaration, importance))
|
deduplicated.push((declaration, importance))
|
||||||
}
|
}
|
||||||
deduplicated.reverse();
|
deduplicated.reverse();
|
||||||
*declarations = deduplicated;
|
block.declarations = deduplicated;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -45,8 +45,7 @@ fn property_declaration_block_should_serialize_correctly() {
|
||||||
];
|
];
|
||||||
|
|
||||||
let block = PropertyDeclarationBlock {
|
let block = PropertyDeclarationBlock {
|
||||||
declarations: Arc::new(declarations),
|
declarations: declarations,
|
||||||
|
|
||||||
important_count: 0,
|
important_count: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -63,8 +62,7 @@ mod shorthand_serialization {
|
||||||
|
|
||||||
pub fn shorthand_properties_to_string(properties: Vec<PropertyDeclaration>) -> String {
|
pub fn shorthand_properties_to_string(properties: Vec<PropertyDeclaration>) -> String {
|
||||||
let block = PropertyDeclarationBlock {
|
let block = PropertyDeclarationBlock {
|
||||||
declarations: Arc::new(properties.into_iter().map(|d| (d, Importance::Normal)).collect()),
|
declarations: properties.into_iter().map(|d| (d, Importance::Normal)).collect(),
|
||||||
|
|
||||||
important_count: 0,
|
important_count: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ fn get_mock_rules(css_selectors: &[&str]) -> Vec<Vec<Rule>> {
|
||||||
selector: s.complex_selector.clone(),
|
selector: s.complex_selector.clone(),
|
||||||
declarations: DeclarationBlock {
|
declarations: DeclarationBlock {
|
||||||
mixed_declarations: Arc::new(PropertyDeclarationBlock {
|
mixed_declarations: Arc::new(PropertyDeclarationBlock {
|
||||||
declarations: Arc::new(Vec::new()),
|
declarations: Vec::new(),
|
||||||
important_count: 0,
|
important_count: 0,
|
||||||
}),
|
}),
|
||||||
importance: Importance::Normal,
|
importance: Importance::Normal,
|
||||||
|
|
|
@ -98,13 +98,13 @@ fn test_parse_stylesheet() {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
declarations: Arc::new(PropertyDeclarationBlock {
|
declarations: Arc::new(PropertyDeclarationBlock {
|
||||||
declarations: Arc::new(vec![
|
declarations: vec![
|
||||||
(PropertyDeclaration::Display(DeclaredValue::Value(
|
(PropertyDeclaration::Display(DeclaredValue::Value(
|
||||||
longhands::display::SpecifiedValue::none)),
|
longhands::display::SpecifiedValue::none)),
|
||||||
Importance::Important),
|
Importance::Important),
|
||||||
(PropertyDeclaration::Custom(Atom::from("a"), DeclaredValue::Inherit),
|
(PropertyDeclaration::Custom(Atom::from("a"), DeclaredValue::Inherit),
|
||||||
Importance::Important),
|
Importance::Important),
|
||||||
]),
|
],
|
||||||
important_count: 2,
|
important_count: 2,
|
||||||
}),
|
}),
|
||||||
})),
|
})),
|
||||||
|
@ -146,11 +146,11 @@ fn test_parse_stylesheet() {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
declarations: Arc::new(PropertyDeclarationBlock {
|
declarations: Arc::new(PropertyDeclarationBlock {
|
||||||
declarations: Arc::new(vec![
|
declarations: vec![
|
||||||
(PropertyDeclaration::Display(DeclaredValue::Value(
|
(PropertyDeclaration::Display(DeclaredValue::Value(
|
||||||
longhands::display::SpecifiedValue::block)),
|
longhands::display::SpecifiedValue::block)),
|
||||||
Importance::Normal),
|
Importance::Normal),
|
||||||
]),
|
],
|
||||||
important_count: 0,
|
important_count: 0,
|
||||||
}),
|
}),
|
||||||
})),
|
})),
|
||||||
|
@ -181,7 +181,7 @@ fn test_parse_stylesheet() {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
declarations: Arc::new(PropertyDeclarationBlock {
|
declarations: Arc::new(PropertyDeclarationBlock {
|
||||||
declarations: Arc::new(vec![
|
declarations: vec![
|
||||||
(PropertyDeclaration::BackgroundColor(DeclaredValue::Value(
|
(PropertyDeclaration::BackgroundColor(DeclaredValue::Value(
|
||||||
longhands::background_color::SpecifiedValue {
|
longhands::background_color::SpecifiedValue {
|
||||||
authored: Some("blue".to_owned()),
|
authored: Some("blue".to_owned()),
|
||||||
|
@ -226,7 +226,7 @@ fn test_parse_stylesheet() {
|
||||||
vec![longhands::background_clip::single_value
|
vec![longhands::background_clip::single_value
|
||||||
::get_initial_specified_value()]))),
|
::get_initial_specified_value()]))),
|
||||||
Importance::Normal),
|
Importance::Normal),
|
||||||
]),
|
],
|
||||||
important_count: 0,
|
important_count: 0,
|
||||||
}),
|
}),
|
||||||
})),
|
})),
|
||||||
|
@ -237,11 +237,11 @@ fn test_parse_stylesheet() {
|
||||||
selector: KeyframeSelector::new_for_unit_testing(
|
selector: KeyframeSelector::new_for_unit_testing(
|
||||||
vec![KeyframePercentage::new(0.)]),
|
vec![KeyframePercentage::new(0.)]),
|
||||||
block: Arc::new(PropertyDeclarationBlock {
|
block: Arc::new(PropertyDeclarationBlock {
|
||||||
declarations: Arc::new(vec![
|
declarations: vec![
|
||||||
(PropertyDeclaration::Width(DeclaredValue::Value(
|
(PropertyDeclaration::Width(DeclaredValue::Value(
|
||||||
LengthOrPercentageOrAuto::Percentage(Percentage(0.)))),
|
LengthOrPercentageOrAuto::Percentage(Percentage(0.)))),
|
||||||
Importance::Normal),
|
Importance::Normal),
|
||||||
]),
|
],
|
||||||
important_count: 0,
|
important_count: 0,
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
|
@ -249,7 +249,7 @@ fn test_parse_stylesheet() {
|
||||||
selector: KeyframeSelector::new_for_unit_testing(
|
selector: KeyframeSelector::new_for_unit_testing(
|
||||||
vec![KeyframePercentage::new(1.)]),
|
vec![KeyframePercentage::new(1.)]),
|
||||||
block: Arc::new(PropertyDeclarationBlock {
|
block: Arc::new(PropertyDeclarationBlock {
|
||||||
declarations: Arc::new(vec![
|
declarations: vec![
|
||||||
(PropertyDeclaration::Width(DeclaredValue::Value(
|
(PropertyDeclaration::Width(DeclaredValue::Value(
|
||||||
LengthOrPercentageOrAuto::Percentage(Percentage(1.)))),
|
LengthOrPercentageOrAuto::Percentage(Percentage(1.)))),
|
||||||
Importance::Normal),
|
Importance::Normal),
|
||||||
|
@ -257,7 +257,7 @@ fn test_parse_stylesheet() {
|
||||||
animation_play_state::SpecifiedValue(
|
animation_play_state::SpecifiedValue(
|
||||||
vec![animation_play_state::SingleSpecifiedValue::running]))),
|
vec![animation_play_state::SingleSpecifiedValue::running]))),
|
||||||
Importance::Normal),
|
Importance::Normal),
|
||||||
]),
|
],
|
||||||
important_count: 0,
|
important_count: 0,
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue