mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Make Interpolate impl generic for Either
This commit is contained in:
parent
0d556ddbf0
commit
b489c4ed90
1 changed files with 12 additions and 5 deletions
|
@ -34,7 +34,6 @@ use values::computed::{Angle, LengthOrPercentageOrAuto, LengthOrPercentageOrNone
|
||||||
use values::computed::{BorderRadiusSize, ClipRect, LengthOrNone};
|
use values::computed::{BorderRadiusSize, ClipRect, LengthOrNone};
|
||||||
use values::computed::{CalcLengthOrPercentage, Context, LengthOrPercentage};
|
use values::computed::{CalcLengthOrPercentage, Context, LengthOrPercentage};
|
||||||
use values::computed::{MaxLength, MinLength};
|
use values::computed::{MaxLength, MinLength};
|
||||||
use values::computed::ColorOrAuto;
|
|
||||||
use values::computed::position::{HorizontalPosition, Position, VerticalPosition};
|
use values::computed::position::{HorizontalPosition, Position, VerticalPosition};
|
||||||
use values::computed::ToComputedValue;
|
use values::computed::ToComputedValue;
|
||||||
use values::specified::Angle as SpecifiedAngle;
|
use values::specified::Angle as SpecifiedAngle;
|
||||||
|
@ -399,6 +398,13 @@ impl Interpolate for Au {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Interpolate for Auto {
|
||||||
|
#[inline]
|
||||||
|
fn interpolate(&self, _other: &Self, _progress: f64) -> Result<Self, ()> {
|
||||||
|
Ok(Auto)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl <T> Interpolate for Option<T>
|
impl <T> Interpolate for Option<T>
|
||||||
where T: Interpolate,
|
where T: Interpolate,
|
||||||
{
|
{
|
||||||
|
@ -1832,16 +1838,17 @@ impl Interpolate for TransformList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://drafts.csswg.org/css-transitions-1/#animtype-color
|
impl<T, U> Interpolate for Either<T, U>
|
||||||
impl Interpolate for ColorOrAuto {
|
where T: Interpolate + Copy, U: Interpolate + Copy,
|
||||||
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
|
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
|
||||||
match (*self, *other) {
|
match (*self, *other) {
|
||||||
(Either::First(ref this), Either::First(ref other)) => {
|
(Either::First(ref this), Either::First(ref other)) => {
|
||||||
this.interpolate(&other, progress).map(Either::First)
|
this.interpolate(&other, progress).map(Either::First)
|
||||||
},
|
},
|
||||||
(Either::Second(Auto), Either::Second(Auto)) => {
|
(Either::Second(ref this), Either::Second(ref other)) => {
|
||||||
Ok(Either::Second(Auto))
|
this.interpolate(&other, progress).map(Either::Second)
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
let interpolated = if progress < 0.5 { *self } else { *other };
|
let interpolated = if progress < 0.5 { *self } else { *other };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue