diff options
author | Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com> | 2023-05-16 07:41:51 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-05-16 07:47:47 +0200 |
commit | a613a0973e498659b42e2529b59fa1fd2a51bce2 (patch) | |
tree | 0aa206f4bdb59db3448da1b2029c2c38ebf3da92 | |
parent | 55e8ffd122a73164c64bd1356be02949a54858c0 (diff) | |
download | serenity-a613a0973e498659b42e2529b59fa1fd2a51bce2.zip |
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.
3 files changed, 40 insertions, 1 deletions
diff --git a/Tests/LibWeb/Layout/expected/grid/float-container-columns-1fr-1fr.txt b/Tests/LibWeb/Layout/expected/grid/float-container-columns-1fr-1fr.txt new file mode 100644 index 0000000000..b04cec661f --- /dev/null +++ b/Tests/LibWeb/Layout/expected/grid/float-container-columns-1fr-1fr.txt @@ -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> diff --git a/Tests/LibWeb/Layout/input/grid/float-container-columns-1fr-1fr.html b/Tests/LibWeb/Layout/input/grid/float-container-columns-1fr-1fr.html new file mode 100644 index 0000000000..9076eabca5 --- /dev/null +++ b/Tests/LibWeb/Layout/input/grid/float-container-columns-1fr-1fr.html @@ -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>
\ No newline at end of file diff --git a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp index 8c45f0aea1..023cb9d39e 100644 --- a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp @@ -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; |