style: Rustfmt recent changes to calc.rs

Differential Revision: https://phabricator.services.mozilla.com/D172339
This commit is contained in:
Emilio Cobos Álvarez 2023-03-13 11:33:23 +00:00 committed by Martin Robinson
parent 2c986f0005
commit 23d6ecfc57
2 changed files with 19 additions and 15 deletions

View file

@ -545,7 +545,7 @@ impl<L: CalcNodeLeaf> CalcNode<L> {
result = result + child.resolve_internal(leaf_to_output_fn)?.powi(2);
}
result.sqrt()
}
},
})
}
@ -669,7 +669,9 @@ impl<L: CalcNodeLeaf> CalcNode<L> {
dividend.visit_depth_first_internal(f);
divisor.visit_depth_first_internal(f);
},
Self::Sum(ref mut children) | Self::MinMax(ref mut children, _) | Self::Hypot(ref mut children) => {
Self::Sum(ref mut children) |
Self::MinMax(ref mut children, _) |
Self::Hypot(ref mut children) => {
for child in &mut **children {
child.visit_depth_first_internal(f);
}
@ -1002,7 +1004,7 @@ impl<L: CalcNodeLeaf> CalcNode<L> {
};
replace_self_with!(&mut result);
}
},
Self::Leaf(ref mut l) => {
l.simplify();
},

View file

@ -672,10 +672,12 @@ impl CalcNode {
},
MathFunction::Log => {
let a = Self::parse_number_argument(context, input)?;
let b = input.try_parse(|input| {
let b = input
.try_parse(|input| {
input.expect_comma()?;
Self::parse_number_argument(context, input)
}).ok();
})
.ok();
let number = match b {
Some(b) => a.log(b),
@ -823,8 +825,7 @@ impl CalcNode {
where
F: FnOnce() -> Result<CSSFloat, ()>,
{
closure()
.map_err(|()| input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
closure().map_err(|()| input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
}
/// Tries to simplify this expression into a `<length>` or `<percentage>`
@ -854,18 +855,19 @@ impl CalcNode {
}
/// Tries to simplify this expression into a `<time>` value.
fn to_time(
&self,
clamping_mode: Option<AllowedNumericType>
) -> Result<Time, ()> {
fn to_time(&self, clamping_mode: Option<AllowedNumericType>) -> Result<Time, ()> {
let seconds = self.resolve(|leaf| match *leaf {
Leaf::Time(ref time) => Ok(time.seconds()),
_ => Err(()),
})?;
Ok(Time::from_seconds_with_calc_clamping_mode(
if nan_inf_enabled() { seconds } else { crate::values::normalize(seconds) },
clamping_mode
if nan_inf_enabled() {
seconds
} else {
crate::values::normalize(seconds)
},
clamping_mode,
))
}