mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Cleanup position and make use of generic Position for its users
This commit is contained in:
parent
3f53fb148d
commit
61a17993eb
10 changed files with 277 additions and 677 deletions
|
@ -36,9 +36,9 @@ use values::computed::{Angle, LengthOrPercentageOrAuto, LengthOrPercentageOrNone
|
|||
use values::computed::{BorderRadiusSize, ClipRect, LengthOrNone};
|
||||
use values::computed::{CalcLengthOrPercentage, Context, LengthOrPercentage};
|
||||
use values::computed::{MaxLength, MinLength};
|
||||
use values::computed::position::{HorizontalPosition, Position, VerticalPosition};
|
||||
use values::computed::position::{HorizontalPosition, VerticalPosition};
|
||||
use values::computed::ToComputedValue;
|
||||
|
||||
use values::generics::position as generic_position;
|
||||
|
||||
|
||||
/// A given transition property, that is either `All`, or an animatable
|
||||
|
@ -957,23 +957,24 @@ impl Interpolate for FontWeight {
|
|||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-transitions/#animtype-simple-list
|
||||
impl Interpolate for Position {
|
||||
impl<H: Interpolate, V: Interpolate> Interpolate for generic_position::Position<H, V> {
|
||||
#[inline]
|
||||
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
|
||||
Ok(Position {
|
||||
Ok(generic_position::Position {
|
||||
horizontal: try!(self.horizontal.interpolate(&other.horizontal, progress)),
|
||||
vertical: try!(self.vertical.interpolate(&other.vertical, progress)),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl RepeatableListInterpolate for Position {}
|
||||
impl<H, V> RepeatableListInterpolate for generic_position::Position<H, V>
|
||||
where H: RepeatableListInterpolate, V: RepeatableListInterpolate {}
|
||||
|
||||
/// https://drafts.csswg.org/css-transitions/#animtype-simple-list
|
||||
impl Interpolate for HorizontalPosition {
|
||||
#[inline]
|
||||
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
|
||||
Ok(HorizontalPosition(try!(self.0.interpolate(&other.0, progress))))
|
||||
self.0.interpolate(&other.0, progress).map(generic_position::HorizontalPosition)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -983,7 +984,7 @@ impl RepeatableListInterpolate for HorizontalPosition {}
|
|||
impl Interpolate for VerticalPosition {
|
||||
#[inline]
|
||||
fn interpolate(&self, other: &Self, progress: f64) -> Result<Self, ()> {
|
||||
Ok(VerticalPosition(try!(self.0.interpolate(&other.0, progress))))
|
||||
self.0.interpolate(&other.0, progress).map(generic_position::VerticalPosition)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2607,7 +2608,9 @@ impl ComputeDistance for FontWeight {
|
|||
}
|
||||
}
|
||||
|
||||
impl ComputeDistance for Position {
|
||||
impl<H, V> ComputeDistance for generic_position::Position<H, V>
|
||||
where H: ComputeDistance, V: ComputeDistance
|
||||
{
|
||||
#[inline]
|
||||
fn compute_distance(&self, other: &Self) -> Result<f64, ()> {
|
||||
self.compute_squared_distance(other).map(|sd| sd.sqrt())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue