mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
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:
parent
e57319a734
commit
e41d724694
2 changed files with 3 additions and 22 deletions
|
@ -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>+ ]
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue