mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-07 16:49:54 +00:00
LibWeb: Correctly compute consistent type when simplifying hypot
Previously we would never get a valid `consistent_type` as we were trying to make the node types consistent with the initial empty type which isn't possible. Gains us 7 WPT tests.
This commit is contained in:
parent
04a3a227c3
commit
8e9753eadb
Notes:
github-actions[bot]
2025-06-30 12:54:14 +00:00
Author: https://github.com/Calme1709
Commit: 8e9753eadb
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5241
5 changed files with 261 additions and 4 deletions
|
@ -2096,7 +2096,7 @@ Optional<CalculatedStyleValue::CalculationResult> HypotCalculationNode::run_oper
|
|||
// <percentage>, but must have a consistent type or else the function is invalid; the result’s type will be the
|
||||
// consistent type.
|
||||
|
||||
CSSNumericType consistent_type;
|
||||
Optional<CSSNumericType> consistent_type;
|
||||
double value = 0;
|
||||
|
||||
for (auto const& child : m_values) {
|
||||
|
@ -2104,14 +2104,20 @@ Optional<CalculatedStyleValue::CalculationResult> HypotCalculationNode::run_oper
|
|||
if (!canonical_child.has_value())
|
||||
return {};
|
||||
|
||||
auto maybe_type = consistent_type.consistent_type(canonical_child->type().value());
|
||||
if (!maybe_type.has_value())
|
||||
if (!consistent_type.has_value())
|
||||
consistent_type = canonical_child->type();
|
||||
else
|
||||
consistent_type = consistent_type->consistent_type(canonical_child->type().value());
|
||||
|
||||
if (!consistent_type.has_value())
|
||||
return {};
|
||||
|
||||
consistent_type = maybe_type.release_value();
|
||||
value += canonical_child->value() * canonical_child->value();
|
||||
}
|
||||
|
||||
if (!consistent_type.has_value())
|
||||
return {};
|
||||
|
||||
return CalculatedStyleValue::CalculationResult { sqrt(value), consistent_type };
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue