Skip to content

Commit

Permalink
style: linear(...) easing: Simplify piecewise linear implementation…
Browse files Browse the repository at this point in the history
… given parsing simplification

Differential Revision: https://phabricator.services.mozilla.com/D150163
  • Loading branch information
dshin-moz authored and Loirooriol committed Sep 25, 2023
1 parent 1999a2b commit 2ef2cfb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
11 changes: 4 additions & 7 deletions components/style/piecewise_linear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct PiecewiseLinearFunction {
}

/// Parameters to define one linear stop.
pub type PiecewiseLinearFunctionBuildParameters = (CSSFloat, Option<CSSFloat>, Option<CSSFloat>);
pub type PiecewiseLinearFunctionBuildParameters = (CSSFloat, Option<CSSFloat>);

impl PiecewiseLinearFunction {
/// Interpolate y value given x and two points. The linear function will be rooted at the asymptote.
Expand Down Expand Up @@ -97,8 +97,8 @@ impl PiecewiseLinearFunction {
Iter: Iterator<Item = PiecewiseLinearFunctionBuildParameters> + ExactSizeIterator,
{
let mut builder = PiecewiseLinearFunctionBuilder::with_capacity(iter.len());
for (y, x_start, x_end) in iter {
builder = builder.push(y, x_start, x_end);
for (y, x_start) in iter {
builder = builder.push(y, x_start);
}
builder.build()
}
Expand Down Expand Up @@ -161,11 +161,8 @@ impl PiecewiseLinearFunctionBuilder {
/// 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
/// 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);
if x_end.is_some() {
self.create_entry(y, x_end.map(|x| x));
}
self
}

Expand Down
1 change: 0 additions & 1 deletion components/style/values/computed/easing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ impl ComputedLinearStop {
(
x.output,
x.input.into_rust().map(|x| x.0),
None,
)
}
}

0 comments on commit 2ef2cfb

Please sign in to comment.