From aeeaf33638e17d20a9ccfda033ae37648ca3f485 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 23 Jun 2020 18:55:25 +0200 Subject: [PATCH] LibWeb: Respect specified width when computing shrink-to-fit candidates Previously we would always just use the combined content width as the shrunken width in shrink-to-fit width calculations, but if the element has a non-auto specified width, we should just let that take over. This is far from perfect and doesn't take stuff like min/max-width into account. Will need more work, this just covers the basic case. --- Libraries/LibWeb/Layout/LayoutBlock.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Libraries/LibWeb/Layout/LayoutBlock.cpp b/Libraries/LibWeb/Layout/LayoutBlock.cpp index 38b9d0f641..40ab73091e 100644 --- a/Libraries/LibWeb/Layout/LayoutBlock.cpp +++ b/Libraries/LibWeb/Layout/LayoutBlock.cpp @@ -155,8 +155,11 @@ void LayoutBlock::layout_contained_boxes(LayoutMode layout_mode) return IterationDecision::Continue; }); - if (layout_mode != LayoutMode::Default) - set_width(content_width); + if (layout_mode != LayoutMode::Default) { + auto specified_width = style().length_or_fallback(CSS::PropertyID::Width, Length(), containing_block()->width()); + if (specified_width.is_auto()) + set_width(content_width); + } set_height(content_height); }