1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 09:47:35 +00:00

LibWeb: Support grid items with fit-content width :^)

This commit is contained in:
Andreas Kling 2023-05-26 19:01:01 +02:00
parent 299775345d
commit a277c393b9
3 changed files with 20 additions and 1 deletions

View file

@ -0,0 +1,8 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (1,1) content-size 798x37.46875 [BFC] children: not-inline
Box <body> at (10,10) content-size 780x19.46875 [GFC] children: not-inline
BlockContainer <div.inner> at (11,11) content-size 132.828125x17.46875 [BFC] children: inline
line 0 width: 132.828125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 15, rect: [11,11 132.828125x17.46875]
"Press and Media"
TextNode <#text>

View file

@ -0,0 +1,5 @@
<!DOCTYPE html><style>
* { border: 1px solid black; }
body { display: grid; }
.inner { width: fit-content; }
</style><body><div class="inner">Press and Media

View file

@ -1393,7 +1393,13 @@ void GridFormattingContext::resolve_grid_item_widths()
box_state.border_right = border_right;
auto const& computed_width = item.box().computed_values().width();
auto used_width = computed_width.is_auto() ? (containing_block_width - box_state.border_left - box_state.border_right - box_state.padding_left - box_state.padding_right) : computed_width.to_px(grid_container(), containing_block_width);
CSSPixels used_width;
if (computed_width.is_auto())
used_width = (containing_block_width - box_state.border_left - box_state.border_right - box_state.padding_left - box_state.padding_right);
else if (computed_width.is_fit_content())
used_width = calculate_fit_content_width(item.box(), get_available_space_for_item(item));
else
used_width = computed_width.to_px(grid_container(), containing_block_width);
box_state.set_content_width(used_width);
}
}