LibWeb: Resolve % top and bottom insets against containing block height

This makes cookie banner buttons show up on Linktree again. :^)

Regressed in fd37ad3a84
This commit is contained in:
Andreas Kling 2023-07-08 09:49:37 +02:00
parent fd37ad3a84
commit db5bde01dc
Notes: sideshowbarker 2024-07-17 22:55:25 +09:00
3 changed files with 36 additions and 2 deletions

View file

@ -0,0 +1,14 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (1,1) content-size 798x0 [BFC] children: not-inline
BlockContainer <body> at (10,10) content-size 500x400 positioned [BFC] children: inline
BlockContainer <div.one> at (311,211) content-size 28.6875x17.46875 positioned [BFC] children: inline
line 0 width: 28.6875, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 3, rect: [311,211 28.6875x17.46875]
"one"
TextNode <#text>
BlockContainer <div.two> at (330.5625,351.53125) content-size 28.4375x17.46875 positioned [BFC] children: inline
line 0 width: 28.4375, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 3, rect: [330.5625,351.53125 28.4375x17.46875]
"two"
TextNode <#text>
TextNode <#text>

View file

@ -0,0 +1,20 @@
<!DOCTYPE html><style>
* {
border: 1px solid black;
}
body {
position: absolute;
width: 500px;
height: 400px;
}
.one {
position: absolute;
top: 50%;
left: 60%;
}
.two {
position: absolute;
bottom: 10%;
right: 30%;
}
</style><body><div class=one>one</div><div class=two>two</div>

View file

@ -1020,8 +1020,8 @@ void FormattingContext::compute_height_for_absolutely_positioned_non_replaced_el
if (before_or_after_inside_layout == BeforeOrAfterInsideLayout::Before)
return;
box_state.inset_top = top.to_px(box, width_of_containing_block);
box_state.inset_bottom = bottom.to_px(box, width_of_containing_block);
box_state.inset_top = top.to_px(box, height_of_containing_block);
box_state.inset_bottom = bottom.to_px(box, height_of_containing_block);
box_state.margin_top = margin_top.to_px(box, width_of_containing_block);
box_state.margin_bottom = margin_bottom.to_px(box, width_of_containing_block);
box_state.padding_top = box.computed_values().padding().top().to_px(box, width_of_containing_block);