Bug 1434130 part 5 - Derive ToCss for values::generics::font::KeywordSize. r=emilio
authorXidorn Quan <me@upsuper.org>
Sun, 29 Apr 2018 09:03:31 +1000
changeset 469756 10da0873e0a5874fcd64100a3ce3dc9a49b59452
parent 469755 543c9e49bfe5df7547448a28ebc663ef1620f406
child 469757 30d22ed91462076e8fbcfe78e631567164afda96
push id9174
push userarchaeopteryx@coole-files.de
push dateMon, 30 Apr 2018 15:33:30 +0000
treeherdermozilla-beta@1b1a8ab75f1f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1434130
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1434130 part 5 - Derive ToCss for values::generics::font::KeywordSize. r=emilio MozReview-Commit-ID: 9ek3PcqYiU3
servo/components/style/values/generics/font.rs
--- a/servo/components/style/values/generics/font.rs
+++ b/servo/components/style/values/generics/font.rs
@@ -182,28 +182,31 @@ where
 }
 
 impl<Length> SpecifiedValueInfo for KeywordInfo<Length> {
     const SUPPORTED_TYPES: u8 = <KeywordSize as SpecifiedValueInfo>::SUPPORTED_TYPES;
 }
 
 /// 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,
 }
 
 impl KeywordSize {
     /// Convert to an HTML <font size> value
     #[inline]
     pub fn html_size(self) -> u8 {
         self as u8
@@ -211,40 +214,16 @@ impl KeywordSize {
 }
 
 impl Default for KeywordSize {
     fn default() -> Self {
         KeywordSize::Medium
     }
 }
 
-impl ToCss for KeywordSize {
-    fn to_css<W>(&self, dest: &mut CssWriter<W>) -> 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
 #[allow(missing_docs)]
 #[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf,
          PartialEq, SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero)]
 pub enum FontStyle<Angle> {
     #[animation(error)]