1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 15:48:12 +00:00

LibWeb: Fix table width algorithm when available space is a constraint

Handle available space more carefully when computing a table width, in
order to avoid creating a definite infinite width when available space
width is max-content, as it's the case in calculate_max_content_width.
The constraint is thus correctly propagated by the time we cache the
computed value, which was previously rejected by the hash function due
to being definite but infinite instead of max-content.
This commit is contained in:
Andi Gallo 2023-06-11 12:04:01 +00:00 committed by Andreas Kling
parent b86ca27692
commit 75e87c32f2
4 changed files with 27 additions and 1 deletions

View file

@ -415,7 +415,14 @@ CSSPixels BlockFormattingContext::compute_table_box_width_inside_table_wrapper(B
auto available_width = width_of_containing_block - margin_left.to_px(box) - margin_right.to_px(box);
LayoutState throwaway_state(&m_state);
throwaway_state.get_mutable(box).set_content_width(available_width);
if (available_space.width.is_definite())
throwaway_state.get_mutable(box).set_content_width(available_width);
else if (available_space.width.is_min_content())
throwaway_state.get_mutable(box).set_min_content_width();
else {
VERIFY(available_space.width.is_max_content());
throwaway_state.get_mutable(box).set_max_content_width();
}
auto context = create_independent_formatting_context_if_needed(throwaway_state, box);
VERIFY(context);
context->run(box, LayoutMode::IntrinsicSizing, m_state.get(box).available_inner_space_or_constraints_from(available_space));