From da768e7c460934b78a753067391509dfa5f31863 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 3 May 2023 13:59:05 +0200 Subject: [PATCH] LibWeb: Don't crash on unresolvable line-height: calc() value Instead, log the calc() value we failed to resolve, so we can debug it. --- Userland/Libraries/LibWeb/CSS/StyleProperties.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp index 2adde0ada0..b3f616139d 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp @@ -206,8 +206,14 @@ CSSPixels StyleProperties::line_height(Layout::Node const& layout_node) const return Length(percentage.as_fraction(), Length::Type::Em).to_px(layout_node); } - if (line_height->is_calculated()) - return line_height->as_calculated().resolve_length(layout_node)->to_px(layout_node); + if (line_height->is_calculated()) { + 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()); + return layout_node.font().pixel_metrics().line_spacing(); + } + return resolved->to_px(layout_node); + } return layout_node.font().pixel_metrics().line_spacing(); }