mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-16 21:20:18 +00:00
LibWeb/CSS: Use generated code to convert between dimension units
This commit is contained in:
parent
82f5be871a
commit
5534ed6715
Notes:
github-actions[bot]
2025-09-11 16:07:38 +00:00
Author: https://github.com/AtkinsSJ
Commit: 5534ed6715
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6071
6 changed files with 8 additions and 69 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue