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

LibWeb: Use containing block width to measure fit-content width in GFC

When the grid layout gets to
`resolve_items_box_metrics(GridDimension::Column)`, we've already
determined the width of each column. However, the widths of the
individual grid items themselves haven't been set. Rather than using
`get_available_space_for_item()`, which returns an indefinite size if
an item's width/height hasn't been set, we should use the already
known track width as the available size to calculate the fit-content
width.
This commit is contained in:
Aliaksandr Kalenik 2023-08-27 02:05:58 +02:00 committed by Andreas Kling
parent e1a9d7ec9d
commit d3d67857b2
3 changed files with 44 additions and 2 deletions

View file

@ -1636,10 +1636,11 @@ void GridFormattingContext::resolve_grid_item_widths()
};
CSSPixels used_width;
AvailableSpace available_space { AvailableSize::make_definite(containing_block_width), AvailableSize::make_indefinite() };
if (computed_width.is_auto()) {
used_width = try_compute_width(calculate_fit_content_width(item.box, get_available_space_for_item(item)));
used_width = try_compute_width(calculate_fit_content_width(item.box, available_space));
} else if (computed_width.is_fit_content()) {
used_width = try_compute_width(calculate_fit_content_width(item.box, get_available_space_for_item(item)));
used_width = try_compute_width(calculate_fit_content_width(item.box, available_space));
} else {
used_width = try_compute_width(computed_width.to_px(grid_container(), containing_block_width));
}