Skip to content

Commit

Permalink
Add get_zero_value for IntermediateSVGPaint.
Browse files Browse the repository at this point in the history
  • Loading branch information
mantaroh committed Jun 23, 2017
1 parent efed75a commit c89c938
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion components/style/properties/helpers/animated_properties.mako.rs
Expand Up @@ -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]
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)]
Expand Down

0 comments on commit c89c938

Please sign in to comment.