mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
style: Derive ToCss for values::generics::font::KeywordSize.
Bug: 1434130 Reviewed-by: emilio MozReview-Commit-ID: 9ek3PcqYiU3
This commit is contained in:
parent
54d8863e60
commit
e50847666c
1 changed files with 4 additions and 25 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue