diff options
author | Andreas Kling <kling@serenityos.org> | 2020-06-23 18:55:25 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-06-23 18:55:25 +0200 |
commit | aeeaf33638e17d20a9ccfda033ae37648ca3f485 (patch) | |
tree | 3097764cce00c0c25804142aea367c4ea85efc82 | |
parent | 675e7c0e6f0835578f99368fff3349911b6c4c2b (diff) | |
download | serenity-aeeaf33638e17d20a9ccfda033ae37648ca3f485.zip |
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.
-rw-r--r-- | Libraries/LibWeb/Layout/LayoutBlock.cpp | 7 |
1 files 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); } |