From e50847666c5f3ec6ec1f47270a007a89f9fdc8fd Mon Sep 17 00:00:00 2001 From: Xidorn Quan Date: Sun, 29 Apr 2018 09:03:31 +1000 Subject: [PATCH] style: Derive ToCss for values::generics::font::KeywordSize. Bug: 1434130 Reviewed-by: emilio MozReview-Commit-ID: 9ek3PcqYiU3 --- components/style/values/generics/font.rs | 29 ++++-------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/components/style/values/generics/font.rs b/components/style/values/generics/font.rs index 738a40a7844..8fb5e5245dd 100644 --- a/components/style/values/generics/font.rs +++ b/components/style/values/generics/font.rs @@ -187,18 +187,21 @@ impl SpecifiedValueInfo for KeywordInfo { /// CSS font keywords #[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, - ToAnimatedValue, ToAnimatedZero, SpecifiedValueInfo)] + SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero, ToCss)] #[allow(missing_docs)] pub enum KeywordSize { + #[css(keyword = "xx-small")] XXSmall, XSmall, Small, Medium, Large, XLarge, + #[css(keyword = "xx-large")] XXLarge, // This is not a real font keyword and will not parse // HTML font-size 7 corresponds to this value + #[css(skip)] XXXLarge, } @@ -216,30 +219,6 @@ impl Default for KeywordSize { } } -impl ToCss for KeywordSize { - fn to_css(&self, dest: &mut CssWriter) -> fmt::Result - where - W: Write, - { - dest.write_str(match *self { - KeywordSize::XXSmall => "xx-small", - KeywordSize::XSmall => "x-small", - KeywordSize::Small => "small", - KeywordSize::Medium => "medium", - KeywordSize::Large => "large", - KeywordSize::XLarge => "x-large", - KeywordSize::XXLarge => "xx-large", - KeywordSize::XXXLarge => { - debug_assert!( - false, - "We should never serialize specified values set via HTML presentation attributes" - ); - "-servo-xxx-large" - }, - }) - } -} - /// A generic value for the `font-style` property. /// /// https://drafts.csswg.org/css-fonts-4/#font-style-prop