style: Derive ToCss for FontFamilyList.

The extra reference in to_css is needed because the family list iterator returns
by value in Gecko.
This commit is contained in:
Emilio Cobos Álvarez 2018-02-07 17:30:28 +01:00
parent e57319a734
commit e41d724694
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 3 additions and 22 deletions

View file

@ -165,9 +165,10 @@ impl From<LengthOrPercentage> for FontSize {
}
/// Specifies a prioritized list of font family names or generic family names.
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
#[derive(Clone, Debug, Eq, Hash, PartialEq, ToCss)]
pub enum FontFamily {
/// List of `font-family`
#[css(iterable, comma)]
Values(FontFamilyList),
/// System font
System(SystemFont),
@ -245,26 +246,6 @@ impl MallocSizeOf for FontFamily {
}
}
impl ToCss for FontFamily {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where
W: Write,
{
match *self {
FontFamily::Values(ref v) => {
let mut iter = v.iter();
iter.next().unwrap().to_css(dest)?;
for family in iter {
dest.write_str(", ")?;
family.to_css(dest)?;
}
Ok(())
}
FontFamily::System(sys) => sys.to_css(dest),
}
}
}
impl Parse for FontFamily {
/// <family-name>#
/// <family-name> = <string> | [ <ident>+ ]

View file

@ -44,7 +44,7 @@ pub fn derive(input: DeriveInput) -> Tokens {
#expr
for item in #binding.iter() {
writer.item(item)?;
writer.item(&item)?;
}
};
} else {