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 app_units::Au;
use cssparser::Parser;
use parser::{Parse, ParserContext};
use std::fmt;
use style_traits::ToCss;
use values::computed::{Context, ToComputedValue};
use values::generics::border::BorderCornerRadius as GenericBorderCornerRadius;
use values::generics::border::BorderImageSideWidth as GenericBorderImageSideWidth;
@ -20,7 +18,7 @@ use values::specified::length::{Length, LengthOrPercentage};
/// A specified value for a single side of the `border-width` property.
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
#[derive(Clone, Debug, HasViewportPercentage, PartialEq, ToCss)]
pub enum BorderSideWidth {
/// `thin`
Thin,
@ -73,17 +71,6 @@ impl Parse for BorderSideWidth {
}
}
impl ToCss for BorderSideWidth {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
match *self {
BorderSideWidth::Thin => dest.write_str("thin"),
BorderSideWidth::Medium => dest.write_str("medium"),
BorderSideWidth::Thick => dest.write_str("thick"),
BorderSideWidth::Length(ref length) => length.to_css(dest)
}
}
}
impl ToComputedValue for BorderSideWidth {
type ComputedValue = Au;