mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-28 12:45:27 +00:00
servo: Merge #12768 - Fix interpolation of CalcLengthOrPercentage (fixes #12765) (from nox:fix-transition); r=SimonSapin
Source-Repo: https://github.com/servo/servo Source-Revision: 44ebbfc20de186f66eb39f6c076b369ed4e3c8ed
This commit is contained in:
parent
32a8bd6f7d
commit
9b8f0a36bf
@ -326,9 +326,25 @@ impl Interpolate for CSSParserColor {
|
||||
impl Interpolate for CalcLengthOrPercentage {
|
||||
#[inline]
|
||||
fn interpolate(&self, other: &Self, time: f64) -> Result<Self, ()> {
|
||||
fn interpolate_half<T>(this: Option<T>,
|
||||
other: Option<T>,
|
||||
time: f64)
|
||||
-> Result<Option<T>, ()>
|
||||
where T: Default + Interpolate
|
||||
{
|
||||
match (this, other) {
|
||||
(None, None) => Ok(None),
|
||||
(this, other) => {
|
||||
let this = this.unwrap_or(T::default());
|
||||
let other = other.unwrap_or(T::default());
|
||||
this.interpolate(&other, time).map(Some)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(CalcLengthOrPercentage {
|
||||
length: self.length.interpolate(&other.length, time).ok().and_then(|x|x),
|
||||
percentage: self.percentage.interpolate(&other.percentage, time).ok().and_then(|x|x),
|
||||
length: try!(interpolate_half(self.length, other.length, time)),
|
||||
percentage: try!(interpolate_half(self.percentage, other.percentage, time)),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -7,14 +7,13 @@
|
||||
//!
|
||||
//! [basic-shape]: https://drafts.csswg.org/css-shapes/#typedef-basic-shape
|
||||
|
||||
use app_units::Au;
|
||||
use cssparser::{Parser, ToCss};
|
||||
use properties::shorthands::{parse_four_sides, serialize_four_sides};
|
||||
use std::fmt;
|
||||
use values::computed::basic_shape as computed_basic_shape;
|
||||
use values::computed::{Context, ToComputedValue, ComputedValueAsSpecified};
|
||||
use values::specified::position::{Position, PositionComponent};
|
||||
use values::specified::{BorderRadiusSize, Length, LengthOrPercentage, Percentage};
|
||||
use values::specified::position::Position;
|
||||
use values::specified::{BorderRadiusSize, LengthOrPercentage, Percentage};
|
||||
|
||||
#[derive(Clone, PartialEq, Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
|
Loading…
Reference in New Issue
Block a user