mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
LibWeb: Use available space in FFC remaining space calculations
We were incorrectly using the inner main size of the flex container instead of the avilable space in some parts of the remaining space calculation. This meant that the algorithm only worked correctly for definite available space in the main axis.
This commit is contained in:
parent
5c13631625
commit
16eca649f1
1 changed files with 3 additions and 3 deletions
|
@ -867,7 +867,7 @@ void FlexFormattingContext::collect_flex_items_into_flex_lines()
|
|||
CSSPixels line_main_size = 0;
|
||||
for (auto& flex_item : m_flex_items) {
|
||||
auto outer_hypothetical_main_size = flex_item.hypothetical_main_size + flex_item.margins.main_before + flex_item.margins.main_after + flex_item.borders.main_before + flex_item.borders.main_after + flex_item.padding.main_before + flex_item.padding.main_after;
|
||||
if (!line.items.is_empty() && (line_main_size + outer_hypothetical_main_size) > specified_main_size(flex_container())) {
|
||||
if (!line.items.is_empty() && (line_main_size + outer_hypothetical_main_size) > m_available_space_for_items->main.to_px_or_zero()) {
|
||||
m_flex_lines.append(move(line));
|
||||
line = {};
|
||||
line_main_size = 0;
|
||||
|
@ -895,7 +895,7 @@ void FlexFormattingContext::resolve_flexible_lengths()
|
|||
for (auto& flex_item : flex_line.items) {
|
||||
sum_of_hypothetical_main_sizes += (flex_item->hypothetical_main_size + flex_item->margins.main_before + flex_item->margins.main_after + flex_item->borders.main_before + flex_item->borders.main_after + flex_item->padding.main_before + flex_item->padding.main_after);
|
||||
}
|
||||
if (sum_of_hypothetical_main_sizes < specified_main_size(flex_container()))
|
||||
if (sum_of_hypothetical_main_sizes < m_available_space_for_items->main.to_px_or_zero())
|
||||
used_flex_factor = FlexFactor::FlexGrowFactor;
|
||||
else
|
||||
used_flex_factor = FlexFactor::FlexShrinkFactor;
|
||||
|
@ -937,7 +937,7 @@ void FlexFormattingContext::resolve_flexible_lengths()
|
|||
else
|
||||
sum_of_items_on_line += flex_item->flex_base_size + flex_item->margins.main_before + flex_item->margins.main_after + flex_item->borders.main_before + flex_item->borders.main_after + flex_item->padding.main_before + flex_item->padding.main_after;
|
||||
}
|
||||
return specified_main_size(flex_container()) - sum_of_items_on_line;
|
||||
return m_available_space_for_items->main.to_px_or_zero() - sum_of_items_on_line;
|
||||
};
|
||||
|
||||
CSSPixels initial_free_space = calculate_free_space();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue