mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Derive ToCss for FontSize
This commit is contained in:
parent
ca45695db1
commit
2aa5f68c92
2 changed files with 4 additions and 17 deletions
|
@ -162,14 +162,16 @@ impl Parse for FontTag {
|
|||
}
|
||||
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf)]
|
||||
#[derive(PartialEq, ToAnimatedValue, ToAnimatedZero)]
|
||||
#[derive(PartialEq, ToAnimatedValue, ToAnimatedZero, ToCss)]
|
||||
/// Additional information for keyword-derived font sizes.
|
||||
pub struct KeywordInfo<Length> {
|
||||
/// The keyword used
|
||||
pub kw: KeywordSize,
|
||||
/// A factor to be multiplied by the computed size of the keyword
|
||||
#[css(skip)]
|
||||
pub factor: f32,
|
||||
/// An additional Au offset to add to the kw*factor in the case of calcs
|
||||
#[css(skip)]
|
||||
pub offset: Length,
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ impl ToComputedValue for FontWeight {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq)]
|
||||
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)]
|
||||
/// A specified font-size value
|
||||
pub enum FontSize {
|
||||
/// A length; e.g. 10px.
|
||||
|
@ -142,21 +142,6 @@ pub enum FontSize {
|
|||
System(SystemFont)
|
||||
}
|
||||
|
||||
impl ToCss for FontSize {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
match *self {
|
||||
FontSize::Length(ref lop) => lop.to_css(dest),
|
||||
FontSize::Keyword(info) => info.kw.to_css(dest),
|
||||
FontSize::Smaller => dest.write_str("smaller"),
|
||||
FontSize::Larger => dest.write_str("larger"),
|
||||
FontSize::System(sys) => sys.to_css(dest),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<LengthOrPercentage> for FontSize {
|
||||
fn from(other: LengthOrPercentage) -> Self {
|
||||
FontSize::Length(other)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue