mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: add css(function, iterable), and derive ToCss for VariantAlternates.
This commit is contained in:
parent
33fa728d6e
commit
06f8f0384b
2 changed files with 25 additions and 60 deletions
|
@ -636,81 +636,31 @@ bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq)]
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)]
|
||||
/// Set of variant alternates
|
||||
pub enum VariantAlternates {
|
||||
/// Enables display of stylistic alternates
|
||||
#[css(function)]
|
||||
Stylistic(CustomIdent),
|
||||
/// Enables display with stylistic sets
|
||||
#[css(comma, function, iterable)]
|
||||
Styleset(Box<[CustomIdent]>),
|
||||
/// Enables display of specific character variants
|
||||
#[css(comma, function, iterable)]
|
||||
CharacterVariant(Box<[CustomIdent]>),
|
||||
/// Enables display of swash glyphs
|
||||
#[css(function)]
|
||||
Swash(CustomIdent),
|
||||
/// Enables replacement of default glyphs with ornaments
|
||||
#[css(function)]
|
||||
Ornaments(CustomIdent),
|
||||
/// Enables display of alternate annotation forms
|
||||
#[css(function)]
|
||||
Annotation(CustomIdent),
|
||||
/// Enables display of historical forms
|
||||
HistoricalForms,
|
||||
}
|
||||
|
||||
impl ToCss for VariantAlternates {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match *self {
|
||||
VariantAlternates::Swash(ref atom) => {
|
||||
dest.write_str("swash")?;
|
||||
dest.write_str("(")?;
|
||||
atom.to_css(dest)?;
|
||||
dest.write_str(")")
|
||||
},
|
||||
VariantAlternates::Stylistic(ref atom) => {
|
||||
dest.write_str("stylistic")?;
|
||||
dest.write_str("(")?;
|
||||
atom.to_css(dest)?;
|
||||
dest.write_str(")")
|
||||
},
|
||||
VariantAlternates::Ornaments(ref atom) => {
|
||||
dest.write_str("ornaments")?;
|
||||
dest.write_str("(")?;
|
||||
atom.to_css(dest)?;
|
||||
dest.write_str(")")
|
||||
},
|
||||
VariantAlternates::Annotation(ref atom) => {
|
||||
dest.write_str("annotation")?;
|
||||
dest.write_str("(")?;
|
||||
atom.to_css(dest)?;
|
||||
dest.write_str(")")
|
||||
},
|
||||
VariantAlternates::Styleset(ref vec) => {
|
||||
dest.write_str("styleset")?;
|
||||
dest.write_str("(")?;
|
||||
let mut iter = vec.iter();
|
||||
iter.next().unwrap().to_css(dest)?;
|
||||
for c in iter {
|
||||
dest.write_str(", ")?;
|
||||
c.to_css(dest)?;
|
||||
}
|
||||
dest.write_str(")")
|
||||
},
|
||||
VariantAlternates::CharacterVariant(ref vec) => {
|
||||
dest.write_str("character-variant")?;
|
||||
dest.write_str("(")?;
|
||||
let mut iter = vec.iter();
|
||||
iter.next().unwrap().to_css(dest)?;
|
||||
for c in iter {
|
||||
dest.write_str(", ")?;
|
||||
c.to_css(dest)?;
|
||||
}
|
||||
dest.write_str(")")
|
||||
},
|
||||
VariantAlternates::HistoricalForms => {
|
||||
dest.write_str("historical-forms")
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq)]
|
||||
/// List of Variant Alternates
|
||||
pub struct VariantAlternatesList(pub Box<[VariantAlternates]>);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue