Bug 1374233 - Part 13: Use NonNegative{*} types for components of Shadow and Filter.

MozReview-Commit-ID: Im4KGy1n9IJ
This commit is contained in:
Boris Chiou 2017-07-24 18:08:27 +08:00
parent 6dd8b159d7
commit 8651acd94c
13 changed files with 84 additions and 53 deletions

View file

@ -733,6 +733,20 @@ impl<T: Parse> Parse for Either<NonNegativeLength, T> {
}
}
impl NonNegativeLength {
/// Returns a `zero` length.
#[inline]
pub fn zero() -> Self {
Length::zero().into()
}
/// Get an absolute length from a px value.
#[inline]
pub fn from_px(px_value: CSSFloat) -> Self {
Length::from_px(px_value.max(0.)).into()
}
}
/// Either a NonNegativeLength or the `normal` keyword.
pub type NonNegativeLengthOrNormal = Either<NonNegativeLength, Normal>;