@@ -42,9 +42,13 @@ impl BlockFormattingContext {
4242 self . float_context . place_floated_box ( floated_box, float_direction)
4343 }
4444
45- fn floated_content_contribution ( & self ) -> f32 {
45+ fn floated_content_width_contribution ( & self ) -> f32 {
4646 self . float_context . content_width ( )
4747 }
48+
49+ fn floated_content_height_contribution ( & self ) -> f32 {
50+ self . float_context . content_height ( )
51+ }
4852}
4953
5054#[ cfg( not( feature = "float_layout" ) ) ]
@@ -183,6 +187,7 @@ pub fn compute_block_layout(
183187 }
184188
185189 // Unwrap the block formatting context if one was passed, or else create a new one
190+ let is_root = bfc. is_none ( ) ;
186191 let mut new_bfc: BlockFormattingContext ;
187192 let bfc_ref: & mut BlockFormattingContext = match bfc {
188193 Some ( inherited_bfc) => inherited_bfc,
@@ -193,7 +198,13 @@ pub fn compute_block_layout(
193198 } ;
194199
195200 debug_log ! ( "BLOCK" ) ;
196- compute_inner ( tree, node_id, LayoutInput { known_dimensions : styled_based_known_dimensions, ..inputs } , bfc_ref)
201+ compute_inner (
202+ tree,
203+ node_id,
204+ LayoutInput { known_dimensions : styled_based_known_dimensions, ..inputs } ,
205+ bfc_ref,
206+ is_root,
207+ )
197208}
198209
199210/// Computes the layout of [`LayoutBlockContainer`] according to the block layout algorithm
@@ -202,6 +213,7 @@ fn compute_inner(
202213 node_id : NodeId ,
203214 inputs : LayoutInput ,
204215 bfc : & mut BlockFormattingContext ,
216+ is_bfc_root : bool ,
205217) -> LayoutOutput {
206218 let LayoutInput {
207219 known_dimensions, parent_size, available_space, run_mode, vertical_margins_are_collapsible, ..
@@ -300,7 +312,7 @@ fn compute_inner(
300312 let resolved_padding = raw_padding. resolve_or_zero ( Some ( container_outer_width) , |val, basis| tree. calc ( val, basis) ) ;
301313 let resolved_border = raw_border. resolve_or_zero ( Some ( container_outer_width) , |val, basis| tree. calc ( val, basis) ) ;
302314 let resolved_content_box_inset = resolved_padding + resolved_border + scrollbar_gutter;
303- let ( inflow_content_size, intrinsic_outer_height, first_child_top_margin_set, last_child_bottom_margin_set) =
315+ let ( inflow_content_size, mut intrinsic_outer_height, first_child_top_margin_set, last_child_bottom_margin_set) =
304316 perform_final_layout_on_in_flow_children (
305317 tree,
306318 & mut items,
@@ -311,6 +323,12 @@ fn compute_inner(
311323 own_margins_collapse_with_children,
312324 bfc,
313325 ) ;
326+
327+ // Root BFCs contain floats
328+ if is_bfc_root {
329+ intrinsic_outer_height = intrinsic_outer_height. max ( bfc. floated_content_height_contribution ( ) ) ;
330+ }
331+
314332 let container_outer_height = known_dimensions
315333 . height
316334 . unwrap_or ( intrinsic_outer_height. maybe_clamp ( min_size. height , max_size. height ) )
@@ -477,7 +495,7 @@ fn determine_content_based_container_width(
477495 max_child_width = f32_max ( max_child_width, width) ;
478496 }
479497
480- max_child_width. max ( bfc. floated_content_contribution ( ) )
498+ max_child_width. max ( bfc. floated_content_width_contribution ( ) )
481499}
482500
483501/// Compute each child's final size and position
0 commit comments