LibWeb: Reset item_incurred_increase before distributing space in GFC

item_incurred_increase should be reset before every next distirbution
because otherwise it will accumulate increases from previous
distributions which is not supposed to happen.
This commit is contained in:
Aliaksandr Kalenik 2023-05-16 07:41:51 +03:00 committed by Andreas Kling
parent 55e8ffd122
commit a613a0973e
Notes: sideshowbarker 2024-07-17 18:49:10 +09:00
3 changed files with 40 additions and 1 deletions

View file

@ -0,0 +1,24 @@
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 784x0 children: not-inline
Box <div.container> at (8,8) content-size 186.53125x34.9375 floating [GFC] children: not-inline
BlockContainer <div.item> at (8,8) content-size 101.640625x17.46875 [BFC] children: inline
line 0 width: 79.25, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 9, rect: [8,8 79.25x17.46875]
"some-text"
TextNode <#text>
BlockContainer <div.item> at (109.640625,8) content-size 84.890625x17.46875 [BFC] children: inline
line 0 width: 78.03125, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 9, rect: [109.640625,8 78.03125x17.46875]
"goes-here"
TextNode <#text>
BlockContainer <div.item> at (8,25.46875) content-size 101.640625x17.46875 [BFC] children: inline
line 0 width: 101.640625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 12, rect: [8,25.46875 101.640625x17.46875]
"another-text"
TextNode <#text>
BlockContainer <div.item> at (109.640625,25.46875) content-size 84.890625x17.46875 [BFC] children: inline
line 0 width: 84.890625, height: 17.46875, bottom: 17.46875, baseline: 13.53125
frag 0 from TextNode start: 0, length: 10, rect: [109.640625,25.46875 84.890625x17.46875]
"goes-there"
TextNode <#text>

View file

@ -0,0 +1,13 @@
<style>
.container {
float: left;
display: grid;
background-color: lightsalmon;
grid-template-columns: 1fr 1fr;
}
.item {
background-color: lightblue;
}
</style>
<div class="container"><div class="item">some-text</div><div class="item">goes-here</div><div class="item">another-text</div><div class="item">goes-there</div></div>

View file

@ -870,8 +870,10 @@ void GridFormattingContext::resolve_intrinsic_track_sizes(AvailableSpace const&
void GridFormattingContext::distribute_extra_space_across_spanned_tracks(CSSPixels item_size_contribution, Vector<TemporaryTrack&>& spanned_tracks)
{
for (auto& track : spanned_tracks)
for (auto& track : spanned_tracks) {
track.planned_increase = 0;
track.item_incurred_increase = 0;
}
// 1. Find the space to distribute:
CSSPixels spanned_tracks_sizes_sum = 0;