diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 84271a185a0..c881dab0ca7 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -475,6 +475,7 @@ def set_gecko_property(ffi_name, expr): #[allow(non_snake_case)] pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T { use values::generics::{SVGPaint, SVGPaintKind}; + use values::specified::url::SpecifiedUrl; use self::structs::nsStyleSVGPaintType; use self::structs::nsStyleSVGFallbackType; let ref paint = ${get_gecko_property(gecko_ffi_name)}; @@ -488,8 +489,13 @@ def set_gecko_property(ffi_name, expr): nsStyleSVGPaintType::eStyleSVGPaintType_ContextFill => SVGPaintKind::ContextFill, nsStyleSVGPaintType::eStyleSVGPaintType_ContextStroke => SVGPaintKind::ContextStroke, nsStyleSVGPaintType::eStyleSVGPaintType_Server => { - // FIXME (bug 1353966) this should animate - SVGPaintKind::None + unsafe { + SVGPaintKind::PaintServer( + SpecifiedUrl::from_url_value_data( + &(**paint.mPaint.mPaintServer.as_ref())._base + ).unwrap() + ) + } } nsStyleSVGPaintType::eStyleSVGPaintType_Color => { unsafe { SVGPaintKind::Color(convert_nscolor_to_rgba(*paint.mPaint.mColor.as_ref())) } diff --git a/components/style/values/generics/mod.rs b/components/style/values/generics/mod.rs index 7c3492e94e2..637735a0c66 100644 --- a/components/style/values/generics/mod.rs +++ b/components/style/values/generics/mod.rs @@ -323,13 +323,25 @@ impl SVGPaintKind { } } +/// Parse SVGPaint's fallback. +/// fallback is keyword(none) or Color. +/// https://svgwg.org/svg2-draft/painting.html#SpecifyingPaint +fn parse_fallback<'i, 't, ColorType: Parse>(context: &ParserContext, + input: &mut Parser<'i, 't>) + -> Option { + if input.try(|i| i.expect_ident_matching("none")).is_ok() { + None + } else { + input.try(|i| ColorType::parse(context, i)).ok() + } +} + impl Parse for SVGPaint { fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) -> Result> { if let Ok(url) = input.try(|i| SpecifiedUrl::parse(context, i)) { - let fallback = input.try(|i| ColorType::parse(context, i)); Ok(SVGPaint { kind: SVGPaintKind::PaintServer(url), - fallback: fallback.ok(), + fallback: parse_fallback(context, input), }) } else if let Ok(kind) = input.try(SVGPaintKind::parse_ident) { if let SVGPaintKind::None = kind { @@ -338,10 +350,9 @@ impl Parse for SVGPaint { fallback: None, }) } else { - let fallback = input.try(|i| ColorType::parse(context, i)); Ok(SVGPaint { kind: kind, - fallback: fallback.ok(), + fallback: parse_fallback(context, input), }) } } else if let Ok(color) = input.try(|i| ColorType::parse(context, i)) {