mirror of
https://github.com/servo/servo.git
synced 2025-08-07 22:45:34 +01:00
Bug 1374233 - Part 13: Use NonNegative{*} types for components of Shadow and Filter.
MozReview-Commit-ID: Im4KGy1n9IJ
This commit is contained in:
parent
6dd8b159d7
commit
8651acd94c
13 changed files with 84 additions and 53 deletions
|
@ -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>;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue