mirror of
https://github.com/servo/servo.git
synced 2025-07-03 05:23:38 +01:00
Change AnimatedValue for NonNegativeNumber to CSSFloat
This commit is contained in:
parent
da5acc81d2
commit
f89ebf7fe9
5 changed files with 22 additions and 42 deletions
|
@ -12,7 +12,7 @@ use std::cmp;
|
|||
use values::Impossible;
|
||||
use values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero};
|
||||
use values::animated::color::RGBA;
|
||||
use values::computed::{Angle, NonNegativeNumber};
|
||||
use values::computed::{Angle, Number};
|
||||
use values::computed::length::{Length, NonNegativeLength};
|
||||
use values::distance::{ComputeSquaredDistance, SquaredDistance};
|
||||
use values::generics::effects::BoxShadow as GenericBoxShadow;
|
||||
|
@ -42,11 +42,11 @@ pub struct FilterList(pub Vec<Filter>);
|
|||
|
||||
/// An animated value for a single `filter`.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub type Filter = GenericFilter<Angle, NonNegativeNumber, NonNegativeLength, SimpleShadow>;
|
||||
pub type Filter = GenericFilter<Angle, Number, NonNegativeLength, SimpleShadow>;
|
||||
|
||||
/// An animated value for a single `filter`.
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
pub type Filter = GenericFilter<Angle, NonNegativeNumber, NonNegativeLength, Impossible>;
|
||||
pub type Filter = GenericFilter<Angle, Number, NonNegativeLength, Impossible>;
|
||||
|
||||
/// An animated value for the `drop-shadow()` filter.
|
||||
pub type SimpleShadow = GenericSimpleShadow<Option<RGBA>, Length, NonNegativeLength>;
|
||||
|
@ -155,25 +155,11 @@ impl ComputeSquaredDistance for BoxShadow {
|
|||
impl ToAnimatedValue for ComputedFilterList {
|
||||
type AnimatedValue = FilterList;
|
||||
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
#[inline]
|
||||
fn to_animated_value(self) -> Self::AnimatedValue {
|
||||
FilterList(self.0)
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
#[inline]
|
||||
fn to_animated_value(self) -> Self::AnimatedValue {
|
||||
FilterList(self.0.to_animated_value())
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
#[inline]
|
||||
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
|
||||
ComputedFilterList(animated.0)
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
#[inline]
|
||||
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
|
||||
ComputedFilterList(ToAnimatedValue::from_animated_value(animated.0))
|
||||
|
|
|
@ -19,7 +19,6 @@ use values::computed::GreaterThanOrEqualToOneNumber as ComputedGreaterThanOrEqua
|
|||
use values::computed::MaxLength as ComputedMaxLength;
|
||||
use values::computed::MozLength as ComputedMozLength;
|
||||
use values::computed::NonNegativeLength as ComputedNonNegativeLength;
|
||||
use values::computed::NonNegativeNumber as ComputedNonNegativeNumber;
|
||||
use values::specified::url::SpecifiedUrl;
|
||||
|
||||
pub mod color;
|
||||
|
@ -263,20 +262,6 @@ trivial_to_animated_value!(ComputedUrl);
|
|||
trivial_to_animated_value!(bool);
|
||||
trivial_to_animated_value!(f32);
|
||||
|
||||
impl ToAnimatedValue for ComputedNonNegativeNumber {
|
||||
type AnimatedValue = Self;
|
||||
|
||||
#[inline]
|
||||
fn to_animated_value(self) -> Self {
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
|
||||
animated.0.max(0.).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl ToAnimatedValue for ComputedGreaterThanOrEqualToOneNumber {
|
||||
type AnimatedValue = Self;
|
||||
|
||||
|
|
|
@ -429,6 +429,20 @@ pub type Number = CSSFloat;
|
|||
/// A wrapper of Number, but the value >= 0.
|
||||
pub type NonNegativeNumber = NonNegative<CSSFloat>;
|
||||
|
||||
impl ToAnimatedValue for NonNegativeNumber {
|
||||
type AnimatedValue = CSSFloat;
|
||||
|
||||
#[inline]
|
||||
fn to_animated_value(self) -> Self::AnimatedValue {
|
||||
self.0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn from_animated_value(animated: Self::AnimatedValue) -> Self {
|
||||
animated.max(0.).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<CSSFloat> for NonNegativeNumber {
|
||||
#[inline]
|
||||
fn from(number: CSSFloat) -> NonNegativeNumber {
|
||||
|
|
|
@ -64,7 +64,7 @@ where
|
|||
|
||||
/// Convenience void type to disable some properties and values through types.
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, MallocSizeOf, Serialize))]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue, ToCss)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, ToAnimatedValue, ToComputedValue, ToCss)]
|
||||
pub enum Impossible {}
|
||||
|
||||
// FIXME(nox): This should be derived but the derive code cannot cope
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue