style: Normalize NaN to zero as a result of calc().

Differential Revision: https://phabricator.services.mozilla.com/D104563
This commit is contained in:
Emilio Cobos Álvarez 2021-02-10 15:30:40 +00:00
parent 20f5e14bf8
commit db03b2cf8e
4 changed files with 25 additions and 6 deletions

View file

@ -482,7 +482,7 @@ impl CalcNode {
Leaf::Time(ref t) => Ok(t.seconds()),
_ => Err(()),
})?;
Ok(Time::from_calc(seconds))
Ok(Time::from_calc(crate::values::normalize(seconds)))
}
/// Tries to simplify this expression into an `Angle` value.
@ -491,7 +491,7 @@ impl CalcNode {
Leaf::Angle(ref angle) => Ok(angle.degrees()),
_ => Err(()),
})?;
Ok(Angle::from_calc(degrees))
Ok(Angle::from_calc(crate::values::normalize(degrees)))
}
/// Tries to simplify this expression into a `<number>` value.
@ -555,6 +555,7 @@ impl CalcNode {
) -> Result<CSSFloat, ParseError<'i>> {
Self::parse(context, input, function, CalcUnit::Percentage)?
.to_percentage()
.map(crate::values::normalize)
.map_err(|()| input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
}
@ -578,6 +579,7 @@ impl CalcNode {
) -> Result<CSSFloat, ParseError<'i>> {
Self::parse(context, input, function, CalcUnit::Number)?
.to_number()
.map(crate::values::normalize)
.map_err(|()| input.new_custom_error(StyleParseErrorKind::UnspecifiedError))
}