aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/cssstyledeclaration.rs10
-rw-r--r--components/script/dom/element.rs7
-rw-r--r--components/style/properties/declaration_block.rs10
-rw-r--r--components/style/properties/gecko.mako.rs30
-rw-r--r--ports/geckolib/glue.rs15
-rw-r--r--tests/unit/style/keyframes.rs107
-rw-r--r--tests/unit/style/properties/serialization.rs21
-rw-r--r--tests/unit/style/rule_tree/bench.rs13
-rw-r--r--tests/unit/style/stylesheets.rs176
-rw-r--r--tests/unit/style/stylist.rs13
10 files changed, 183 insertions, 219 deletions
diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs
index 450d0b7da4b..dc53a58c8c5 100644
--- a/components/script/dom/cssstyledeclaration.rs
+++ b/components/script/dom/cssstyledeclaration.rs
@@ -62,10 +62,7 @@ impl CSSStyleOwner {
let result = f(&mut pdb, &mut changed);
result
} else {
- let mut pdb = PropertyDeclarationBlock {
- important_count: 0,
- declarations: vec![],
- };
+ let mut pdb = PropertyDeclarationBlock::new();
let result = f(&mut pdb, &mut changed);
// Here `changed` is somewhat silly, because we know the
@@ -116,10 +113,7 @@ impl CSSStyleOwner {
match *el.style_attribute().borrow() {
Some(ref pdb) => f(&pdb.read()),
None => {
- let pdb = PropertyDeclarationBlock {
- important_count: 0,
- declarations: vec![],
- };
+ let pdb = PropertyDeclarationBlock::new();
f(&pdb)
}
}
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index eeff67ed318..a0fb1d0f179 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -385,10 +385,9 @@ impl LayoutElementHelpers for LayoutJS<Element> {
#[inline]
fn from_declaration(declaration: PropertyDeclaration) -> ApplicableDeclarationBlock {
ApplicableDeclarationBlock::from_declarations(
- Arc::new(RwLock::new(PropertyDeclarationBlock {
- declarations: vec![(declaration, Importance::Normal)],
- important_count: 0,
- })),
+ Arc::new(RwLock::new(PropertyDeclarationBlock::with_one(
+ declaration, Importance::Normal
+ ))),
CascadeLevel::PresHints)
}
diff --git a/components/style/properties/declaration_block.rs b/components/style/properties/declaration_block.rs
index 683aa580e1a..a88fee2856e 100644
--- a/components/style/properties/declaration_block.rs
+++ b/components/style/properties/declaration_block.rs
@@ -56,7 +56,7 @@ pub struct PropertyDeclarationBlock {
pub declarations: Vec<(PropertyDeclaration, Importance)>,
/// The number of entries in `self.declaration` with `Importance::Important`
- pub important_count: usize,
+ important_count: usize,
}
impl PropertyDeclarationBlock {
@@ -68,6 +68,14 @@ impl PropertyDeclarationBlock {
}
}
+ /// Create a block with a single declaration
+ pub fn with_one(declaration: PropertyDeclaration, importance: Importance) -> Self {
+ PropertyDeclarationBlock {
+ declarations: vec![(declaration, importance)],
+ important_count: if importance.important() { 1 } else { 0 },
+ }
+ }
+
/// Returns wheather this block contains any declaration with `!important`.
///
/// This is based on the `important_count` counter,
diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs
index 69a1cca08bb..8e52d9d739c 100644
--- a/components/style/properties/gecko.mako.rs
+++ b/components/style/properties/gecko.mako.rs
@@ -168,23 +168,19 @@ impl ComputedValues {
% for prop in data.longhands:
% if prop.animatable:
PropertyDeclarationId::Longhand(LonghandId::${prop.camel_case}) => {
- PropertyDeclarationBlock {
- declarations: vec![
- (PropertyDeclaration::${prop.camel_case}(DeclaredValue::Value(
- % if prop.boxed:
- Box::new(
- % endif
- longhands::${prop.ident}::SpecifiedValue::from_computed_value(
- &self.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}())
- % if prop.boxed:
- )
- % endif
-
- )),
- Importance::Normal)
- ],
- important_count: 0
- }
+ PropertyDeclarationBlock::with_one(
+ PropertyDeclaration::${prop.camel_case}(DeclaredValue::Value(
+ % if prop.boxed:
+ Box::new(
+ % endif
+ longhands::${prop.ident}::SpecifiedValue::from_computed_value(
+ &self.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}())
+ % if prop.boxed:
+ )
+ % endif
+ )),
+ Importance::Normal
+ )
},
% endif
% endfor
diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs
index a700e2a33aa..31bf032fc21 100644
--- a/ports/geckolib/glue.rs
+++ b/ports/geckolib/glue.rs
@@ -276,10 +276,8 @@ pub extern "C" fn Servo_AnimationValue_Serialize(value: RawServoAnimationValueBo
{
let uncomputed_value = AnimationValue::as_arc(&value).uncompute();
let mut string = String::new();
- let rv = PropertyDeclarationBlock {
- declarations: vec![(uncomputed_value, Importance::Normal)],
- important_count: 0
- }.single_value_to_css(&get_property_id_from_nscsspropertyid!(property, ()), &mut string);
+ let rv = PropertyDeclarationBlock::with_one(uncomputed_value, Importance::Normal)
+ .single_value_to_css(&get_property_id_from_nscsspropertyid!(property, ()), &mut string);
debug_assert!(rv.is_ok());
write!(unsafe { &mut *buffer }, "{}", string).expect("Failed to copy string");
@@ -726,7 +724,7 @@ pub extern "C" fn Servo_ParseStyleAttribute(data: *const nsACString) -> RawServo
#[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_CreateEmpty() -> RawServoDeclarationBlockStrong {
- Arc::new(RwLock::new(PropertyDeclarationBlock { declarations: vec![], important_count: 0 })).into_strong()
+ Arc::new(RwLock::new(PropertyDeclarationBlock::new())).into_strong()
}
#[no_mangle]
@@ -1479,10 +1477,9 @@ pub extern "C" fn Servo_StyleSet_FillKeyframesForName(raw_data: RawServoStyleSet
(*keyframe).mPropertyValues.set_len((index + 1) as u32);
(*keyframe).mPropertyValues[index].mProperty = property.into();
(*keyframe).mPropertyValues[index].mServoDeclarationBlock.set_arc_leaky(
- Arc::new(RwLock::new(
- PropertyDeclarationBlock { declarations: vec![ (declaration.clone(),
- Importance::Normal) ],
- important_count: 0 })));
+ Arc::new(RwLock::new(PropertyDeclarationBlock::with_one(
+ declaration.clone(), Importance::Normal
+ ))));
if step.start_percentage.0 == 0. ||
step.start_percentage.0 == 1. {
seen.set_transition_property_bit(&property);
diff --git a/tests/unit/style/keyframes.rs b/tests/unit/style/keyframes.rs
index d01dbcab2d0..a1861754419 100644
--- a/tests/unit/style/keyframes.rs
+++ b/tests/unit/style/keyframes.rs
@@ -27,10 +27,7 @@ fn test_no_property_in_keyframe() {
let keyframes = vec![
Arc::new(RwLock::new(Keyframe {
selector: KeyframeSelector::new_for_unit_testing(vec![KeyframePercentage::new(1.)]),
- block: Arc::new(RwLock::new(PropertyDeclarationBlock {
- declarations: vec![],
- important_count: 0,
- }))
+ block: Arc::new(RwLock::new(PropertyDeclarationBlock::new()))
})),
];
let animation = KeyframesAnimation::from_keyframes(&keyframes);
@@ -45,27 +42,26 @@ fn test_no_property_in_keyframe() {
#[test]
fn test_missing_property_in_initial_keyframe() {
let declarations_on_initial_keyframe =
- Arc::new(RwLock::new(PropertyDeclarationBlock {
- declarations: vec![
- (PropertyDeclaration::Width(
- DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))),
- Importance::Normal),
- ],
- important_count: 0,
- }));
+ Arc::new(RwLock::new(PropertyDeclarationBlock::with_one(
+ PropertyDeclaration::Width(
+ DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))),
+ Importance::Normal
+ )));
let declarations_on_final_keyframe =
- Arc::new(RwLock::new(PropertyDeclarationBlock {
- declarations: vec![
- (PropertyDeclaration::Width(
+ Arc::new(RwLock::new({
+ let mut block = PropertyDeclarationBlock::new();
+ block.push(
+ PropertyDeclaration::Width(
DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))),
- Importance::Normal),
-
- (PropertyDeclaration::Height(
+ Importance::Normal
+ );
+ block.push(
+ PropertyDeclaration::Height(
DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))),
- Importance::Normal),
- ],
- important_count: 0,
+ Importance::Normal
+ );
+ block
}));
let keyframes = vec![
@@ -102,28 +98,27 @@ fn test_missing_property_in_initial_keyframe() {
#[test]
fn test_missing_property_in_final_keyframe() {
let declarations_on_initial_keyframe =
- Arc::new(RwLock::new(PropertyDeclarationBlock {
- declarations: vec![
- (PropertyDeclaration::Width(
+ Arc::new(RwLock::new({
+ let mut block = PropertyDeclarationBlock::new();
+ block.push(
+ PropertyDeclaration::Width(
DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))),
- Importance::Normal),
-
- (PropertyDeclaration::Height(
+ Importance::Normal
+ );
+ block.push(
+ PropertyDeclaration::Height(
DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))),
- Importance::Normal),
- ],
- important_count: 0,
+ Importance::Normal
+ );
+ block
}));
let declarations_on_final_keyframe =
- Arc::new(RwLock::new(PropertyDeclarationBlock {
- declarations: vec![
- (PropertyDeclaration::Height(
- DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))),
- Importance::Normal),
- ],
- important_count: 0,
- }));
+ Arc::new(RwLock::new(PropertyDeclarationBlock::with_one(
+ PropertyDeclaration::Height(
+ DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))),
+ Importance::Normal,
+ )));
let keyframes = vec![
Arc::new(RwLock::new(Keyframe {
@@ -159,26 +154,25 @@ fn test_missing_property_in_final_keyframe() {
#[test]
fn test_missing_keyframe_in_both_of_initial_and_final_keyframe() {
let declarations =
- Arc::new(RwLock::new(PropertyDeclarationBlock {
- declarations: vec![
- (PropertyDeclaration::Width(
- DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))),
- Importance::Normal),
-
- (PropertyDeclaration::Height(
- DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))),
- Importance::Normal),
- ],
- important_count: 0,
+ Arc::new(RwLock::new({
+ let mut block = PropertyDeclarationBlock::new();
+ block.push(
+ PropertyDeclaration::Width(
+ DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))),
+ Importance::Normal
+ );
+ block.push(
+ PropertyDeclaration::Height(
+ DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))),
+ Importance::Normal
+ );
+ block
}));
let keyframes = vec![
Arc::new(RwLock::new(Keyframe {
selector: KeyframeSelector::new_for_unit_testing(vec![KeyframePercentage::new(0.)]),
- block: Arc::new(RwLock::new(PropertyDeclarationBlock {
- declarations: vec![],
- important_count: 0,
- }))
+ block: Arc::new(RwLock::new(PropertyDeclarationBlock::new()))
})),
Arc::new(RwLock::new(Keyframe {
selector: KeyframeSelector::new_for_unit_testing(vec![KeyframePercentage::new(0.5)]),
@@ -191,11 +185,10 @@ fn test_missing_keyframe_in_both_of_initial_and_final_keyframe() {
KeyframesStep {
start_percentage: KeyframePercentage(0.),
value: KeyframesStepValue::Declarations {
- block: Arc::new(RwLock::new(PropertyDeclarationBlock {
+ block: Arc::new(RwLock::new(
// XXX: Should we use ComputedValues in this case?
- declarations: vec![],
- important_count: 0,
- }))
+ PropertyDeclarationBlock::new()
+ ))
},
declared_timing_function: false,
},
diff --git a/tests/unit/style/properties/serialization.rs b/tests/unit/style/properties/serialization.rs
index 9433d97ed3d..f69e75ed571 100644
--- a/tests/unit/style/properties/serialization.rs
+++ b/tests/unit/style/properties/serialization.rs
@@ -17,6 +17,7 @@ use style::values::specified::{BorderStyle, BorderWidth, CSSColor, Length, NoCal
use style::values::specified::{LengthOrPercentage, LengthOrPercentageOrAuto, LengthOrPercentageOrAutoOrContent};
use style::values::specified::url::SpecifiedUrl;
use style_traits::ToCss;
+use stylesheets::block_from;
fn parse_declaration_block(css_properties: &str) -> PropertyDeclarationBlock {
let url = ServoUrl::parse("http://localhost").unwrap();
@@ -56,10 +57,7 @@ fn property_declaration_block_should_serialize_correctly() {
Importance::Normal),
];
- let block = PropertyDeclarationBlock {
- declarations: declarations,
- important_count: 0,
- };
+ let block = block_from(declarations);
let css_string = block.to_css_string();
@@ -73,10 +71,7 @@ mod shorthand_serialization {
pub use super::*;
pub fn shorthand_properties_to_string(properties: Vec<PropertyDeclaration>) -> String {
- let block = PropertyDeclarationBlock {
- declarations: properties.into_iter().map(|d| (d, Importance::Normal)).collect(),
- important_count: 0,
- };
+ let block = block_from(properties.into_iter().map(|d| (d, Importance::Normal)));
block.to_css_string()
}
@@ -882,10 +877,7 @@ mod shorthand_serialization {
Importance::Normal)
];
- let block = PropertyDeclarationBlock {
- declarations: declarations,
- important_count: 0
- };
+ let block = block_from(declarations);
let mut s = String::new();
@@ -905,10 +897,7 @@ mod shorthand_serialization {
Importance::Normal)
];
- let block = PropertyDeclarationBlock {
- declarations: declarations,
- important_count: 0
- };
+ let block = block_from(declarations);
let mut s = String::new();
diff --git a/tests/unit/style/rule_tree/bench.rs b/tests/unit/style/rule_tree/bench.rs
index ba76d79b861..74242967766 100644
--- a/tests/unit/style/rule_tree/bench.rs
+++ b/tests/unit/style/rule_tree/bench.rs
@@ -68,14 +68,11 @@ fn test_insertion(rule_tree: &RuleTree, rules: Vec<(StyleSource, CascadeLevel)>)
fn test_insertion_style_attribute(rule_tree: &RuleTree, rules: &[(StyleSource, CascadeLevel)]) -> StrongRuleNode {
let mut rules = rules.to_vec();
- rules.push((StyleSource::Declarations(Arc::new(RwLock::new(PropertyDeclarationBlock {
- declarations: vec![
- (PropertyDeclaration::Display(DeclaredValue::Value(
- longhands::display::SpecifiedValue::block)),
- Importance::Normal),
- ],
- important_count: 0,
- }))), CascadeLevel::UserNormal));
+ rules.push((StyleSource::Declarations(Arc::new(RwLock::new(PropertyDeclarationBlock::with_one(
+ PropertyDeclaration::Display(DeclaredValue::Value(
+ longhands::display::SpecifiedValue::block)),
+ Importance::Normal
+ )))), CascadeLevel::UserNormal));
test_insertion(rule_tree, rules)
}
diff --git a/tests/unit/style/stylesheets.rs b/tests/unit/style/stylesheets.rs
index 586f2616ecf..a85e5e36fb0 100644
--- a/tests/unit/style/stylesheets.rs
+++ b/tests/unit/style/stylesheets.rs
@@ -24,6 +24,15 @@ use style::stylesheets::{Origin, Namespaces};
use style::stylesheets::{Stylesheet, NamespaceRule, CssRule, CssRules, StyleRule, KeyframesRule};
use style::values::specified::{LengthOrPercentageOrAuto, Percentage};
+pub fn block_from<I>(iterable: I) -> PropertyDeclarationBlock
+where I: IntoIterator<Item=(PropertyDeclaration, Importance)> {
+ let mut block = PropertyDeclarationBlock::new();
+ for (d, i) in iterable {
+ block.push(d, i)
+ }
+ block
+}
+
#[test]
fn test_parse_stylesheet() {
let css = r"
@@ -98,17 +107,14 @@ fn test_parse_stylesheet() {
specificity: (0 << 20) + (1 << 10) + (1 << 0),
},
]),
- block: Arc::new(RwLock::new(PropertyDeclarationBlock {
- declarations: vec![
- (PropertyDeclaration::Display(DeclaredValue::Value(
- longhands::display::SpecifiedValue::none)),
- Importance::Important),
- (PropertyDeclaration::Custom(Atom::from("a"),
- DeclaredValue::CSSWideKeyword(CSSWideKeyword::Inherit)),
- Importance::Important),
- ],
- important_count: 2,
- })),
+ block: Arc::new(RwLock::new(block_from(vec![
+ (PropertyDeclaration::Display(DeclaredValue::Value(
+ longhands::display::SpecifiedValue::none)),
+ Importance::Important),
+ (PropertyDeclaration::Custom(Atom::from("a"),
+ DeclaredValue::CSSWideKeyword(CSSWideKeyword::Inherit)),
+ Importance::Important),
+ ]))),
}))),
CssRule::Style(Arc::new(RwLock::new(StyleRule {
selectors: SelectorList(vec![
@@ -147,14 +153,11 @@ fn test_parse_stylesheet() {
specificity: (0 << 20) + (0 << 10) + (1 << 0),
},
]),
- block: Arc::new(RwLock::new(PropertyDeclarationBlock {
- declarations: vec![
- (PropertyDeclaration::Display(DeclaredValue::Value(
- longhands::display::SpecifiedValue::block)),
- Importance::Normal),
- ],
- important_count: 0,
- })),
+ block: Arc::new(RwLock::new(block_from(vec![
+ (PropertyDeclaration::Display(DeclaredValue::Value(
+ longhands::display::SpecifiedValue::block)),
+ Importance::Normal),
+ ]))),
}))),
CssRule::Style(Arc::new(RwLock::new(StyleRule {
selectors: SelectorList(vec![
@@ -182,58 +185,55 @@ fn test_parse_stylesheet() {
specificity: (1 << 20) + (1 << 10) + (0 << 0),
},
]),
- block: Arc::new(RwLock::new(PropertyDeclarationBlock {
- declarations: vec![
- (PropertyDeclaration::BackgroundColor(DeclaredValue::Value(
- longhands::background_color::SpecifiedValue {
- authored: Some("blue".to_owned().into_boxed_str()),
- parsed: cssparser::Color::RGBA(cssparser::RGBA::new(0, 0, 255, 255)),
- }
- )),
- Importance::Normal),
- (PropertyDeclaration::BackgroundPositionX(DeclaredValue::Value(
- longhands::background_position_x::SpecifiedValue(
- vec![longhands::background_position_x::single_value
- ::get_initial_position_value()]))),
- Importance::Normal),
- (PropertyDeclaration::BackgroundPositionY(DeclaredValue::Value(
- longhands::background_position_y::SpecifiedValue(
- vec![longhands::background_position_y::single_value
- ::get_initial_position_value()]))),
- Importance::Normal),
- (PropertyDeclaration::BackgroundRepeat(DeclaredValue::Value(
- longhands::background_repeat::SpecifiedValue(
- vec![longhands::background_repeat::single_value
- ::get_initial_specified_value()]))),
- Importance::Normal),
- (PropertyDeclaration::BackgroundAttachment(DeclaredValue::Value(
- longhands::background_attachment::SpecifiedValue(
- vec![longhands::background_attachment::single_value
- ::get_initial_specified_value()]))),
- Importance::Normal),
- (PropertyDeclaration::BackgroundImage(DeclaredValue::Value(
- longhands::background_image::SpecifiedValue(
- vec![longhands::background_image::single_value
- ::get_initial_specified_value()]))),
- Importance::Normal),
- (PropertyDeclaration::BackgroundSize(DeclaredValue::Value(
- longhands::background_size::SpecifiedValue(
- vec![longhands::background_size::single_value
- ::get_initial_specified_value()]))),
- Importance::Normal),
- (PropertyDeclaration::BackgroundOrigin(DeclaredValue::Value(
- longhands::background_origin::SpecifiedValue(
- vec![longhands::background_origin::single_value
- ::get_initial_specified_value()]))),
- Importance::Normal),
- (PropertyDeclaration::BackgroundClip(DeclaredValue::Value(
- longhands::background_clip::SpecifiedValue(
- vec![longhands::background_clip::single_value
- ::get_initial_specified_value()]))),
- Importance::Normal),
- ],
- important_count: 0,
- })),
+ block: Arc::new(RwLock::new(block_from(vec![
+ (PropertyDeclaration::BackgroundColor(DeclaredValue::Value(
+ longhands::background_color::SpecifiedValue {
+ authored: Some("blue".to_owned().into_boxed_str()),
+ parsed: cssparser::Color::RGBA(cssparser::RGBA::new(0, 0, 255, 255)),
+ }
+ )),
+ Importance::Normal),
+ (PropertyDeclaration::BackgroundPositionX(DeclaredValue::Value(
+ longhands::background_position_x::SpecifiedValue(
+ vec![longhands::background_position_x::single_value
+ ::get_initial_position_value()]))),
+ Importance::Normal),
+ (PropertyDeclaration::BackgroundPositionY(DeclaredValue::Value(
+ longhands::background_position_y::SpecifiedValue(
+ vec![longhands::background_position_y::single_value
+ ::get_initial_position_value()]))),
+ Importance::Normal),
+ (PropertyDeclaration::BackgroundRepeat(DeclaredValue::Value(
+ longhands::background_repeat::SpecifiedValue(
+ vec![longhands::background_repeat::single_value
+ ::get_initial_specified_value()]))),
+ Importance::Normal),
+ (PropertyDeclaration::BackgroundAttachment(DeclaredValue::Value(
+ longhands::background_attachment::SpecifiedValue(
+ vec![longhands::background_attachment::single_value
+ ::get_initial_specified_value()]))),
+ Importance::Normal),
+ (PropertyDeclaration::BackgroundImage(DeclaredValue::Value(
+ longhands::background_image::SpecifiedValue(
+ vec![longhands::background_image::single_value
+ ::get_initial_specified_value()]))),
+ Importance::Normal),
+ (PropertyDeclaration::BackgroundSize(DeclaredValue::Value(
+ longhands::background_size::SpecifiedValue(
+ vec![longhands::background_size::single_value
+ ::get_initial_specified_value()]))),
+ Importance::Normal),
+ (PropertyDeclaration::BackgroundOrigin(DeclaredValue::Value(
+ longhands::background_origin::SpecifiedValue(
+ vec![longhands::background_origin::single_value
+ ::get_initial_specified_value()]))),
+ Importance::Normal),
+ (PropertyDeclaration::BackgroundClip(DeclaredValue::Value(
+ longhands::background_clip::SpecifiedValue(
+ vec![longhands::background_clip::single_value
+ ::get_initial_specified_value()]))),
+ Importance::Normal),
+ ]))),
}))),
CssRule::Keyframes(Arc::new(RwLock::new(KeyframesRule {
name: "foo".into(),
@@ -241,30 +241,24 @@ fn test_parse_stylesheet() {
Arc::new(RwLock::new(Keyframe {
selector: KeyframeSelector::new_for_unit_testing(
vec![KeyframePercentage::new(0.)]),
- block: Arc::new(RwLock::new(PropertyDeclarationBlock {
- declarations: vec![
- (PropertyDeclaration::Width(DeclaredValue::Value(
- LengthOrPercentageOrAuto::Percentage(Percentage(0.)))),
- Importance::Normal),
- ],
- important_count: 0,
- }))
+ block: Arc::new(RwLock::new(block_from(vec![
+ (PropertyDeclaration::Width(DeclaredValue::Value(
+ LengthOrPercentageOrAuto::Percentage(Percentage(0.)))),
+ Importance::Normal),
+ ])))
})),
Arc::new(RwLock::new(Keyframe {
selector: KeyframeSelector::new_for_unit_testing(
vec![KeyframePercentage::new(1.)]),
- block: Arc::new(RwLock::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,
- })),
+ block: Arc::new(RwLock::new(block_from(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),
+ ]))),
})),
]
})))
diff --git a/tests/unit/style/stylist.rs b/tests/unit/style/stylist.rs
index abb8f459211..46fb3eef164 100644
--- a/tests/unit/style/stylist.rs
+++ b/tests/unit/style/stylist.rs
@@ -23,14 +23,11 @@ fn get_mock_rules(css_selectors: &[&str]) -> Vec<Vec<Rule>> {
let rule = Arc::new(RwLock::new(StyleRule {
selectors: selectors,
- block: Arc::new(RwLock::new(PropertyDeclarationBlock {
- declarations: vec![
- (PropertyDeclaration::Display(DeclaredValue::Value(
- longhands::display::SpecifiedValue::block)),
- Importance::Normal),
- ],
- important_count: 0,
- })),
+ block: Arc::new(RwLock::new(PropertyDeclarationBlock::with_one(
+ PropertyDeclaration::Display(DeclaredValue::Value(
+ longhands::display::SpecifiedValue::block)),
+ Importance::Normal
+ ))),
}));
let guard = rule.read();