style: Hook up linear easing calculation for servo and expose it to C++

Differential Revision: https://phabricator.services.mozilla.com/D146838
This commit is contained in:
David Shin 2022-06-07 11:51:24 +00:00 committed by Martin Robinson
parent 6326a384a8
commit b31be826c4
3 changed files with 64 additions and 11 deletions

View file

@ -4,6 +4,7 @@
//! Computed types for CSS Easing functions.
use crate::piecewise_linear::PiecewiseLinearFunctionBuildParameters;
use crate::values::computed::{Integer, Number, Percentage};
use crate::values::generics::easing;
@ -15,3 +16,16 @@ pub type TimingFunction = ComputedTimingFunction;
/// A computed linear easing entry.
pub type ComputedLinearStop = easing::LinearStop<Number, Percentage>;
impl ComputedLinearStop {
/// Convert this type to entries that can be used to build PiecewiseLinearFunction.
pub fn to_piecewise_linear_build_parameters(
x: &ComputedLinearStop,
) -> PiecewiseLinearFunctionBuildParameters {
(
x.output,
x.input_start.into_rust().map(|x| x.0),
x.input_end.into_rust().map(|x| x.0),
)
}
}