mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Derive ToCss for some counter-style descriptors
This commit is contained in:
parent
2b02a444ea
commit
3ee6598abb
1 changed files with 5 additions and 43 deletions
|
@ -469,7 +469,7 @@ fn bound_to_css<W>(range: Option<i32>, dest: &mut W) -> fmt::Result where W: fmt
|
|||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-counter-styles/#counter-style-pad
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Clone, Debug, ToCss)]
|
||||
pub struct Pad(pub u32, pub Symbol);
|
||||
|
||||
impl Parse for Pad {
|
||||
|
@ -484,15 +484,8 @@ impl Parse for Pad {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToCss for Pad {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
write!(dest, "{} ", self.0)?;
|
||||
self.1.to_css(dest)
|
||||
}
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-counter-styles/#counter-style-fallback
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Clone, Debug, ToCss)]
|
||||
pub struct Fallback(pub CustomIdent);
|
||||
|
||||
impl Parse for Fallback {
|
||||
|
@ -501,12 +494,6 @@ impl Parse for Fallback {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToCss for Fallback {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
self.0.to_css(dest)
|
||||
}
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-counter-styles/#descdef-counter-style-symbols
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Symbols(pub Vec<Symbol>);
|
||||
|
@ -542,7 +529,7 @@ impl ToCss for Symbols {
|
|||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-counter-styles/#descdef-counter-style-additive-symbols
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Clone, Debug, ToCss)]
|
||||
pub struct AdditiveSymbols(pub Vec<AdditiveTuple>);
|
||||
|
||||
impl Parse for AdditiveSymbols {
|
||||
|
@ -556,14 +543,8 @@ impl Parse for AdditiveSymbols {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToCss for AdditiveSymbols {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
self.0.to_css(dest)
|
||||
}
|
||||
}
|
||||
|
||||
/// <integer> && <symbol>
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Clone, Debug, ToCss)]
|
||||
pub struct AdditiveTuple {
|
||||
/// <integer>
|
||||
pub weight: u32,
|
||||
|
@ -588,15 +569,8 @@ impl Parse for AdditiveTuple {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToCss for AdditiveTuple {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
write!(dest, "{} ", self.weight)?;
|
||||
self.symbol.to_css(dest)
|
||||
}
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-counter-styles/#counter-style-speak-as
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Clone, Debug, ToCss)]
|
||||
pub enum SpeakAs {
|
||||
/// auto
|
||||
Auto,
|
||||
|
@ -639,15 +613,3 @@ impl Parse for SpeakAs {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for SpeakAs {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match *self {
|
||||
SpeakAs::Auto => dest.write_str("auto"),
|
||||
SpeakAs::Bullets => dest.write_str("bullets"),
|
||||
SpeakAs::Numbers => dest.write_str("numbers"),
|
||||
SpeakAs::Words => dest.write_str("words"),
|
||||
SpeakAs::Other(ref other) => other.to_css(dest),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue