Auto merge of #17215 - servo:derive-all-the-things, r=emilio

Derive more ToCss impls

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17215)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-06-09 05:00:45 -07:00 committed by GitHub
commit 1555f0fc41
15 changed files with 54 additions and 96 deletions

View file

@ -427,8 +427,8 @@ ${helpers.predefined_type("word-spacing",
no_viewport_percentage!(SpecifiedValue);
pub mod computed_value {
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, PartialEq, ToCss)]
pub enum T {
Keyword(KeywordValue),
None,
@ -443,33 +443,14 @@ ${helpers.predefined_type("word-spacing",
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, PartialEq, ToCss)]
pub enum SpecifiedValue {
Keyword(KeywordValue),
None,
String(String),
}
impl ToCss for computed_value::T {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
match *self {
computed_value::T::Keyword(ref keyword) => keyword.to_css(dest),
computed_value::T::None => dest.write_str("none"),
computed_value::T::String(ref string) => write!(dest, "\"{}\"", string),
}
}
}
impl ToCss for SpecifiedValue {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
match *self {
SpecifiedValue::Keyword(ref keyword) => keyword.to_css(dest),
SpecifiedValue::None => dest.write_str("none"),
SpecifiedValue::String(ref string) => write!(dest, "\"{}\"", string),
}
}
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum KeywordValue {