mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
LibWeb/Layout: Add support for grid-auto-flow
in GFC
This commit is contained in:
parent
703c2bb06e
commit
37f5253ec9
Notes:
sideshowbarker
2024-07-17 05:02:35 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/37f5253ec9 Pull-request: https://github.com/SerenityOS/serenity/pull/20624 Reviewed-by: https://github.com/AtkinsSJ ✅ Reviewed-by: https://github.com/awesomekling ✅
3 changed files with 38 additions and 3 deletions
21
Tests/LibWeb/Layout/expected/grid/auto-flow-column.txt
Normal file
21
Tests/LibWeb/Layout/expected/grid/auto-flow-column.txt
Normal file
|
@ -0,0 +1,21 @@
|
|||
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 200x19.46875 [GFC] children: not-inline
|
||||
BlockContainer <div> at (11,11) content-size 98x17.46875 [BFC] children: inline
|
||||
line 0 width: 36.84375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
|
||||
frag 0 from TextNode start: 0, length: 5, rect: [11,11 36.84375x17.46875]
|
||||
"hello"
|
||||
TextNode <#text>
|
||||
BlockContainer <div> at (111,11) content-size 98x17.46875 [BFC] children: inline
|
||||
line 0 width: 55.359375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
|
||||
frag 0 from TextNode start: 0, length: 7, rect: [111,11 55.359375x17.46875]
|
||||
"friends"
|
||||
TextNode <#text>
|
||||
|
||||
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
||||
PaintableWithLines (BlockContainer<HTML>) [0,0 800x39.46875]
|
||||
PaintableBox (Box<BODY>) [9,9 202x21.46875]
|
||||
PaintableWithLines (BlockContainer<DIV>) [10,10 100x19.46875]
|
||||
TextPaintable (TextNode<#text>)
|
||||
PaintableWithLines (BlockContainer<DIV>) [110,10 100x19.46875]
|
||||
TextPaintable (TextNode<#text>)
|
8
Tests/LibWeb/Layout/input/grid/auto-flow-column.html
Normal file
8
Tests/LibWeb/Layout/input/grid/auto-flow-column.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
<!doctype html><style>
|
||||
* { border: 1px solid black; }
|
||||
body {
|
||||
display: grid;
|
||||
grid-auto-flow: column;
|
||||
width: 200px;
|
||||
}
|
||||
</style><body><div>hello</div><div>friends</div>
|
|
@ -534,6 +534,8 @@ void GridFormattingContext::place_item_with_no_declared_position(Box const& chil
|
|||
row_span = child_box.computed_values().grid_row_end().raw_value();
|
||||
auto found_unoccupied_area = false;
|
||||
|
||||
auto const& auto_flow = grid_container().computed_values().grid_auto_flow();
|
||||
|
||||
while (true) {
|
||||
while (auto_placement_cursor_x <= m_occupation_grid.max_column_index()) {
|
||||
if (auto_placement_cursor_x + static_cast<int>(column_span) <= m_occupation_grid.max_column_index() + 1) {
|
||||
|
@ -562,9 +564,13 @@ void GridFormattingContext::place_item_with_no_declared_position(Box const& chil
|
|||
// row position (creating new rows in the implicit grid as necessary), set its column position to the
|
||||
// start-most column line in the implicit grid, and return to the previous step.
|
||||
if (!found_unoccupied_area) {
|
||||
auto_placement_cursor_x = m_occupation_grid.min_column_index();
|
||||
auto_placement_cursor_y++;
|
||||
row_start = auto_placement_cursor_y;
|
||||
if (auto_flow.row) {
|
||||
auto_placement_cursor_x = m_occupation_grid.min_column_index();
|
||||
auto_placement_cursor_y++;
|
||||
} else {
|
||||
m_occupation_grid.set_max_column_index(auto_placement_cursor_x);
|
||||
auto_placement_cursor_y = m_occupation_grid.min_row_index();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue