LibWeb/CSS: Use generated code to convert between dimension units

This commit is contained in:
Sam Atkins 2025-09-04 12:27:20 +01:00
commit 5534ed6715
Notes: github-actions[bot] 2025-09-11 16:07:38 +00:00
6 changed files with 8 additions and 69 deletions

View file

@ -42,16 +42,7 @@ String Resolution::to_string(SerializationMode serialization_mode) const
double Resolution::to_dots_per_pixel() const
{
switch (m_unit) {
case ResolutionUnit::Dpi:
return m_value / 96; // 1in = 2.54cm = 96px
case ResolutionUnit::Dpcm:
return m_value / (96.0 / 2.54); // 1cm = 96px/2.54
case ResolutionUnit::Dppx:
case ResolutionUnit::X:
return m_value;
}
VERIFY_NOT_REACHED();
return ratio_between_units(m_unit, ResolutionUnit::Dppx) * m_value;
}
}