diff --git a/src/components/layout/block.rs b/src/components/layout/block.rs index 36b525924a7..f17582f142a 100644 --- a/src/components/layout/block.rs +++ b/src/components/layout/block.rs @@ -1050,9 +1050,6 @@ impl BlockFlow { floats = flow::mut_base(kid).floats.clone(); } - // Floats establish a block formatting context, so we discard the output floats here. - drop(floats); - let top_offset = self.fragment.margin.top + self.fragment.border_padding.top; let mut cur_y = top_offset; @@ -1065,7 +1062,12 @@ impl BlockFlow { cur_y = cur_y + child_base.position.size.height; } - let content_height = cur_y - top_offset; + // Intrinsic height should include floating descendants with a margin + // below the element's bottom edge (see CSS Section 10.6.7). + let content_height = geometry::max(cur_y - top_offset, floats.clearance(ClearBoth)); + + // Floats establish a block formatting context, so we discard the output floats here. + drop(floats); // The associated fragment has the border box of this flow. self.fragment.border_box.origin.y = self.fragment.margin.top; diff --git a/src/test/ref/basic.list b/src/test/ref/basic.list index 6559ee86518..5a11b53c12f 100644 --- a/src/test/ref/basic.list +++ b/src/test/ref/basic.list @@ -83,3 +83,4 @@ == position_fixed_overflow_a.html position_fixed_overflow_b.html == noscript.html noscript_ref.html == pseudo_inherit.html pseudo_inherit_ref.html +== float_intrinsic_height.html float_intrinsic_height_ref.html diff --git a/src/test/ref/float_intrinsic_height.html b/src/test/ref/float_intrinsic_height.html new file mode 100644 index 00000000000..b6d9e7e302a --- /dev/null +++ b/src/test/ref/float_intrinsic_height.html @@ -0,0 +1,24 @@ + + +
+ + + +