Skip to content

Commit

Permalink
Flexbox: pass cross-axis known_dimensions when sizing a child to
Browse files Browse the repository at this point in the history
determine container main size (match the inputs we usually pass when
determining a child's base size)
  • Loading branch information
nicoburns committed Jun 29, 2024
1 parent 84723c5 commit e628b85
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/compute/flexbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -920,12 +920,24 @@ fn determine_container_main_size(

let child_available_space = available_space.with_cross(dir, cross_axis_available_space);

// Known dimensions for child sizing
let child_known_dimensions = {
let mut ckd = item.size.with_main(dir, None);
if item.align_self == AlignSelf::Stretch && ckd.cross(dir).is_none() {
ckd.set_cross(
dir,
cross_axis_available_space.into_option().maybe_sub(item.margin.cross_axis_sum(dir)),
);
}
ckd
};

// Either the min- or max- content size depending on which constraint we are sizing under.
// TODO: Optimise by using already computed values where available
debug_log!("COMPUTE CHILD BASE SIZE (for intrinsic main size):");
let content_main_size = tree.measure_child_size(
item.node,
Size::NONE,
child_known_dimensions,
constants.node_inner_size,
child_available_space,
SizingMode::InherentSize,
Expand Down

0 comments on commit e628b85

Please sign in to comment.