style: linear(...) easing: Simplify piecewise linear implementation given parsing simplification

Differential Revision: https://phabricator.services.mozilla.com/D150163
This commit is contained in:
David Shin 2022-06-28 11:31:34 +00:00 committed by Martin Robinson
parent e3e2ee64de
commit c49a49d7a5
2 changed files with 4 additions and 8 deletions

View file

@ -26,7 +26,7 @@ pub struct PiecewiseLinearFunction {
} }
/// Parameters to define one linear stop. /// Parameters to define one linear stop.
pub type PiecewiseLinearFunctionBuildParameters = (CSSFloat, Option<CSSFloat>, Option<CSSFloat>); pub type PiecewiseLinearFunctionBuildParameters = (CSSFloat, Option<CSSFloat>);
impl PiecewiseLinearFunction { impl PiecewiseLinearFunction {
/// Interpolate y value given x and two points. The linear function will be rooted at the asymptote. /// Interpolate y value given x and two points. The linear function will be rooted at the asymptote.
@ -97,8 +97,8 @@ impl PiecewiseLinearFunction {
Iter: Iterator<Item = PiecewiseLinearFunctionBuildParameters> + ExactSizeIterator, Iter: Iterator<Item = PiecewiseLinearFunctionBuildParameters> + ExactSizeIterator,
{ {
let mut builder = PiecewiseLinearFunctionBuilder::with_capacity(iter.len()); let mut builder = PiecewiseLinearFunctionBuilder::with_capacity(iter.len());
for (y, x_start, x_end) in iter { for (y, x_start) in iter {
builder = builder.push(y, x_start, x_end); builder = builder.push(y, x_start);
} }
builder.build() builder.build()
} }
@ -161,11 +161,8 @@ impl PiecewiseLinearFunctionBuilder {
/// the x value is calculated later. If the end x value is specified, a flat segment /// the x value is calculated later. If the end x value is specified, a flat segment
/// is generated. If start x value is not specified but end x is, it is treated as /// is generated. If start x value is not specified but end x is, it is treated as
/// start x. /// start x.
pub fn push(mut self, y: CSSFloat, x_start: Option<CSSFloat>, x_end: Option<CSSFloat>) -> Self { pub fn push(mut self, y: CSSFloat, x_start: Option<CSSFloat>) -> Self {
self.create_entry(y, x_start); self.create_entry(y, x_start);
if x_end.is_some() {
self.create_entry(y, x_end.map(|x| x));
}
self self
} }

View file

@ -25,7 +25,6 @@ impl ComputedLinearStop {
( (
x.output, x.output,
x.input.into_rust().map(|x| x.0), x.input.into_rust().map(|x| x.0),
None,
) )
} }
} }