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);
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)
}
}

View file

@ -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)
}

View file

@ -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,

View file

@ -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