Remove uses of parse_four_sides and serialize_four_sides

This commit is contained in:
Anthony Ramine 2017-05-25 12:22:49 +02:00
parent ca8fae91da
commit 6f3c46ca61
6 changed files with 41 additions and 141 deletions

View file

@ -887,35 +887,34 @@
<%call expr="self.shorthand(name, sub_properties=sub_properties, **kwargs)">
#[allow(unused_imports)]
use parser::Parse;
use super::parse_four_sides;
use values::generics::rect::Rect;
use values::specified;
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
let (top, right, bottom, left) =
let rect = Rect::parse_with(context, input, |_c, i| {
% if allow_quirks:
try!(parse_four_sides(input, |i| ${parser_function}_quirky(context, i, specified::AllowQuirks::Yes)));
${parser_function}_quirky(_c, i, specified::AllowQuirks::Yes)
% elif needs_context:
try!(parse_four_sides(input, |i| ${parser_function}(context, i)));
${parser_function}(_c, i)
% else:
try!(parse_four_sides(input, ${parser_function}));
let _unused = context;
${parser_function}(i)
% endif
})?;
Ok(expanded! {
% for side in ["top", "right", "bottom", "left"]:
${to_rust_ident(sub_property_pattern % side)}: ${side},
${to_rust_ident(sub_property_pattern % side)}: rect.${side},
% endfor
})
}
impl<'a> ToCss for LonghandsToSerialize<'a> {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
super::serialize_four_sides(
dest,
self.${to_rust_ident(sub_property_pattern % 'top')},
self.${to_rust_ident(sub_property_pattern % 'right')},
self.${to_rust_ident(sub_property_pattern % 'bottom')},
self.${to_rust_ident(sub_property_pattern % 'left')}
)
let rect = Rect::new(
% for side in ["top", "right", "bottom", "left"]:
&self.${to_rust_ident(sub_property_pattern % side)},
% endfor
);
rect.to_css(dest)
}
}
</%call>