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

@ -7,8 +7,6 @@
use cssparser::Parser;
use euclid::Point2D;
use parser::{Parse, ParserContext};
use std::fmt;
use style_traits::ToCss;
use values::computed::{LengthOrPercentage as ComputedLengthOrPercentage, Context, ToComputedValue};
use values::computed::transform::TimingFunction as ComputedTimingFunction;
use values::generics::transform::{StepPosition, TimingFunction as GenericTimingFunction};
@ -22,7 +20,7 @@ pub type TransformOrigin = GenericTransformOrigin<OriginComponent<X>, OriginComp
/// The specified value of a component of a CSS `<transform-origin>`.
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)]
pub enum OriginComponent<S> {
/// `center`
Center,
@ -99,20 +97,6 @@ impl<S> Parse for OriginComponent<S>
}
}
impl<S: ToCss> ToCss for OriginComponent<S>
where S: ToCss,
{
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
where W: fmt::Write,
{
match *self {
OriginComponent::Center => dest.write_str("center"),
OriginComponent::Length(ref lop) => lop.to_css(dest),
OriginComponent::Side(ref keyword) => keyword.to_css(dest),
}
}
}
impl<S> ToComputedValue for OriginComponent<S>
where S: Side,
{