Quellcode durchsuchen

LibWeb: Make min-content height equivalent to max-content as appropriate

Per CSS-SIZING-3, the min-content block size should be equivalent to the
max-content block size for some boxes.

Honoring this gives more correct results, and avoids unnecessary work in
many cases since the cached max-content size can be reused.
Andreas Kling vor 2 Jahren
Ursprung
Commit
4e06e86438
1 geänderte Dateien mit 5 neuen und 0 gelöschten Zeilen
  1. 5 0
      Userland/Libraries/LibWeb/Layout/FormattingContext.cpp

+ 5 - 0
Userland/Libraries/LibWeb/Layout/FormattingContext.cpp

@@ -1146,8 +1146,13 @@ CSSPixels FormattingContext::calculate_max_content_width(Layout::Box const& box)
     return *cache.max_content_width;
 }
 
+// https://www.w3.org/TR/css-sizing-3/#min-content-block-size
 CSSPixels FormattingContext::calculate_min_content_height(Layout::Box const& box, AvailableSize const& available_width) const
 {
+    // For block containers, tables, and inline boxes, this is equivalent to the max-content block size.
+    if (box.is_block_container() || box.is_table())
+        return calculate_max_content_height(box, available_width);
+
     if (box.has_intrinsic_height())
         return *box.intrinsic_height();