From 7411f66fcfac7e886b70a3137aadb8e7a5974a80 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Mon, 5 Feb 2024 09:43:55 +0100 Subject: [PATCH] LibWeb/CSS: Resolve value of "height" in special way according to spec Per spec value of height should be resolved to used value if "display" property is not "none" or "contents". --- .../css/getComputedStyle-print-all.txt | 2 +- .../LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt b/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt index 1c3fd4bd9d..8e52e2d6b5 100644 --- a/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt +++ b/Tests/LibWeb/Text/expected/css/getComputedStyle-print-all.txt @@ -81,7 +81,7 @@ grid-row-start: auto grid-template-areas: grid-template-columns: grid-template-rows: -height: auto +height: 1411px image-rendering: auto inset-block-end: auto inset-block-start: auto diff --git a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp index 35b6a786a9..ae4da4e6c5 100644 --- a/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp +++ b/Userland/Libraries/LibWeb/CSS/ResolvedCSSStyleDeclaration.cpp @@ -270,11 +270,21 @@ RefPtr ResolvedCSSStyleDeclaration::style_value_for_property(L // -> padding-top // -> width // -> A resolved value special case property like height defined in another specification - // FIXME: If the property applies to the element or pseudo-element and the resolved value of the - // display property is not none or contents, then the resolved value is the used value. - // Otherwise the resolved value is the computed value. - case PropertyID::Height: + case PropertyID::Height: { + // If the property applies to the element or pseudo-element and the resolved value of the + // display property is not none or contents, then the resolved value is the used value. + // Otherwise the resolved value is the computed value. + auto const& display = layout_node.computed_values().display(); + if (!display.is_none() && !display.is_contents() && layout_node.paintable()) { + if (layout_node.paintable()->is_paintable_box()) { + auto const& paintable_box = static_cast(*layout_node.paintable()); + auto const used_height = paintable_box.content_height(); + return style_value_for_size(Size::make_px(used_height)); + } + dbgln("FIXME: Support getting used height for ({})", layout_node.debug_description()); + } return style_value_for_size(layout_node.computed_values().height()); + } case PropertyID::MarginBlockEnd: return style_value_for_length_box_logical_side(layout_node, layout_node.computed_values().margin(), LogicalSide::BlockEnd); case PropertyID::MarginBlockStart: