Support unit variants when deriving ToCss

This commit is contained in:
Anthony Ramine 2017-06-07 14:53:31 +02:00
parent 7d09ce0495
commit 45e8b0e8c7
14 changed files with 71 additions and 242 deletions

View file

@ -450,8 +450,8 @@ impl PropertyDeclarationIdSet {
% endfor
/// An enum to represent a CSS Wide keyword.
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Copy, Clone, Debug, Eq, PartialEq, ToCss)]
pub enum CSSWideKeyword {
/// The `initial` keyword.
Initial,
@ -483,12 +483,6 @@ impl CSSWideKeyword {
}
}
impl ToCss for CSSWideKeyword {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
dest.write_str(self.to_str())
}
}
impl Parse for CSSWideKeyword {
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
let ident = input.expect_ident()?;
@ -628,8 +622,8 @@ impl LonghandId {
}
/// An identifier for a given shorthand property.
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Copy, Debug, Eq, PartialEq, ToCss)]
pub enum ShorthandId {
% for property in data.shorthands:
/// ${property.name}
@ -637,14 +631,6 @@ pub enum ShorthandId {
% endfor
}
impl ToCss for ShorthandId {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
where W: fmt::Write,
{
dest.write_str(self.name())
}
}
impl ShorthandId {
/// Get the name for this shorthand property.
pub fn name(&self) -> &'static str {