Bug 1374233 - Part 8: Implement ToAnimatedValue for BorderCornerRadius.

BorderCornerRadius should always be non-negative, so we can implemennt
ToAnimatedValue for it directly, for properties:
1. border-{*}-radius
2. -moz-outline-{*}-radius

MozReview-Commit-ID: HEbeHz9Hfkd
This commit is contained in:
Boris Chiou 2017-07-21 13:01:56 +08:00
parent e72a0f126e
commit b37f270c65
4 changed files with 33 additions and 10 deletions

View file

@ -351,6 +351,20 @@ impl LengthOrPercentage {
},
}
}
/// Returns the clamped non-negative values.
#[inline]
pub fn clamp_to_non_negative(self) -> Self {
match self {
LengthOrPercentage::Length(length) => {
LengthOrPercentage::Length(Au(::std::cmp::max(length.0, 0)))
},
LengthOrPercentage::Percentage(percentage) => {
LengthOrPercentage::Percentage(Percentage(percentage.0.max(0.)))
},
_ => self
}
}
}
impl fmt::Debug for LengthOrPercentage {