From a38a5d50ab973dc2a54e13db68ab6793b3f85a7a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 10 Jun 2020 15:28:56 +0200 Subject: [PATCH] LibWeb: Constrain block height by the max-height if specified --- Libraries/LibWeb/Layout/LayoutBlock.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Libraries/LibWeb/Layout/LayoutBlock.cpp b/Libraries/LibWeb/Layout/LayoutBlock.cpp index 1afd9c9b22..ff43ca236e 100644 --- a/Libraries/LibWeb/Layout/LayoutBlock.cpp +++ b/Libraries/LibWeb/Layout/LayoutBlock.cpp @@ -426,9 +426,17 @@ void LayoutBlock::compute_position() void LayoutBlock::compute_height() { auto& style = this->style(); - auto height = style.length_or_fallback(CSS::PropertyID::Height, Length(), containing_block()->height()); - if (height.is_absolute()) - set_height(height.to_px(*this)); + + auto specified_height = style.length_or_fallback(CSS::PropertyID::Height, Length(), containing_block()->height()); + auto specified_max_height = style.length_or_fallback(CSS::PropertyID::MaxHeight, Length(), containing_block()->height()); + + + if (!specified_height.is_auto()) { + float used_height = specified_height.to_px(*this); + if (!specified_max_height.is_auto()) + used_height = min(used_height, specified_max_height.to_px(*this)); + set_height(used_height); + } } void LayoutBlock::render(RenderingContext& context)