LibWeb: Resolve auto containing block sizes before intrinsic sizing

Before performing intrinsic sizing layout on a box, we now check if its
containing block has automatic size in the relevant axis, and if so,
we fetch the size of the nearest containing block ancestor with a size.
This commit is contained in:
Andreas Kling 2022-07-20 22:07:26 +02:00
parent da0cc9d401
commit e095b9c6f9
Notes: sideshowbarker 2024-07-17 08:44:02 +09:00

View File

@ -872,6 +872,8 @@ float FormattingContext::calculate_min_content_width(Layout::Box const& box) con
if (!containing_block.has_definite_height())
containing_block_state.set_content_height(INFINITY);
else if (containing_block.computed_values().height().is_auto())
containing_block_state.set_content_height(containing_block_height_for(containing_block));
auto& box_state = throwaway_state.get_mutable(box);
box_state.width_constraint = SizeConstraint::MinContent;
@ -912,6 +914,8 @@ float FormattingContext::calculate_max_content_width(Layout::Box const& box) con
if (!containing_block.has_definite_height())
containing_block_state.set_content_height(INFINITY);
else if (containing_block.computed_values().height().is_auto())
containing_block_state.set_content_height(containing_block_height_for(containing_block));
auto& box_state = throwaway_state.get_mutable(box);
box_state.width_constraint = SizeConstraint::MaxContent;
@ -952,6 +956,8 @@ float FormattingContext::calculate_min_content_height(Layout::Box const& box) co
if (!containing_block.has_definite_width())
containing_block_state.set_content_width(INFINITY);
else if (containing_block.computed_values().width().is_auto())
containing_block_state.set_content_width(containing_block_width_for(containing_block));
auto& box_state = throwaway_state.get_mutable(box);
box_state.height_constraint = SizeConstraint::MinContent;
@ -992,6 +998,8 @@ float FormattingContext::calculate_max_content_height(Layout::Box const& box) co
if (!containing_block.has_definite_width())
containing_block_state.set_content_width(INFINITY);
else if (containing_block.computed_values().width().is_auto())
containing_block_state.set_content_width(containing_block_width_for(containing_block));
auto& box_state = throwaway_state.get_mutable(box);
box_state.height_constraint = SizeConstraint::MaxContent;