Skip to content

Commit

Permalink
LibWeb: Resolve used insets for grid items
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Jul 3, 2023
1 parent 2186478 commit 4789d5c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Tests/LibWeb/Layout/expected/grid/relpos-grid-item.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (2,2) content-size 796x62.9375 [BFC] children: not-inline
Box <body> at (12,12) content-size 600x42.9375 [GFC] children: not-inline
BlockContainer <div.exekiller> at (14,14) content-size 200x17.46875 positioned [BFC] children: inline
line 0 width: 65.4375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 9, rect: [14,14 65.4375x17.46875]
"exekiller"
TextNode <#text>
BlockContainer <div.athena> at (24,25.46875) content-size 200x17.46875 positioned [BFC] children: inline
line 0 width: 53.171875, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 6, rect: [24,25.46875 53.171875x17.46875]
"athena"
TextNode <#text>
19 changes: 19 additions & 0 deletions Tests/LibWeb/Layout/input/grid/relpos-grid-item.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html><style>
* { border: 2px solid black; }
body {
width: 600px;
display: grid;
}
div {
width: 200px;
position: relative;
}
.athena {
background: green;
top: -10px;
left: 10px;
}
.exekiller {
background: red;
}
</style><body><div class="exekiller">exekiller</div><div class="athena">athena</div></body>
2 changes: 2 additions & 0 deletions Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1609,6 +1609,8 @@ void GridFormattingContext::run(Box const& box, LayoutMode, AvailableSpace const
y_start + child_box_state.border_top + child_box_state.padding_top + child_box_state.margin_top
};

compute_inset(child_box);

auto available_space_for_children = AvailableSpace(AvailableSize::make_definite(child_box_state.content_width()), AvailableSize::make_definite(child_box_state.content_height()));
if (auto independent_formatting_context = layout_inside(child_box, LayoutMode::Normal, available_space_for_children))
independent_formatting_context->parent_context_did_dimension_child_root_box();
Expand Down

0 comments on commit 4789d5c

Please sign in to comment.