mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +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
|
|
@ -78,6 +78,18 @@ public:
|
|||
return to_px_slow_case(node);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE double to_px_without_rounding(ResolutionContext const& context) const
|
||||
{
|
||||
if (is_absolute())
|
||||
return absolute_length_to_px_without_rounding();
|
||||
if (is_font_relative())
|
||||
return font_relative_length_to_px_without_rounding(context.font_metrics, context.root_font_metrics);
|
||||
if (is_viewport_relative())
|
||||
return viewport_relative_length_to_px_without_rounding(context.viewport_rect);
|
||||
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE CSSPixels to_px(CSSPixelRect const& viewport_rect, FontMetrics const& font_metrics, FontMetrics const& root_font_metrics) const
|
||||
{
|
||||
if (is_absolute())
|
||||
|
|
@ -108,7 +120,9 @@ public:
|
|||
}
|
||||
|
||||
CSSPixels font_relative_length_to_px(FontMetrics const& font_metrics, FontMetrics const& root_font_metrics) const;
|
||||
double font_relative_length_to_px_without_rounding(FontMetrics const& font_metrics, FontMetrics const& root_font_metrics) const;
|
||||
CSSPixels viewport_relative_length_to_px(CSSPixelRect const& viewport_rect) const;
|
||||
double viewport_relative_length_to_px_without_rounding(CSSPixelRect const& viewport_rect) const;
|
||||
|
||||
// Returns empty optional if it's already absolute.
|
||||
Optional<Length> absolutize(CSSPixelRect const& viewport_rect, FontMetrics const& font_metrics, FontMetrics const& root_font_metrics) const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue