浏览代码

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.
Andreas Kling 5 年之前
父节点
当前提交
aeeaf33638
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      Libraries/LibWeb/Layout/LayoutBlock.cpp

+ 5 - 2
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);
 }