diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index a38367f23cc5..e0342ebc3a6c 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -330,7 +330,7 @@ impl LayoutElementHelpers for LayoutJS { fn from_declaration(rule: PropertyDeclaration) -> DeclarationBlock { DeclarationBlock::from_declarations( Arc::new(PropertyDeclarationBlock { - declarations: Arc::new(vec![(rule, Importance::Normal)]), + declarations: vec![(rule, Importance::Normal)], important_count: 0, }), Importance::Normal) @@ -778,7 +778,7 @@ impl Element { }); if let Some(index) = index { let declarations = Arc::make_mut(declarations); - Arc::make_mut(&mut declarations.declarations).remove(index); + declarations.declarations.remove(index); if importance.unwrap().important() { declarations.important_count -= 1; } @@ -801,7 +801,7 @@ impl Element { // Usually, the reference count will be 1 here. But transitions could make it greater // than that. 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 { for existing_declaration in &mut *existing_declarations { @@ -835,7 +835,7 @@ impl Element { }; *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, })); } @@ -853,7 +853,7 @@ impl Element { // Usually, the reference counts of `from` and `to` will be 1 here. But transitions // could make them greater than that. 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 { if properties.iter().any(|p| declaration.name() == **p) { match (*importance, new_importance) { diff --git a/components/style/keyframes.rs b/components/style/keyframes.rs index 266dd04a5915..d5ee58157b42 100644 --- a/components/style/keyframes.rs +++ b/components/style/keyframes.rs @@ -266,7 +266,7 @@ impl<'a> QualifiedRuleParser for KeyframeListParser<'a> { Ok(Arc::new(Keyframe { selector: prelude, block: Arc::new(PropertyDeclarationBlock { - declarations: Arc::new(declarations), + declarations: declarations, important_count: 0, }), })) diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 2b70561b23b0..c8be3470edeb 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -286,7 +286,7 @@ impl Importance { #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct PropertyDeclarationBlock { #[cfg_attr(feature = "servo", ignore_heap_size_of = "#7038")] - pub declarations: Arc>, + pub declarations: Vec<(PropertyDeclaration, Importance)>, /// The number of entries in `self.declaration` with `Importance::Important` pub important_count: u32, @@ -567,7 +567,7 @@ pub fn parse_property_declaration_list(context: &ParserContext, input: &mut Pars } } let mut block = PropertyDeclarationBlock { - declarations: Arc::new(declarations), + declarations: declarations, important_count: important_count, }; 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_important = Vec::new(); - let declarations = Arc::get_mut(&mut block.declarations).unwrap(); - for (declaration, importance) in declarations.drain(..).rev() { + for (declaration, importance) in block.declarations.drain(..).rev() { match declaration { % for property in data.longhands: PropertyDeclaration::${property.camel_case}(..) => { @@ -636,7 +635,7 @@ fn deduplicate_property_declarations(block: &mut PropertyDeclarationBlock) { deduplicated.push((declaration, importance)) } deduplicated.reverse(); - *declarations = deduplicated; + block.declarations = deduplicated; } #[inline] diff --git a/tests/unit/style/properties/serialization.rs b/tests/unit/style/properties/serialization.rs index b802c5c4fbf8..c43fc5e93c1c 100644 --- a/tests/unit/style/properties/serialization.rs +++ b/tests/unit/style/properties/serialization.rs @@ -45,8 +45,7 @@ fn property_declaration_block_should_serialize_correctly() { ]; let block = PropertyDeclarationBlock { - declarations: Arc::new(declarations), - + declarations: declarations, important_count: 0, }; @@ -63,8 +62,7 @@ mod shorthand_serialization { pub fn shorthand_properties_to_string(properties: Vec) -> String { 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, }; diff --git a/tests/unit/style/selector_matching.rs b/tests/unit/style/selector_matching.rs index d11ebb99907a..63a219ecd5e9 100644 --- a/tests/unit/style/selector_matching.rs +++ b/tests/unit/style/selector_matching.rs @@ -20,7 +20,7 @@ fn get_mock_rules(css_selectors: &[&str]) -> Vec> { selector: s.complex_selector.clone(), declarations: DeclarationBlock { mixed_declarations: Arc::new(PropertyDeclarationBlock { - declarations: Arc::new(Vec::new()), + declarations: Vec::new(), important_count: 0, }), importance: Importance::Normal, diff --git a/tests/unit/style/stylesheets.rs b/tests/unit/style/stylesheets.rs index bf57f19a0667..802ffb52f844 100644 --- a/tests/unit/style/stylesheets.rs +++ b/tests/unit/style/stylesheets.rs @@ -98,13 +98,13 @@ fn test_parse_stylesheet() { }, ], declarations: Arc::new(PropertyDeclarationBlock { - declarations: Arc::new(vec![ + declarations: vec![ (PropertyDeclaration::Display(DeclaredValue::Value( longhands::display::SpecifiedValue::none)), Importance::Important), (PropertyDeclaration::Custom(Atom::from("a"), DeclaredValue::Inherit), Importance::Important), - ]), + ], important_count: 2, }), })), @@ -146,11 +146,11 @@ fn test_parse_stylesheet() { }, ], declarations: Arc::new(PropertyDeclarationBlock { - declarations: Arc::new(vec![ + declarations: vec![ (PropertyDeclaration::Display(DeclaredValue::Value( longhands::display::SpecifiedValue::block)), Importance::Normal), - ]), + ], important_count: 0, }), })), @@ -181,7 +181,7 @@ fn test_parse_stylesheet() { }, ], declarations: Arc::new(PropertyDeclarationBlock { - declarations: Arc::new(vec![ + declarations: vec![ (PropertyDeclaration::BackgroundColor(DeclaredValue::Value( longhands::background_color::SpecifiedValue { authored: Some("blue".to_owned()), @@ -226,7 +226,7 @@ fn test_parse_stylesheet() { vec![longhands::background_clip::single_value ::get_initial_specified_value()]))), Importance::Normal), - ]), + ], important_count: 0, }), })), @@ -237,11 +237,11 @@ fn test_parse_stylesheet() { selector: KeyframeSelector::new_for_unit_testing( vec![KeyframePercentage::new(0.)]), block: Arc::new(PropertyDeclarationBlock { - declarations: Arc::new(vec![ + declarations: vec![ (PropertyDeclaration::Width(DeclaredValue::Value( LengthOrPercentageOrAuto::Percentage(Percentage(0.)))), Importance::Normal), - ]), + ], important_count: 0, }) }), @@ -249,7 +249,7 @@ fn test_parse_stylesheet() { selector: KeyframeSelector::new_for_unit_testing( vec![KeyframePercentage::new(1.)]), block: Arc::new(PropertyDeclarationBlock { - declarations: Arc::new(vec![ + declarations: vec![ (PropertyDeclaration::Width(DeclaredValue::Value( LengthOrPercentageOrAuto::Percentage(Percentage(1.)))), Importance::Normal), @@ -257,7 +257,7 @@ fn test_parse_stylesheet() { animation_play_state::SpecifiedValue( vec![animation_play_state::SingleSpecifiedValue::running]))), Importance::Normal), - ]), + ], important_count: 0, }), }),