@@ -21,6 +21,8 @@ void litehtml::flex_line::distribute_free_space_grow(pixel_t container_main_size
2121{
2222 pixel_t initial_free_space = container_main_size;
2323
24+ bool all_inflexible = true ;
25+
2426 for (auto & item : items)
2527 {
2628 // 2. Size inflexible items. Freeze, setting its target main size to its hypothetical main size
@@ -39,14 +41,17 @@ void litehtml::flex_line::distribute_free_space_grow(pixel_t container_main_size
3941 } else
4042 {
4143 initial_free_space -= item->base_size ;
44+ all_inflexible = false ;
4245 }
4346 }
4447
4548 // 4. Loop:
4649
4750 // 4.a Check for flexible items. If all the flex items on the line are frozen, free space has been
4851 // distributed; exit this loop.
49-
52+
53+ if (all_inflexible) return ;
54+
5055 while (true )
5156 {
5257 // 4.b Calculate the remaining free space as for initial free space, above. If the sum of the
@@ -107,6 +112,8 @@ void litehtml::flex_line::distribute_free_space_shrink(pixel_t container_main_si
107112{
108113 pixel_t initial_free_space = container_main_size;
109114
115+ bool all_inflexible = true ;
116+
110117 for (auto & item : items)
111118 {
112119 // 2. Size inflexible items. Freeze, setting its target main size to its hypothetical main size
@@ -125,14 +132,17 @@ void litehtml::flex_line::distribute_free_space_shrink(pixel_t container_main_si
125132 } else
126133 {
127134 initial_free_space -= item->base_size ;
135+ all_inflexible = false ;
128136 }
129137 }
130138
131139 // 4. Loop:
132140
133141 // 4.a Check for flexible items. If all the flex items on the line are frozen, free space has been
134142 // distributed; exit this loop.
135-
143+
144+ if (all_inflexible) return ;
145+
136146 while (true )
137147 {
138148 // 4.b Calculate the remaining free space as for initial free space, above. If the sum of the
0 commit comments