1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 18:17:34 +00:00

LibWeb: Remove 3 decimal places rounding hack in Length::percentage_of

CSSPixels uses fixed point now.
This commit is contained in:
Andi Gallo 2023-08-11 06:20:48 +00:00 committed by Sam Atkins
parent f2c60b7716
commit a426263dee
2 changed files with 9 additions and 17 deletions

View file

@ -59,15 +59,7 @@ Length Length::percentage_of(Percentage const& percentage) const
return *this;
}
// HACK: We round to 3 decimal places to emulate what happens in browsers that used fixed point math.
// FIXME: Remove this when converting CSSPixels to a fixed-point type.
// https://github.com/SerenityOS/serenity/issues/18566
auto value = percentage.as_fraction() * raw_value();
value *= 1000;
value = round(value);
value /= 1000;
return Length { value, m_type };
return Length { percentage.as_fraction() * raw_value(), m_type };
}
CSSPixels Length::font_relative_length_to_px(Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const