Ver código fonte

LibWeb: Consider floating children when computing auto-height

The case for computing auto-height of block elements which have block-
level children was erroneously skipping some children:

1. If the block element itself is absolute or floating, all children
   were skipped due to a likely typo ("box" vs. "child_box" inside the
   for-each loop).

2. Floating children should only be skipped if the block element's
   'overflow' property computes to 'visible', per section 10.6.3 of the
   CSS height property spec. If the property computes to another value,
   section 10.6.7 only indicates that absolutely positioned children
   should be skipped.
Timothy Flynn 4 anos atrás
pai
commit
03990fcb89

+ 3 - 1
Userland/Libraries/LibWeb/Layout/BlockFormattingContext.cpp

@@ -290,7 +290,9 @@ float BlockFormattingContext::compute_auto_height_for_block_level_element(const
         // the top margin-edge of the topmost block-level child box
         // and the bottom margin-edge of the bottommost block-level child box.
         box.for_each_child_of_type<Box>([&](Layout::Box& child_box) {
-            if (box.is_absolutely_positioned() || box.is_floating())
+            if (child_box.is_absolutely_positioned())
+                return IterationDecision::Continue;
+            if ((box.computed_values().overflow_y() == CSS::Overflow::Visible) && child_box.is_floating())
                 return IterationDecision::Continue;
 
             float child_box_top = child_box.effective_offset().y() - child_box.box_model().margin_box().top;