Auto merge of #13134 - servo:archery, r=emilio

Add lots of Arc’s in style, and prepare for using DOMRefCell

<!-- Please describe your changes on the following line: -->

`DOMRefCell` usage is not there year because of thread-safety questions, but I have this much already that I’d like to land before it bitrots.

r? @emilio

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require new tests because refactor

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13134)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-08-31 16:30:56 -05:00 committed by GitHub
commit bbfe38e35f
29 changed files with 487 additions and 246 deletions

View file

@ -40,10 +40,10 @@ macro_rules! sizeof_checker (
// Update the sizes here
sizeof_checker!(size_event_target, EventTarget, 40);
sizeof_checker!(size_node, Node, 152);
sizeof_checker!(size_element, Element, 328);
sizeof_checker!(size_htmlelement, HTMLElement, 344);
sizeof_checker!(size_div, HTMLDivElement, 344);
sizeof_checker!(size_span, HTMLSpanElement, 344);
sizeof_checker!(size_element, Element, 320);
sizeof_checker!(size_htmlelement, HTMLElement, 336);
sizeof_checker!(size_div, HTMLDivElement, 336);
sizeof_checker!(size_span, HTMLSpanElement, 336);
sizeof_checker!(size_text, Text, 184);
sizeof_checker!(size_characterdata, CharacterData, 184);
sizeof_checker!(size_servothreadsafelayoutnode, ServoThreadSafeLayoutNode, 16);

View file

@ -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<PropertyDeclaration>) -> 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,
};

View file

@ -6,7 +6,7 @@ use cssparser::Parser;
use selectors::parser::{LocalName, ParserContext, parse_selector_list};
use std::sync::Arc;
use string_cache::Atom;
use style::properties::Importance;
use style::properties::{Importance, PropertyDeclarationBlock};
use style::selector_matching::{DeclarationBlock, Rule, SelectorMap};
/// Helper method to get some Rules from selector strings.
@ -19,7 +19,10 @@ fn get_mock_rules(css_selectors: &[&str]) -> Vec<Vec<Rule>> {
Rule {
selector: s.complex_selector.clone(),
declarations: DeclarationBlock {
mixed_declarations: Arc::new(Vec::new()),
mixed_declarations: Arc::new(PropertyDeclarationBlock {
declarations: Vec::new(),
important_count: 0,
}),
importance: Importance::Normal,
specificity: s.specificity,
source_order: i,

View file

@ -15,7 +15,7 @@ use style::parser::ParserContextExtraData;
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, DeclaredValue, longhands};
use style::properties::Importance;
use style::properties::longhands::animation_play_state;
use style::stylesheets::{Stylesheet, CSSRule, StyleRule, KeyframesRule, Origin};
use style::stylesheets::{Stylesheet, NamespaceRule, CSSRule, StyleRule, KeyframesRule, Origin};
use style::values::specified::{LengthOrPercentageOrAuto, Percentage};
use url::Url;
@ -65,11 +65,11 @@ fn test_parse_stylesheet() {
media: None,
dirty_on_viewport_size_change: false,
rules: vec![
CSSRule::Namespace {
CSSRule::Namespace(Arc::new(NamespaceRule {
prefix: None,
url: NsAtom(Atom::from("http://www.w3.org/1999/xhtml"))
},
CSSRule::Style(StyleRule {
})),
CSSRule::Style(Arc::new(StyleRule {
selectors: vec![
Selector {
complex_selector: Arc::new(ComplexSelector {
@ -97,18 +97,18 @@ fn test_parse_stylesheet() {
specificity: (0 << 20) + (1 << 10) + (1 << 0),
},
],
declarations: PropertyDeclarationBlock {
declarations: Arc::new(vec![
declarations: Arc::new(PropertyDeclarationBlock {
declarations: vec![
(PropertyDeclaration::Display(DeclaredValue::Value(
longhands::display::SpecifiedValue::none)),
Importance::Important),
(PropertyDeclaration::Custom(Atom::from("a"), DeclaredValue::Inherit),
Importance::Important),
]),
],
important_count: 2,
},
}),
CSSRule::Style(StyleRule {
}),
})),
CSSRule::Style(Arc::new(StyleRule {
selectors: vec![
Selector {
complex_selector: Arc::new(ComplexSelector {
@ -145,16 +145,16 @@ fn test_parse_stylesheet() {
specificity: (0 << 20) + (0 << 10) + (1 << 0),
},
],
declarations: PropertyDeclarationBlock {
declarations: Arc::new(vec![
declarations: Arc::new(PropertyDeclarationBlock {
declarations: vec![
(PropertyDeclaration::Display(DeclaredValue::Value(
longhands::display::SpecifiedValue::block)),
Importance::Normal),
]),
],
important_count: 0,
},
}),
CSSRule::Style(StyleRule {
}),
})),
CSSRule::Style(Arc::new(StyleRule {
selectors: vec![
Selector {
complex_selector: Arc::new(ComplexSelector {
@ -180,8 +180,8 @@ fn test_parse_stylesheet() {
specificity: (1 << 20) + (1 << 10) + (0 << 0),
},
],
declarations: PropertyDeclarationBlock {
declarations: Arc::new(vec![
declarations: Arc::new(PropertyDeclarationBlock {
declarations: vec![
(PropertyDeclaration::BackgroundColor(DeclaredValue::Value(
longhands::background_color::SpecifiedValue {
authored: Some("blue".to_owned()),
@ -226,37 +226,43 @@ fn test_parse_stylesheet() {
vec![longhands::background_clip::single_value
::get_initial_specified_value()]))),
Importance::Normal),
]),
],
important_count: 0,
},
}),
CSSRule::Keyframes(KeyframesRule {
}),
})),
CSSRule::Keyframes(Arc::new(KeyframesRule {
name: "foo".into(),
keyframes: vec![
Keyframe {
Arc::new(Keyframe {
selector: KeyframeSelector::new_for_unit_testing(
vec![KeyframePercentage::new(0.)]),
declarations: Arc::new(vec![
(PropertyDeclaration::Width(DeclaredValue::Value(
LengthOrPercentageOrAuto::Percentage(Percentage(0.)))),
Importance::Normal),
]),
},
Keyframe {
block: Arc::new(PropertyDeclarationBlock {
declarations: vec![
(PropertyDeclaration::Width(DeclaredValue::Value(
LengthOrPercentageOrAuto::Percentage(Percentage(0.)))),
Importance::Normal),
],
important_count: 0,
})
}),
Arc::new(Keyframe {
selector: KeyframeSelector::new_for_unit_testing(
vec![KeyframePercentage::new(1.)]),
declarations: Arc::new(vec![
(PropertyDeclaration::Width(DeclaredValue::Value(
LengthOrPercentageOrAuto::Percentage(Percentage(1.)))),
Importance::Normal),
(PropertyDeclaration::AnimationPlayState(DeclaredValue::Value(
animation_play_state::SpecifiedValue(
vec![animation_play_state::SingleSpecifiedValue::running]))),
Importance::Normal),
]),
},
block: Arc::new(PropertyDeclarationBlock {
declarations: vec![
(PropertyDeclaration::Width(DeclaredValue::Value(
LengthOrPercentageOrAuto::Percentage(Percentage(1.)))),
Importance::Normal),
(PropertyDeclaration::AnimationPlayState(DeclaredValue::Value(
animation_play_state::SpecifiedValue(
vec![animation_play_state::SingleSpecifiedValue::running]))),
Importance::Normal),
],
important_count: 0,
}),
}),
]
})
}))
],
});