LibWeb: Start fleshing out support for relative CSS units

This patch introduces support for more than just "absolute px" units in
our Length class. It now also supports "em" and "rem", which are units
relative to the font-size of the current layout node and the <html>
element's layout node respectively.
This commit is contained in:
Andreas Kling 2020-06-07 17:55:46 +02:00
commit 731685468a
Notes: sideshowbarker 2024-07-19 05:47:10 +09:00
16 changed files with 163 additions and 92 deletions

View file

@ -172,11 +172,11 @@ void StyleProperties::load_font() const
return;
}
float StyleProperties::line_height() const
float StyleProperties::line_height(const LayoutNode& layout_node) const
{
auto line_height_length = length_or_fallback(CSS::PropertyID::LineHeight, {});
if (line_height_length.is_absolute())
return (float)line_height_length.to_px();
return (float)line_height_length.to_px(layout_node);
return (float)font().glyph_height() * 1.4f;
}