Navigation Menu

Skip to content

Commit

Permalink
Derive ToCss for some counter-style descriptors
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed Jun 17, 2017
1 parent 2b02a44 commit 3ee6598
Showing 1 changed file with 5 additions and 43 deletions.
48 changes: 5 additions & 43 deletions components/style/counter_style/mod.rs
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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>);
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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),
}
}
}

0 comments on commit 3ee6598

Please sign in to comment.