From 36db6f9cddf878262f8a94a93e91c75c6e59688e Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Thu, 8 Mar 2018 11:18:49 +0100 Subject: [PATCH] Derive ToCss for FontSettings --- components/style/values/generics/font.rs | 29 +++--------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/components/style/values/generics/font.rs b/components/style/values/generics/font.rs index c498a3cfaef..1e7a0f957ee 100644 --- a/components/style/values/generics/font.rs +++ b/components/style/values/generics/font.rs @@ -68,8 +68,9 @@ where } /// A value both for font-variation-settings and font-feature-settings. -#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue)] -pub struct FontSettings(pub Box<[T]>); +#[css(comma)] +#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +pub struct FontSettings(#[css(if_empty = "normal", iterable)] pub Box<[T]>); impl FontSettings { /// Default value of font settings as `normal`. @@ -96,30 +97,6 @@ impl Parse for FontSettings { } } -impl ToCss for FontSettings { - /// https://drafts.csswg.org/css-fonts-4/#descdef-font-face-font-feature-settings - /// https://drafts.csswg.org/css-fonts-4/#font-variation-settings-def - fn to_css(&self, dest: &mut CssWriter) -> fmt::Result - where - W: Write, - { - if self.0.is_empty() { - return dest.write_str("normal"); - } - - let mut first = true; - for item in self.0.iter() { - if !first { - dest.write_str(", ")?; - } - first = false; - item.to_css(dest)?; - } - - Ok(()) - } -} - /// A font four-character tag, represented as a u32 for convenience. /// /// See: