summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-01-25 15:02:36 +0100
committerAndreas Kling <kling@serenityos.org>2023-01-26 12:34:56 +0100
commit16eca649f182e52270c9edc25acc4b1a758ac52a (patch)
tree5586568c988dc80e0314507cd6587ab13ef5b815 /Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
parent5c136316258f279fe7af3b41896869e82718df9d (diff)
downloadserenity-16eca649f182e52270c9edc25acc4b1a758ac52a.zip
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.
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp')
-rw-r--r--Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
index 5609a79cc3..9bece55642 100644
--- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
@@ -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();