mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Support unit variants when deriving ToCss
This commit is contained in:
parent
7d09ce0495
commit
45e8b0e8c7
14 changed files with 71 additions and 242 deletions
|
@ -54,7 +54,7 @@ where
|
|||
|
||||
/// A generic spacing value for the `letter-spacing` and `word-spacing` properties.
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue)]
|
||||
#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToComputedValue, ToCss)]
|
||||
pub enum Spacing<Value> {
|
||||
/// `normal`
|
||||
Normal,
|
||||
|
@ -117,22 +117,9 @@ impl<Value> Animatable for Spacing<Value>
|
|||
}
|
||||
}
|
||||
|
||||
impl<Value> ToCss for Spacing<Value>
|
||||
where Value: ToCss,
|
||||
{
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
|
||||
where W: fmt::Write
|
||||
{
|
||||
match *self {
|
||||
Spacing::Normal => dest.write_str("normal"),
|
||||
Spacing::Value(ref value) => value.to_css(dest),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A generic value for the `line-height` property.
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, HasViewportPercentage, PartialEq, ToCss)]
|
||||
pub enum LineHeight<Number, LengthOrPercentage> {
|
||||
/// `normal`
|
||||
Normal,
|
||||
|
@ -152,19 +139,3 @@ impl<N, L> LineHeight<N, L> {
|
|||
LineHeight::Normal
|
||||
}
|
||||
}
|
||||
|
||||
impl<N, L> ToCss for LineHeight<N, L>
|
||||
where N: ToCss, L: ToCss,
|
||||
{
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
|
||||
where W: fmt::Write,
|
||||
{
|
||||
match *self {
|
||||
LineHeight::Normal => dest.write_str("normal"),
|
||||
#[cfg(feature = "gecko")]
|
||||
LineHeight::MozBlockHeight => dest.write_str("-moz-block-height"),
|
||||
LineHeight::Number(ref number) => number.to_css(dest),
|
||||
LineHeight::Length(ref value) => value.to_css(dest),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue