Bug 1374233 - Part 2: Add NonNegativeAu.

Add values::computed::NonNegativeAu, so BorderSideWith could be computed
to this non-negative Au, for the following properties:
1. outline-width
2. border-{*}-width
3. column-rule-width
4. -webkit-text-stroke-width

MozReview-Commit-ID: ASHaB2F7VtM
This commit is contained in:
Boris Chiou 2017-07-20 13:11:37 +08:00
parent 4cc97746f2
commit 191c2a282b
16 changed files with 113 additions and 64 deletions

View file

@ -9,8 +9,10 @@
//! module's raison d'être is to ultimately contain all these types.
use app_units::Au;
use std::cmp::max;
use values::computed::Angle as ComputedAngle;
use values::computed::GreaterThanOrEqualToOneNumber as ComputedGreaterThanOrEqualToOneNumber;
use values::computed::NonNegativeAu;
use values::computed::NonNegativeNumber as ComputedNonNegativeNumber;
use values::specified::url::SpecifiedUrl;
@ -118,6 +120,20 @@ impl ToAnimatedValue for ComputedGreaterThanOrEqualToOneNumber {
}
}
impl ToAnimatedValue for NonNegativeAu {
type AnimatedValue = Self;
#[inline]
fn to_animated_value(self) -> Self {
self
}
#[inline]
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
max(animated.0, Au(0)).into()
}
}
/// Returns a value similar to `self` that represents zero.
pub trait ToAnimatedZero: Sized {
/// Returns a value that, when added with an underlying value, will produce the underlying