mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
LibWeb: Consider span > 1 while getting available space for items in GFC
This commit is contained in:
parent
79e76ae64c
commit
628efda754
Notes:
sideshowbarker
2024-07-17 11:06:06 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/628efda754 Pull-request: https://github.com/SerenityOS/serenity/pull/18891 Reviewed-by: https://github.com/awesomekling
21
Tests/LibWeb/Layout/expected/grid/item-column-span-2.txt
Normal file
21
Tests/LibWeb/Layout/expected/grid/item-column-span-2.txt
Normal file
@ -0,0 +1,21 @@
|
||||
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||
BlockContainer <html> at (0,0) content-size 800x600 [BFC] children: not-inline
|
||||
BlockContainer <body> at (8,8) content-size 784x35.40625 children: not-inline
|
||||
Box <div.container> at (8,8) content-size 784x35.40625 [GFC] children: not-inline
|
||||
BlockContainer <(anonymous)> at (8,8) content-size 0x0 [BFC] children: inline
|
||||
TextNode <#text>
|
||||
BlockContainer <div.item-left> at (8,8) content-size 100x35.40625 [BFC] children: not-inline
|
||||
BlockContainer <(anonymous)> at (8,8) content-size 0x0 [BFC] children: inline
|
||||
TextNode <#text>
|
||||
BlockContainer <div.item-right> at (108.000061,8) content-size 683.999938x35.40625 [BFC] children: inline
|
||||
line 0 width: 625.953125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
|
||||
frag 0 from TextNode start: 0, length: 77, rect: [108.000061,8 625.953125x17.46875]
|
||||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut iaculis venenatis"
|
||||
line 1 width: 304.0625, height: 17.9375, bottom: 35.40625, baseline: 13.53125
|
||||
frag 0 from TextNode start: 78, length: 39, rect: [108.000061,25 304.0625x17.46875]
|
||||
"purus, eget blandit velit venenatis at."
|
||||
TextNode <#text>
|
||||
BlockContainer <(anonymous)> at (8,8) content-size 0x0 [BFC] children: inline
|
||||
TextNode <#text>
|
||||
BlockContainer <(anonymous)> at (8,43.40625) content-size 784x0 children: inline
|
||||
TextNode <#text>
|
21
Tests/LibWeb/Layout/input/grid/item-column-span-2.html
Normal file
21
Tests/LibWeb/Layout/input/grid/item-column-span-2.html
Normal file
@ -0,0 +1,21 @@
|
||||
<style>
|
||||
.container {
|
||||
display: grid;
|
||||
grid-template-columns: auto 0 minmax(0, calc(100%));
|
||||
background-color: red;
|
||||
}
|
||||
|
||||
.item-left {
|
||||
grid-column: 1;
|
||||
width: 100px;
|
||||
background-color: blueviolet;
|
||||
}
|
||||
|
||||
.item-right {
|
||||
grid-column: 2 / span 2;
|
||||
}
|
||||
</style>
|
||||
<div class="container">
|
||||
<div class="item-left"></div>
|
||||
<div class="item-right">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut iaculis venenatis purus, eget blandit velit venenatis at.</div>
|
||||
</div>
|
@ -1649,11 +1649,37 @@ CSSPixels GridFormattingContext::containing_block_size_for_item(GridItem const&
|
||||
|
||||
AvailableSpace GridFormattingContext::get_available_space_for_item(GridItem const& item) const
|
||||
{
|
||||
auto const& column_track = m_grid_columns[item.raw_column()];
|
||||
AvailableSize available_width = column_track.has_definite_base_size ? AvailableSize::make_definite(column_track.base_size) : AvailableSize::make_indefinite();
|
||||
CSSPixels column_width = 0;
|
||||
bool has_columns_with_definite_base_size = false;
|
||||
for (size_t span = 0; span < item.raw_column_span(); span++) {
|
||||
// FIXME: This check should not be need if grid item positioning works correct
|
||||
if (item.raw_column() + span >= m_grid_columns.size())
|
||||
break;
|
||||
|
||||
auto const& row_track = m_grid_rows[item.raw_row()];
|
||||
AvailableSize available_height = row_track.has_definite_base_size ? AvailableSize::make_definite(row_track.base_size) : AvailableSize::make_indefinite();
|
||||
auto& track = m_grid_columns[item.raw_column() + span];
|
||||
column_width += track.base_size;
|
||||
|
||||
if (track.has_definite_base_size)
|
||||
has_columns_with_definite_base_size = true;
|
||||
}
|
||||
|
||||
AvailableSize available_width = has_columns_with_definite_base_size ? AvailableSize::make_definite(column_width) : AvailableSize::make_indefinite();
|
||||
|
||||
CSSPixels column_height = 0;
|
||||
bool has_rows_with_definite_base_size = false;
|
||||
for (size_t span = 0; span < item.raw_row_span(); span++) {
|
||||
// FIXME: This check should not be need if grid item positioning works correct
|
||||
if (item.raw_row() + span >= m_grid_rows.size())
|
||||
break;
|
||||
|
||||
auto& track = m_grid_rows[item.raw_row() + span];
|
||||
column_height += track.base_size;
|
||||
|
||||
if (track.has_definite_base_size)
|
||||
has_rows_with_definite_base_size = true;
|
||||
}
|
||||
|
||||
AvailableSize available_height = has_rows_with_definite_base_size ? AvailableSize::make_definite(column_height) : AvailableSize::make_indefinite();
|
||||
|
||||
return AvailableSpace(available_width, available_height);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user