Make PropertyDeclarationBlock::important_count private.

This commit is contained in:
Simon Sapin 2017-03-07 19:45:12 +01:00
parent 460fd6eba8
commit da4e5146e9
10 changed files with 183 additions and 219 deletions

View file

@ -62,10 +62,7 @@ impl CSSStyleOwner {
let result = f(&mut pdb, &mut changed); let result = f(&mut pdb, &mut changed);
result result
} else { } else {
let mut pdb = PropertyDeclarationBlock { let mut pdb = PropertyDeclarationBlock::new();
important_count: 0,
declarations: vec![],
};
let result = f(&mut pdb, &mut changed); let result = f(&mut pdb, &mut changed);
// Here `changed` is somewhat silly, because we know the // Here `changed` is somewhat silly, because we know the
@ -116,10 +113,7 @@ impl CSSStyleOwner {
match *el.style_attribute().borrow() { match *el.style_attribute().borrow() {
Some(ref pdb) => f(&pdb.read()), Some(ref pdb) => f(&pdb.read()),
None => { None => {
let pdb = PropertyDeclarationBlock { let pdb = PropertyDeclarationBlock::new();
important_count: 0,
declarations: vec![],
};
f(&pdb) f(&pdb)
} }
} }

View file

@ -385,10 +385,9 @@ impl LayoutElementHelpers for LayoutJS<Element> {
#[inline] #[inline]
fn from_declaration(declaration: PropertyDeclaration) -> ApplicableDeclarationBlock { fn from_declaration(declaration: PropertyDeclaration) -> ApplicableDeclarationBlock {
ApplicableDeclarationBlock::from_declarations( ApplicableDeclarationBlock::from_declarations(
Arc::new(RwLock::new(PropertyDeclarationBlock { Arc::new(RwLock::new(PropertyDeclarationBlock::with_one(
declarations: vec![(declaration, Importance::Normal)], declaration, Importance::Normal
important_count: 0, ))),
})),
CascadeLevel::PresHints) CascadeLevel::PresHints)
} }

View file

@ -56,7 +56,7 @@ pub struct PropertyDeclarationBlock {
pub declarations: 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: usize, important_count: usize,
} }
impl PropertyDeclarationBlock { 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`. /// Returns wheather this block contains any declaration with `!important`.
/// ///
/// This is based on the `important_count` counter, /// This is based on the `important_count` counter,

View file

@ -168,23 +168,19 @@ impl ComputedValues {
% for prop in data.longhands: % for prop in data.longhands:
% if prop.animatable: % if prop.animatable:
PropertyDeclarationId::Longhand(LonghandId::${prop.camel_case}) => { PropertyDeclarationId::Longhand(LonghandId::${prop.camel_case}) => {
PropertyDeclarationBlock { PropertyDeclarationBlock::with_one(
declarations: vec![ PropertyDeclaration::${prop.camel_case}(DeclaredValue::Value(
(PropertyDeclaration::${prop.camel_case}(DeclaredValue::Value( % if prop.boxed:
% if prop.boxed: Box::new(
Box::new( % endif
% endif longhands::${prop.ident}::SpecifiedValue::from_computed_value(
longhands::${prop.ident}::SpecifiedValue::from_computed_value( &self.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}())
&self.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}()) % if prop.boxed:
% if prop.boxed: )
) % endif
% endif )),
Importance::Normal
)), )
Importance::Normal)
],
important_count: 0
}
}, },
% endif % endif
% endfor % endfor

View file

@ -276,10 +276,8 @@ pub extern "C" fn Servo_AnimationValue_Serialize(value: RawServoAnimationValueBo
{ {
let uncomputed_value = AnimationValue::as_arc(&value).uncompute(); let uncomputed_value = AnimationValue::as_arc(&value).uncompute();
let mut string = String::new(); let mut string = String::new();
let rv = PropertyDeclarationBlock { let rv = PropertyDeclarationBlock::with_one(uncomputed_value, Importance::Normal)
declarations: vec![(uncomputed_value, Importance::Normal)], .single_value_to_css(&get_property_id_from_nscsspropertyid!(property, ()), &mut string);
important_count: 0
}.single_value_to_css(&get_property_id_from_nscsspropertyid!(property, ()), &mut string);
debug_assert!(rv.is_ok()); debug_assert!(rv.is_ok());
write!(unsafe { &mut *buffer }, "{}", string).expect("Failed to copy string"); 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] #[no_mangle]
pub extern "C" fn Servo_DeclarationBlock_CreateEmpty() -> RawServoDeclarationBlockStrong { 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] #[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.set_len((index + 1) as u32);
(*keyframe).mPropertyValues[index].mProperty = property.into(); (*keyframe).mPropertyValues[index].mProperty = property.into();
(*keyframe).mPropertyValues[index].mServoDeclarationBlock.set_arc_leaky( (*keyframe).mPropertyValues[index].mServoDeclarationBlock.set_arc_leaky(
Arc::new(RwLock::new( Arc::new(RwLock::new(PropertyDeclarationBlock::with_one(
PropertyDeclarationBlock { declarations: vec![ (declaration.clone(), declaration.clone(), Importance::Normal
Importance::Normal) ], ))));
important_count: 0 })));
if step.start_percentage.0 == 0. || if step.start_percentage.0 == 0. ||
step.start_percentage.0 == 1. { step.start_percentage.0 == 1. {
seen.set_transition_property_bit(&property); seen.set_transition_property_bit(&property);

View file

@ -27,10 +27,7 @@ fn test_no_property_in_keyframe() {
let keyframes = vec![ let keyframes = vec![
Arc::new(RwLock::new(Keyframe { Arc::new(RwLock::new(Keyframe {
selector: KeyframeSelector::new_for_unit_testing(vec![KeyframePercentage::new(1.)]), selector: KeyframeSelector::new_for_unit_testing(vec![KeyframePercentage::new(1.)]),
block: Arc::new(RwLock::new(PropertyDeclarationBlock { block: Arc::new(RwLock::new(PropertyDeclarationBlock::new()))
declarations: vec![],
important_count: 0,
}))
})), })),
]; ];
let animation = KeyframesAnimation::from_keyframes(&keyframes); let animation = KeyframesAnimation::from_keyframes(&keyframes);
@ -45,27 +42,26 @@ fn test_no_property_in_keyframe() {
#[test] #[test]
fn test_missing_property_in_initial_keyframe() { fn test_missing_property_in_initial_keyframe() {
let declarations_on_initial_keyframe = let declarations_on_initial_keyframe =
Arc::new(RwLock::new(PropertyDeclarationBlock { Arc::new(RwLock::new(PropertyDeclarationBlock::with_one(
declarations: vec![ PropertyDeclaration::Width(
(PropertyDeclaration::Width( DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))),
DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), Importance::Normal
Importance::Normal), )));
],
important_count: 0,
}));
let declarations_on_final_keyframe = let declarations_on_final_keyframe =
Arc::new(RwLock::new(PropertyDeclarationBlock { Arc::new(RwLock::new({
declarations: vec![ let mut block = PropertyDeclarationBlock::new();
(PropertyDeclaration::Width( block.push(
PropertyDeclaration::Width(
DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))),
Importance::Normal), Importance::Normal
);
(PropertyDeclaration::Height( block.push(
PropertyDeclaration::Height(
DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))),
Importance::Normal), Importance::Normal
], );
important_count: 0, block
})); }));
let keyframes = vec![ let keyframes = vec![
@ -102,28 +98,27 @@ fn test_missing_property_in_initial_keyframe() {
#[test] #[test]
fn test_missing_property_in_final_keyframe() { fn test_missing_property_in_final_keyframe() {
let declarations_on_initial_keyframe = let declarations_on_initial_keyframe =
Arc::new(RwLock::new(PropertyDeclarationBlock { Arc::new(RwLock::new({
declarations: vec![ let mut block = PropertyDeclarationBlock::new();
(PropertyDeclaration::Width( block.push(
PropertyDeclaration::Width(
DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))),
Importance::Normal), Importance::Normal
);
(PropertyDeclaration::Height( block.push(
PropertyDeclaration::Height(
DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))),
Importance::Normal), Importance::Normal
], );
important_count: 0, block
})); }));
let declarations_on_final_keyframe = let declarations_on_final_keyframe =
Arc::new(RwLock::new(PropertyDeclarationBlock { Arc::new(RwLock::new(PropertyDeclarationBlock::with_one(
declarations: vec![ PropertyDeclaration::Height(
(PropertyDeclaration::Height( DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))),
DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), Importance::Normal,
Importance::Normal), )));
],
important_count: 0,
}));
let keyframes = vec![ let keyframes = vec![
Arc::new(RwLock::new(Keyframe { Arc::new(RwLock::new(Keyframe {
@ -159,26 +154,25 @@ fn test_missing_property_in_final_keyframe() {
#[test] #[test]
fn test_missing_keyframe_in_both_of_initial_and_final_keyframe() { fn test_missing_keyframe_in_both_of_initial_and_final_keyframe() {
let declarations = let declarations =
Arc::new(RwLock::new(PropertyDeclarationBlock { Arc::new(RwLock::new({
declarations: vec![ let mut block = PropertyDeclarationBlock::new();
(PropertyDeclaration::Width( block.push(
DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), PropertyDeclaration::Width(
Importance::Normal), DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))),
Importance::Normal
(PropertyDeclaration::Height( );
DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))), block.push(
Importance::Normal), PropertyDeclaration::Height(
], DeclaredValue::Value(LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32)))),
important_count: 0, Importance::Normal
);
block
})); }));
let keyframes = vec![ let keyframes = vec![
Arc::new(RwLock::new(Keyframe { Arc::new(RwLock::new(Keyframe {
selector: KeyframeSelector::new_for_unit_testing(vec![KeyframePercentage::new(0.)]), selector: KeyframeSelector::new_for_unit_testing(vec![KeyframePercentage::new(0.)]),
block: Arc::new(RwLock::new(PropertyDeclarationBlock { block: Arc::new(RwLock::new(PropertyDeclarationBlock::new()))
declarations: vec![],
important_count: 0,
}))
})), })),
Arc::new(RwLock::new(Keyframe { Arc::new(RwLock::new(Keyframe {
selector: KeyframeSelector::new_for_unit_testing(vec![KeyframePercentage::new(0.5)]), 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 { KeyframesStep {
start_percentage: KeyframePercentage(0.), start_percentage: KeyframePercentage(0.),
value: KeyframesStepValue::Declarations { value: KeyframesStepValue::Declarations {
block: Arc::new(RwLock::new(PropertyDeclarationBlock { block: Arc::new(RwLock::new(
// XXX: Should we use ComputedValues in this case? // XXX: Should we use ComputedValues in this case?
declarations: vec![], PropertyDeclarationBlock::new()
important_count: 0, ))
}))
}, },
declared_timing_function: false, declared_timing_function: false,
}, },

View file

@ -17,6 +17,7 @@ use style::values::specified::{BorderStyle, BorderWidth, CSSColor, Length, NoCal
use style::values::specified::{LengthOrPercentage, LengthOrPercentageOrAuto, LengthOrPercentageOrAutoOrContent}; use style::values::specified::{LengthOrPercentage, LengthOrPercentageOrAuto, LengthOrPercentageOrAutoOrContent};
use style::values::specified::url::SpecifiedUrl; use style::values::specified::url::SpecifiedUrl;
use style_traits::ToCss; use style_traits::ToCss;
use stylesheets::block_from;
fn parse_declaration_block(css_properties: &str) -> PropertyDeclarationBlock { fn parse_declaration_block(css_properties: &str) -> PropertyDeclarationBlock {
let url = ServoUrl::parse("http://localhost").unwrap(); let url = ServoUrl::parse("http://localhost").unwrap();
@ -56,10 +57,7 @@ fn property_declaration_block_should_serialize_correctly() {
Importance::Normal), Importance::Normal),
]; ];
let block = PropertyDeclarationBlock { let block = block_from(declarations);
declarations: declarations,
important_count: 0,
};
let css_string = block.to_css_string(); let css_string = block.to_css_string();
@ -73,10 +71,7 @@ mod shorthand_serialization {
pub use super::*; pub use super::*;
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 = block_from(properties.into_iter().map(|d| (d, Importance::Normal)));
declarations: properties.into_iter().map(|d| (d, Importance::Normal)).collect(),
important_count: 0,
};
block.to_css_string() block.to_css_string()
} }
@ -882,10 +877,7 @@ mod shorthand_serialization {
Importance::Normal) Importance::Normal)
]; ];
let block = PropertyDeclarationBlock { let block = block_from(declarations);
declarations: declarations,
important_count: 0
};
let mut s = String::new(); let mut s = String::new();
@ -905,10 +897,7 @@ mod shorthand_serialization {
Importance::Normal) Importance::Normal)
]; ];
let block = PropertyDeclarationBlock { let block = block_from(declarations);
declarations: declarations,
important_count: 0
};
let mut s = String::new(); let mut s = String::new();

View file

@ -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 { fn test_insertion_style_attribute(rule_tree: &RuleTree, rules: &[(StyleSource, CascadeLevel)]) -> StrongRuleNode {
let mut rules = rules.to_vec(); let mut rules = rules.to_vec();
rules.push((StyleSource::Declarations(Arc::new(RwLock::new(PropertyDeclarationBlock { rules.push((StyleSource::Declarations(Arc::new(RwLock::new(PropertyDeclarationBlock::with_one(
declarations: vec![ PropertyDeclaration::Display(DeclaredValue::Value(
(PropertyDeclaration::Display(DeclaredValue::Value( longhands::display::SpecifiedValue::block)),
longhands::display::SpecifiedValue::block)), Importance::Normal
Importance::Normal), )))), CascadeLevel::UserNormal));
],
important_count: 0,
}))), CascadeLevel::UserNormal));
test_insertion(rule_tree, rules) test_insertion(rule_tree, rules)
} }

View file

@ -24,6 +24,15 @@ use style::stylesheets::{Origin, Namespaces};
use style::stylesheets::{Stylesheet, NamespaceRule, CssRule, CssRules, StyleRule, KeyframesRule}; use style::stylesheets::{Stylesheet, NamespaceRule, CssRule, CssRules, StyleRule, KeyframesRule};
use style::values::specified::{LengthOrPercentageOrAuto, Percentage}; 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] #[test]
fn test_parse_stylesheet() { fn test_parse_stylesheet() {
let css = r" let css = r"
@ -98,17 +107,14 @@ fn test_parse_stylesheet() {
specificity: (0 << 20) + (1 << 10) + (1 << 0), specificity: (0 << 20) + (1 << 10) + (1 << 0),
}, },
]), ]),
block: Arc::new(RwLock::new(PropertyDeclarationBlock { block: Arc::new(RwLock::new(block_from(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"),
(PropertyDeclaration::Custom(Atom::from("a"), DeclaredValue::CSSWideKeyword(CSSWideKeyword::Inherit)),
DeclaredValue::CSSWideKeyword(CSSWideKeyword::Inherit)), Importance::Important),
Importance::Important), ]))),
],
important_count: 2,
})),
}))), }))),
CssRule::Style(Arc::new(RwLock::new(StyleRule { CssRule::Style(Arc::new(RwLock::new(StyleRule {
selectors: SelectorList(vec![ selectors: SelectorList(vec![
@ -147,14 +153,11 @@ fn test_parse_stylesheet() {
specificity: (0 << 20) + (0 << 10) + (1 << 0), specificity: (0 << 20) + (0 << 10) + (1 << 0),
}, },
]), ]),
block: Arc::new(RwLock::new(PropertyDeclarationBlock { block: Arc::new(RwLock::new(block_from(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,
})),
}))), }))),
CssRule::Style(Arc::new(RwLock::new(StyleRule { CssRule::Style(Arc::new(RwLock::new(StyleRule {
selectors: SelectorList(vec![ selectors: SelectorList(vec![
@ -182,58 +185,55 @@ fn test_parse_stylesheet() {
specificity: (1 << 20) + (1 << 10) + (0 << 0), specificity: (1 << 20) + (1 << 10) + (0 << 0),
}, },
]), ]),
block: Arc::new(RwLock::new(PropertyDeclarationBlock { block: Arc::new(RwLock::new(block_from(vec![
declarations: vec![ (PropertyDeclaration::BackgroundColor(DeclaredValue::Value(
(PropertyDeclaration::BackgroundColor(DeclaredValue::Value( longhands::background_color::SpecifiedValue {
longhands::background_color::SpecifiedValue { authored: Some("blue".to_owned().into_boxed_str()),
authored: Some("blue".to_owned().into_boxed_str()), parsed: cssparser::Color::RGBA(cssparser::RGBA::new(0, 0, 255, 255)),
parsed: cssparser::Color::RGBA(cssparser::RGBA::new(0, 0, 255, 255)), }
} )),
)), Importance::Normal),
Importance::Normal), (PropertyDeclaration::BackgroundPositionX(DeclaredValue::Value(
(PropertyDeclaration::BackgroundPositionX(DeclaredValue::Value( longhands::background_position_x::SpecifiedValue(
longhands::background_position_x::SpecifiedValue( vec![longhands::background_position_x::single_value
vec![longhands::background_position_x::single_value ::get_initial_position_value()]))),
::get_initial_position_value()]))), Importance::Normal),
Importance::Normal), (PropertyDeclaration::BackgroundPositionY(DeclaredValue::Value(
(PropertyDeclaration::BackgroundPositionY(DeclaredValue::Value( longhands::background_position_y::SpecifiedValue(
longhands::background_position_y::SpecifiedValue( vec![longhands::background_position_y::single_value
vec![longhands::background_position_y::single_value ::get_initial_position_value()]))),
::get_initial_position_value()]))), Importance::Normal),
Importance::Normal), (PropertyDeclaration::BackgroundRepeat(DeclaredValue::Value(
(PropertyDeclaration::BackgroundRepeat(DeclaredValue::Value( longhands::background_repeat::SpecifiedValue(
longhands::background_repeat::SpecifiedValue( vec![longhands::background_repeat::single_value
vec![longhands::background_repeat::single_value ::get_initial_specified_value()]))),
::get_initial_specified_value()]))), Importance::Normal),
Importance::Normal), (PropertyDeclaration::BackgroundAttachment(DeclaredValue::Value(
(PropertyDeclaration::BackgroundAttachment(DeclaredValue::Value( longhands::background_attachment::SpecifiedValue(
longhands::background_attachment::SpecifiedValue( vec![longhands::background_attachment::single_value
vec![longhands::background_attachment::single_value ::get_initial_specified_value()]))),
::get_initial_specified_value()]))), Importance::Normal),
Importance::Normal), (PropertyDeclaration::BackgroundImage(DeclaredValue::Value(
(PropertyDeclaration::BackgroundImage(DeclaredValue::Value( longhands::background_image::SpecifiedValue(
longhands::background_image::SpecifiedValue( vec![longhands::background_image::single_value
vec![longhands::background_image::single_value ::get_initial_specified_value()]))),
::get_initial_specified_value()]))), Importance::Normal),
Importance::Normal), (PropertyDeclaration::BackgroundSize(DeclaredValue::Value(
(PropertyDeclaration::BackgroundSize(DeclaredValue::Value( longhands::background_size::SpecifiedValue(
longhands::background_size::SpecifiedValue( vec![longhands::background_size::single_value
vec![longhands::background_size::single_value ::get_initial_specified_value()]))),
::get_initial_specified_value()]))), Importance::Normal),
Importance::Normal), (PropertyDeclaration::BackgroundOrigin(DeclaredValue::Value(
(PropertyDeclaration::BackgroundOrigin(DeclaredValue::Value( longhands::background_origin::SpecifiedValue(
longhands::background_origin::SpecifiedValue( vec![longhands::background_origin::single_value
vec![longhands::background_origin::single_value ::get_initial_specified_value()]))),
::get_initial_specified_value()]))), Importance::Normal),
Importance::Normal), (PropertyDeclaration::BackgroundClip(DeclaredValue::Value(
(PropertyDeclaration::BackgroundClip(DeclaredValue::Value( longhands::background_clip::SpecifiedValue(
longhands::background_clip::SpecifiedValue( 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,
})),
}))), }))),
CssRule::Keyframes(Arc::new(RwLock::new(KeyframesRule { CssRule::Keyframes(Arc::new(RwLock::new(KeyframesRule {
name: "foo".into(), name: "foo".into(),
@ -241,30 +241,24 @@ fn test_parse_stylesheet() {
Arc::new(RwLock::new(Keyframe { Arc::new(RwLock::new(Keyframe {
selector: KeyframeSelector::new_for_unit_testing( selector: KeyframeSelector::new_for_unit_testing(
vec![KeyframePercentage::new(0.)]), vec![KeyframePercentage::new(0.)]),
block: Arc::new(RwLock::new(PropertyDeclarationBlock { block: Arc::new(RwLock::new(block_from(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,
}))
})), })),
Arc::new(RwLock::new(Keyframe { Arc::new(RwLock::new(Keyframe {
selector: KeyframeSelector::new_for_unit_testing( selector: KeyframeSelector::new_for_unit_testing(
vec![KeyframePercentage::new(1.)]), vec![KeyframePercentage::new(1.)]),
block: Arc::new(RwLock::new(PropertyDeclarationBlock { block: Arc::new(RwLock::new(block_from(vec![
declarations: vec![ (PropertyDeclaration::Width(DeclaredValue::Value(
(PropertyDeclaration::Width(DeclaredValue::Value( LengthOrPercentageOrAuto::Percentage(Percentage(1.)))),
LengthOrPercentageOrAuto::Percentage(Percentage(1.)))), Importance::Normal),
Importance::Normal), (PropertyDeclaration::AnimationPlayState(DeclaredValue::Value(
(PropertyDeclaration::AnimationPlayState(DeclaredValue::Value( 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,
})),
})), })),
] ]
}))) })))

View file

@ -23,14 +23,11 @@ fn get_mock_rules(css_selectors: &[&str]) -> Vec<Vec<Rule>> {
let rule = Arc::new(RwLock::new(StyleRule { let rule = Arc::new(RwLock::new(StyleRule {
selectors: selectors, selectors: selectors,
block: Arc::new(RwLock::new(PropertyDeclarationBlock { block: Arc::new(RwLock::new(PropertyDeclarationBlock::with_one(
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,
})),
})); }));
let guard = rule.read(); let guard = rule.read();