mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb: Avoid early conversion to CSSPixels when simplifying calculation
Converting to CSSPixels caused us to lose precision and the sign of signed zeroes. The values we resolve against in Length::ResolutionContext are still themselves rounded too early but this is in the right direction.
This commit is contained in:
parent
43b06cbbdd
commit
0b45a68423
Notes:
github-actions[bot]
2025-10-23 08:35:32 +00:00
Author: https://github.com/Calme1709
Commit: 0b45a68423
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6544
Reviewed-by: https://github.com/AtkinsSJ ✅
6 changed files with 63 additions and 39 deletions
|
|
@ -2531,7 +2531,7 @@ CalculatedStyleValue::CalculationResult CalculatedStyleValue::CalculationResult:
|
|||
return AK::NaN<double>;
|
||||
}
|
||||
|
||||
return length.to_px(context.length_resolution_context.value()).to_double();
|
||||
return length.to_px_without_rounding(context.length_resolution_context.value());
|
||||
},
|
||||
[](Resolution const& resolution) { return resolution.to_dots_per_pixel(); },
|
||||
[](Time const& time) { return time.to_seconds(); },
|
||||
|
|
@ -2900,7 +2900,7 @@ NonnullRefPtr<CalculationNode const> simplify_a_calculation_tree(CalculationNode
|
|||
if (length.is_absolute())
|
||||
return NumericCalculationNode::create(Length::make_px(length.absolute_length_to_px()).percentage_of(*percentage), context);
|
||||
if (resolution_context.length_resolution_context.has_value())
|
||||
return NumericCalculationNode::create(Length::make_px(length.to_px(resolution_context.length_resolution_context.value())).percentage_of(*percentage), context);
|
||||
return NumericCalculationNode::create(Length::make_px(length.to_px_without_rounding(resolution_context.length_resolution_context.value())).percentage_of(*percentage), context);
|
||||
return nullptr;
|
||||
},
|
||||
[&](Time const& time) -> RefPtr<NumericCalculationNode const> {
|
||||
|
|
@ -2938,9 +2938,9 @@ NonnullRefPtr<CalculationNode const> simplify_a_calculation_tree(CalculationNode
|
|||
if (length.unit() == LengthUnit::Px)
|
||||
return nullptr;
|
||||
if (length.is_absolute())
|
||||
return NumericCalculationNode::create(Length::make_px(length.absolute_length_to_px()), context);
|
||||
return NumericCalculationNode::create(Length::make_px(length.absolute_length_to_px_without_rounding()), context);
|
||||
if (resolution_context.length_resolution_context.has_value())
|
||||
return NumericCalculationNode::create(Length::make_px(length.to_px(resolution_context.length_resolution_context.value())), context);
|
||||
return NumericCalculationNode::create(Length::make_px(length.to_px_without_rounding(resolution_context.length_resolution_context.value())), context);
|
||||
return nullptr;
|
||||
},
|
||||
[&](Number const&) -> RefPtr<CalculationNode const> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue