Bug 1434130 part 5 - Derive ToCss for values::generics::font::KeywordSize. r?emilio
MozReview-Commit-ID: 9ek3PcqYiU3
--- 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)]