Auto merge of #19981 - emilio:nicer, r=nox

style: Derive ToCss for FontFamilyList.

The extra reference in to_css is needed because the family list iterator returns
by value in Gecko.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19981)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-02-07 12:42:18 -05:00 committed by GitHub
commit 10552c23fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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. /// 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 { pub enum FontFamily {
/// List of `font-family` /// List of `font-family`
#[css(iterable, comma)]
Values(FontFamilyList), Values(FontFamilyList),
/// System font /// System font
System(SystemFont), 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 { impl Parse for FontFamily {
/// <family-name># /// <family-name>#
/// <family-name> = <string> | [ <ident>+ ] /// <family-name> = <string> | [ <ident>+ ]

View file

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