Skip to content

Commit 01be29a

Browse files
DRKV333tordex
authored andcommitted
Fixed flex grow factor sum also counting frozen items
1 parent 6321389 commit 01be29a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/flex_line.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@ void litehtml::flex_line::distribute_free_space(pixel_t container_main_size)
4848
while (processed)
4949
{
5050
pixel_t sum_scaled_flex_shrink_factor = 0;
51+
int sum_flex_grow_factor = 0;
5152
pixel_t remaining_free_space = container_main_size;
5253
int total_not_frozen = 0;
5354
for (auto &item: items)
5455
{
5556
if (!item->frozen)
5657
{
5758
sum_scaled_flex_shrink_factor += item->scaled_flex_shrink_factor;
59+
sum_flex_grow_factor += item->grow;
5860
remaining_free_space -= item->base_size;
5961
total_not_frozen++;
6062
} else
@@ -115,7 +117,7 @@ void litehtml::flex_line::distribute_free_space(pixel_t container_main_size)
115117
// factors of all unfrozen items on the line. Set the item’s target main size to
116118
// its flex base size plus a fraction of the remaining free space proportional
117119
// to the ratio.
118-
item->main_size = item->base_size + remaining_free_space * (pixel_t) item->grow / (pixel_t) total_flex_factor;
120+
item->main_size = item->base_size + remaining_free_space * (pixel_t) item->grow / (pixel_t) sum_flex_grow_factor;
119121

120122
// d. Fix min/max violations. Clamp each non-frozen item’s target main size by its used
121123
// min and max main sizes and floor its content-box size at zero. If the item’s target

0 commit comments

Comments
 (0)