summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-06-01 08:28:16 +0200
committerAndreas Kling <kling@serenityos.org>2023-06-01 09:20:05 +0200
commit966058d693625928abbc5b87ff9d8447bfe50541 (patch)
tree94a2dc2050dd0605540a22bed28568e4b6ad7bd4 /Userland
parentdcead6f5ebec4f4df1c27b641954d2f8ba5a9edb (diff)
downloadserenity-966058d693625928abbc5b87ff9d8447bfe50541.zip
LibWeb: Support `line-height: calc(...)` values that resolve to number
This is used on GitHub and many other websites.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleProperties.cpp9
1 files changed, 9 insertions, 0 deletions
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());