Replace write! with to_css and write_str in some ToCss impls

This commit is contained in:
Xidorn Quan 2017-08-20 17:11:51 +10:00
parent c1b196b7cb
commit 7e92c15e00
11 changed files with 58 additions and 42 deletions

View file

@ -2316,7 +2316,7 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control-
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
match *self {
SpecifiedValue::Auto => dest.write_str("auto"),
SpecifiedValue::Relative(rel) => write!(dest, "{}", rel),
SpecifiedValue::Relative(rel) => rel.to_css(dest),
// can only be specified by pres attrs; should not
// serialize to anything else
SpecifiedValue::Absolute(_) => Ok(()),

View file

@ -148,36 +148,36 @@
% endfor
if i != 0 {
write!(dest, ", ")?;
dest.write_str(", ")?;
}
if i == len - 1 {
self.background_color.to_css(dest)?;
write!(dest, " ")?;
dest.write_str(" ")?;
}
image.to_css(dest)?;
% for name in "repeat attachment".split():
write!(dest, " ")?;
dest.write_str(" ")?;
${name}.to_css(dest)?;
% endfor
write!(dest, " ")?;
dest.write_str(" ")?;
Position {
horizontal: position_x.clone(),
vertical: position_y.clone()
}.to_css(dest)?;
if *size != background_size::single_value::get_initial_specified_value() {
write!(dest, " / ")?;
dest.write_str(" / ")?;
size.to_css(dest)?;
}
if *origin != Origin::padding_box || *clip != Clip::border_box {
write!(dest, " ")?;
dest.write_str(" ")?;
origin.to_css(dest)?;
if *clip != From::from(*origin) {
write!(dest, " ")?;
dest.write_str(" ")?;
clip.to_css(dest)?;
}
}