Introduce #[css(if_empty = "…", iterable)]

This commit is contained in:
Anthony Ramine 2018-03-07 13:07:13 +01:00
parent 92f116a95c
commit 90b23963b7
4 changed files with 48 additions and 80 deletions

View file

@ -736,9 +736,12 @@ pub enum VariantAlternates {
HistoricalForms,
}
#[derive(Clone, Debug, MallocSizeOf, PartialEq)]
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)]
/// List of Variant Alternates
pub struct VariantAlternatesList(pub Box<[VariantAlternates]>);
pub struct VariantAlternatesList(
#[css(if_empty = "normal", iterable)]
pub Box<[VariantAlternates]>,
);
impl VariantAlternatesList {
/// Returns the length of all variant alternates.
@ -759,25 +762,6 @@ impl VariantAlternatesList {
}
}
impl ToCss for VariantAlternatesList {
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
where
W: Write,
{
if self.0.is_empty() {
return dest.write_str("normal");
}
let mut iter = self.0.iter();
iter.next().unwrap().to_css(dest)?;
for alternate in iter {
dest.write_str(" ")?;
alternate.to_css(dest)?;
}
Ok(())
}
}
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)]
/// Control over the selection of these alternate glyphs
pub enum FontVariantAlternates {