mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Support unit variants when deriving ToCss
This commit is contained in:
parent
7d09ce0495
commit
45e8b0e8c7
14 changed files with 71 additions and 242 deletions
|
@ -182,8 +182,8 @@ impl<T: Parse> Parse for FontSettingTag<T> {
|
|||
|
||||
|
||||
/// A font settings value for font-variation-settings or font-feature-settings
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, ToCss)]
|
||||
pub enum FontSettings<T> {
|
||||
/// No settings (default)
|
||||
Normal,
|
||||
|
@ -191,15 +191,6 @@ pub enum FontSettings<T> {
|
|||
Tag(Vec<FontSettingTag<T>>)
|
||||
}
|
||||
|
||||
impl<T: ToCss> ToCss for FontSettings<T> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match *self {
|
||||
FontSettings::Normal => dest.write_str("normal"),
|
||||
FontSettings::Tag(ref ftvs) => ftvs.to_css(dest)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Parse> Parse for FontSettings<T> {
|
||||
/// https://www.w3.org/TR/css-fonts-3/#propdef-font-feature-settings
|
||||
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
||||
|
@ -290,8 +281,8 @@ pub struct SVGPaint<ColorType> {
|
|||
/// Whereas the spec only allows PaintServer
|
||||
/// to have a fallback, Gecko lets the context
|
||||
/// properties have a fallback as well.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Debug, PartialEq, ToCss)]
|
||||
pub enum SVGPaintKind<ColorType> {
|
||||
/// `none`
|
||||
None,
|
||||
|
@ -378,18 +369,6 @@ impl<ColorType: Parse> Parse for SVGPaint<ColorType> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<ColorType: ToCss> ToCss for SVGPaintKind<ColorType> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match *self {
|
||||
SVGPaintKind::None => dest.write_str("none"),
|
||||
SVGPaintKind::ContextStroke => dest.write_str("context-stroke"),
|
||||
SVGPaintKind::ContextFill => dest.write_str("context-fill"),
|
||||
SVGPaintKind::Color(ref color) => color.to_css(dest),
|
||||
SVGPaintKind::PaintServer(ref server) => server.to_css(dest),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<ColorType: ToCss> ToCss for SVGPaint<ColorType> {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
self.kind.to_css(dest)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue