1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 03:27:45 +00:00

LibWeb: Calculate viewport-relative lengths in CSSPixels

This commit is contained in:
Zaggy1024 2023-08-31 19:57:20 -05:00 committed by Alexander Kalenik
parent fc05cda8cf
commit 99c90e49b6

View file

@ -98,34 +98,34 @@ CSSPixels Length::viewport_relative_length_to_px(CSSPixelRect const& viewport_re
case Type::Svw: case Type::Svw:
case Type::Lvw: case Type::Lvw:
case Type::Dvw: case Type::Dvw:
return CSSPixels::nearest_value_for(viewport_rect.width() * (m_value / 100)); return viewport_rect.width() * (CSSPixels::nearest_value_for(m_value) / 100);
case Type::Vh: case Type::Vh:
case Type::Svh: case Type::Svh:
case Type::Lvh: case Type::Lvh:
case Type::Dvh: case Type::Dvh:
return CSSPixels::nearest_value_for(viewport_rect.height() * (m_value / 100)); return viewport_rect.height() * (CSSPixels::nearest_value_for(m_value) / 100);
case Type::Vi: case Type::Vi:
case Type::Svi: case Type::Svi:
case Type::Lvi: case Type::Lvi:
case Type::Dvi: case Type::Dvi:
// FIXME: Select the width or height based on which is the inline axis. // FIXME: Select the width or height based on which is the inline axis.
return CSSPixels::nearest_value_for(viewport_rect.width() * (m_value / 100)); return viewport_rect.width() * (CSSPixels::nearest_value_for(m_value) / 100);
case Type::Vb: case Type::Vb:
case Type::Svb: case Type::Svb:
case Type::Lvb: case Type::Lvb:
case Type::Dvb: case Type::Dvb:
// FIXME: Select the width or height based on which is the block axis. // FIXME: Select the width or height based on which is the block axis.
return CSSPixels::nearest_value_for(viewport_rect.height() * (m_value / 100)); return viewport_rect.height() * (CSSPixels::nearest_value_for(m_value) / 100);
case Type::Vmin: case Type::Vmin:
case Type::Svmin: case Type::Svmin:
case Type::Lvmin: case Type::Lvmin:
case Type::Dvmin: case Type::Dvmin:
return CSSPixels::nearest_value_for(min(viewport_rect.width(), viewport_rect.height()) * (m_value / 100)); return min(viewport_rect.width(), viewport_rect.height()) * (CSSPixels::nearest_value_for(m_value) / 100);
case Type::Vmax: case Type::Vmax:
case Type::Svmax: case Type::Svmax:
case Type::Lvmax: case Type::Lvmax:
case Type::Dvmax: case Type::Dvmax:
return CSSPixels::nearest_value_for(max(viewport_rect.width(), viewport_rect.height()) * (m_value / 100)); return max(viewport_rect.width(), viewport_rect.height()) * (CSSPixels::nearest_value_for(m_value) / 100);
default: default:
VERIFY_NOT_REACHED(); VERIFY_NOT_REACHED();
} }