Derive the most trivial ToCss implementations 🌋

For now, all variants get serialised as the space-separated serialisations
of their fields. Unit variants are not supported.
This commit is contained in:
Anthony Ramine 2017-06-04 15:45:09 +02:00
parent 6d6f03974d
commit c4f1d647a0
18 changed files with 113 additions and 263 deletions

View file

@ -481,9 +481,9 @@ pub struct Shadow {
/// A `<number>` value.
pub type Number = CSSFloat;
#[derive(Debug, Copy, Clone, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Copy, Debug, PartialEq, ToCss)]
pub enum NumberOrPercentage {
Percentage(Percentage),
Number(Number),
@ -512,15 +512,6 @@ impl ToComputedValue for specified::NumberOrPercentage {
}
}
impl ToCss for NumberOrPercentage {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
match *self {
NumberOrPercentage::Percentage(percentage) => percentage.to_css(dest),
NumberOrPercentage::Number(number) => number.to_css(dest),
}
}
}
/// A type used for opacity.
pub type Opacity = CSSFloat;