From 966058d693625928abbc5b87ff9d8447bfe50541 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 1 Jun 2023 08:28:16 +0200 Subject: LibWeb: Support `line-height: calc(...)` values that resolve to number This is used on GitHub and many other websites. --- Userland/Libraries/LibWeb/CSS/StyleProperties.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Userland') diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp index 3c638dac48..403700d462 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -219,6 +219,15 @@ CSSPixels StyleProperties::line_height(Layout::Node const& layout_node) const } if (line_height->is_calculated()) { + if (line_height->as_calculated().resolves_to_number()) { + auto resolved = line_height->as_calculated().resolve_number(); + if (!resolved.has_value()) { + dbgln("FIXME: Failed to resolve calc() line-height (number): {}", line_height->as_calculated().to_string().release_value_but_fixme_should_propagate_errors()); + return layout_node.font().pixel_metrics().line_spacing(); + } + return Length(resolved.value(), Length::Type::Em).to_px(layout_node); + } + auto resolved = line_height->as_calculated().resolve_length(layout_node); if (!resolved.has_value()) { dbgln("FIXME: Failed to resolve calc() line-height: {}", line_height->as_calculated().to_string().release_value_but_fixme_should_propagate_errors()); -- cgit v1.2.3