style: Derive ToCss for values::generics::font::KeywordSize.

Bug: 1434130
Reviewed-by: emilio
MozReview-Commit-ID: 9ek3PcqYiU3
This commit is contained in:
Xidorn Quan 2018-04-29 09:03:31 +10:00 committed by Emilio Cobos Álvarez
parent 54d8863e60
commit e50847666c
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -187,18 +187,21 @@ impl<Length> SpecifiedValueInfo for KeywordInfo<Length> {
/// 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<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