Reduce duplication in generated ServoComputedData::to_declaration_block.

This commit is contained in:
Josh Matthews 2017-09-06 11:02:53 -07:00
parent 00867711b3
commit ca9b231173

View file

@ -342,29 +342,27 @@ impl ComputedValuesInner {
pub fn is_multicol(&self) -> bool { false } pub fn is_multicol(&self) -> bool { false }
pub fn to_declaration_block(&self, property: PropertyDeclarationId) -> PropertyDeclarationBlock { pub fn to_declaration_block(&self, property: PropertyDeclarationId) -> PropertyDeclarationBlock {
match property { let value = match property {
% 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::with_one( PropertyDeclaration::${prop.camel_case}(
PropertyDeclaration::${prop.camel_case}( % 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
) )
}, },
% endif % endif
% endfor % endfor
PropertyDeclarationId::Custom(_name) => unimplemented!(), PropertyDeclarationId::Custom(_name) => unimplemented!(),
_ => unimplemented!() _ => unimplemented!()
} };
PropertyDeclarationBlock::with_one(value, Importance::Normal)
} }
} }