1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:28:12 +00:00

LibWeb: Support reverse flex layout with space-around/space-between

We were not taking reverse flex directions into account when choosing
the initial offset for flex item placement if justify-content were
either space-around or space-between.
This commit is contained in:
Andreas Kling 2023-05-28 15:39:21 +02:00
parent d15ae9fa93
commit 30feb95d53
3 changed files with 103 additions and 1 deletions

View file

@ -1323,11 +1323,20 @@ void FlexFormattingContext::distribute_any_remaining_free_space()
}
break;
case CSS::JustifyContent::SpaceBetween:
if (is_direction_reverse()) {
initial_offset = inner_main_size(flex_container());
} else {
initial_offset = 0;
}
space_between_items = flex_line.remaining_free_space / (number_of_items - 1);
break;
case CSS::JustifyContent::SpaceAround:
space_between_items = flex_line.remaining_free_space / number_of_items;
initial_offset = space_between_items / 2.0;
if (is_direction_reverse()) {
initial_offset = inner_main_size(flex_container()) - space_between_items / 2.0;
} else {
initial_offset = space_between_items / 2.0;
}
break;
}
}