mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
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:
parent
e72a0f126e
commit
b37f270c65
4 changed files with 33 additions and 10 deletions
|
@ -11,6 +11,7 @@
|
|||
use app_units::Au;
|
||||
use std::cmp::max;
|
||||
use values::computed::Angle as ComputedAngle;
|
||||
use values::computed::BorderCornerRadius as ComputedBorderCornerRadius;
|
||||
use values::computed::GreaterThanOrEqualToOneNumber as ComputedGreaterThanOrEqualToOneNumber;
|
||||
use values::computed::NonNegativeAu;
|
||||
use values::computed::NonNegativeLengthOrPercentage as ComputedNonNegativeLengthOrPercentage;
|
||||
|
@ -160,14 +161,22 @@ impl ToAnimatedValue for ComputedNonNegativeLengthOrPercentage {
|
|||
|
||||
#[inline]
|
||||
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
|
||||
use values::computed::{LengthOrPercentage, Percentage};
|
||||
match animated.0 {
|
||||
LengthOrPercentage::Length(au) => LengthOrPercentage::Length(max(au, Au(0))).into(),
|
||||
LengthOrPercentage::Percentage(percentage) => {
|
||||
LengthOrPercentage::Percentage(Percentage(percentage.0.max(0.))).into()
|
||||
},
|
||||
_ => animated
|
||||
}
|
||||
animated.0.clamp_to_non_negative().into()
|
||||
}
|
||||
}
|
||||
|
||||
impl ToAnimatedValue for ComputedBorderCornerRadius {
|
||||
type AnimatedValue = Self;
|
||||
|
||||
#[inline]
|
||||
fn to_animated_value(self) -> Self {
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
|
||||
ComputedBorderCornerRadius::new(animated.0.width.clamp_to_non_negative(),
|
||||
animated.0.height.clamp_to_non_negative())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue