diff options
author | Mantaroh Yoshinaga <mantaroh@gmail.com> | 2017-06-22 15:14:03 +0900 |
---|---|---|
committer | Mantaroh Yoshinaga <mantaroh@gmail.com> | 2017-06-23 10:32:50 +0900 |
commit | c89c938623d0a742b869f326ee496e56fc69721f (patch) | |
tree | a08269aa3a57aa9c9fe46a35e6ff83e635005e36 | |
parent | efed75ae5a0a36006db25198961fb91386415cae (diff) | |
download | servo-c89c938623d0a742b869f326ee496e56fc69721f.tar.gz servo-c89c938623d0a742b869f326ee496e56fc69721f.zip |
Add get_zero_value for IntermediateSVGPaint.
-rw-r--r-- | components/style/properties/helpers/animated_properties.mako.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index a78af95120b..3874f972a25 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -2765,7 +2765,7 @@ impl Animatable for IntermediateRGBA { #[inline] fn get_zero_value(&self) -> Option<Self> { - Some(IntermediateRGBA::new(0., 0., 0., 1.)) + Some(IntermediateRGBA::transparent()) } #[inline] @@ -2982,6 +2982,14 @@ impl Animatable for IntermediateSVGPaint { Ok(self.kind.compute_squared_distance(&other.kind)? + self.fallback.compute_squared_distance(&other.fallback)?) } + + #[inline] + fn get_zero_value(&self) -> Option<Self> { + Some(IntermediateSVGPaint { + kind: option_try!(self.kind.get_zero_value()), + fallback: self.fallback.and_then(|v| v.get_zero_value()), + }) + } } impl Animatable for IntermediateSVGPaintKind { @@ -3012,6 +3020,18 @@ impl Animatable for IntermediateSVGPaintKind { _ => Err(()) } } + + #[inline] + fn get_zero_value(&self) -> Option<Self> { + match self { + &SVGPaintKind::Color(ref color) => color.get_zero_value() + .map(SVGPaintKind::Color), + &SVGPaintKind::None | + &SVGPaintKind::ContextFill | + &SVGPaintKind::ContextStroke => Some(self.clone()), + _ => None, + } + } } #[derive(Copy, Clone, Debug, PartialEq)] |