mirror of
https://github.com/servo/servo.git
synced 2025-08-10 07:55:33 +01:00
Introduce #[css(if_empty = "…", iterable)]
This commit is contained in:
parent
92f116a95c
commit
90b23963b7
4 changed files with 48 additions and 80 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue