From 3ee6598abb7acdfb6147ac56e2df6dad0173183e Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sat, 17 Jun 2017 02:45:52 +0200 Subject: [PATCH] Derive ToCss for some counter-style descriptors --- components/style/counter_style/mod.rs | 48 +++------------------------ 1 file changed, 5 insertions(+), 43 deletions(-) diff --git a/components/style/counter_style/mod.rs b/components/style/counter_style/mod.rs index c189429fb909..cfe35bccf05e 100644 --- a/components/style/counter_style/mod.rs +++ b/components/style/counter_style/mod.rs @@ -469,7 +469,7 @@ fn bound_to_css(range: Option, 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(&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(&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); @@ -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); impl Parse for AdditiveSymbols { @@ -556,14 +543,8 @@ impl Parse for AdditiveSymbols { } } -impl ToCss for AdditiveSymbols { - fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { - self.0.to_css(dest) - } -} - /// && -#[derive(Debug, Clone)] +#[derive(Clone, Debug, ToCss)] pub struct AdditiveTuple { /// pub weight: u32, @@ -588,15 +569,8 @@ impl Parse for AdditiveTuple { } } -impl ToCss for AdditiveTuple { - fn to_css(&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(&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), - } - } -}