mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
LibWeb: Coerce NaNs to 0 when escaping top-level calculations
This commit is contained in:
parent
545d151948
commit
6a3c3ee291
Notes:
github-actions[bot]
2025-03-25 19:54:37 +00:00
Author: https://github.com/gmta
Commit: 6a3c3ee291
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4088
Reviewed-by: https://github.com/AtkinsSJ ✅
3 changed files with 12 additions and 3 deletions
|
@ -2716,9 +2716,16 @@ Optional<Time> CalculatedStyleValue::resolve_time(CalculationResolutionContext c
|
|||
Optional<double> CalculatedStyleValue::resolve_number(CalculationResolutionContext const& context) const
|
||||
{
|
||||
auto result = m_calculation->resolve(context);
|
||||
if (result.type().has_value() && result.type()->matches_number(m_context.percentages_resolve_as))
|
||||
return result.value();
|
||||
return {};
|
||||
if (!result.type().has_value() || !result.type()->matches_number(m_context.percentages_resolve_as))
|
||||
return {};
|
||||
|
||||
// https://drafts.csswg.org/css-values/#calc-ieee
|
||||
// NaN does not escape a top-level calculation; it’s censored into a zero value.
|
||||
auto value = result.value();
|
||||
if (isnan(value))
|
||||
return 0.;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
Optional<i64> CalculatedStyleValue::resolve_integer(CalculationResolutionContext const& context) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue