summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-01-15 17:51:30 +0100
committerAndreas Kling <kling@serenityos.org>2023-01-26 12:34:56 +0100
commit1ea276bf6d261b9de22b1f54bd28c7e710889d22 (patch)
treebd446803d3fadb6d9da9f1e43b7b457d3695bb51 /Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
parent00f8b5a911d17d29db56c7d5373e37e64dffae57 (diff)
downloadserenity-1ea276bf6d261b9de22b1f54bd28c7e710889d22.zip
LibWeb: Take used width into account for flex item intrinsic heights
If we've already established the used width for a flex item, we need to take it into account when calculating the min-content and max-content heights for that item. We were already doing this when calculating cross sizes. This patch adds the same consideration for main sizes.
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp')
-rw-r--r--Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
index 6b121f7dd9..02dc6b2755 100644
--- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
@@ -1846,7 +1846,18 @@ CSSPixels FlexFormattingContext::calculate_cross_max_content_contribution(FlexIt
CSSPixels FlexFormattingContext::calculate_min_content_main_size(FlexItem const& item) const
{
- return is_row_layout() ? calculate_min_content_width(item.box) : calculate_min_content_height(item.box, m_available_space_for_items->space.width);
+ if (is_row_layout()) {
+ return calculate_min_content_width(item.box);
+ }
+ return calculate_min_content_height(item.box, item.cross_size.has_value() ? AvailableSize::make_definite(item.cross_size.value()) : AvailableSize::make_indefinite());
+}
+
+CSSPixels FlexFormattingContext::calculate_max_content_main_size(FlexItem const& item) const
+{
+ if (is_row_layout()) {
+ return calculate_max_content_width(item.box);
+ }
+ return calculate_max_content_height(item.box, item.cross_size.has_value() ? AvailableSize::make_definite(item.cross_size.value()) : AvailableSize::make_indefinite());
}
CSSPixels FlexFormattingContext::calculate_fit_content_main_size(FlexItem const& item) const
@@ -1861,11 +1872,6 @@ CSSPixels FlexFormattingContext::calculate_fit_content_cross_size(FlexItem const
: calculate_fit_content_height(item.box, m_available_space_for_items->space);
}
-CSSPixels FlexFormattingContext::calculate_max_content_main_size(FlexItem const& item) const
-{
- return is_row_layout() ? calculate_max_content_width(item.box) : calculate_max_content_height(item.box, m_available_space_for_items->space.width);
-}
-
CSSPixels FlexFormattingContext::calculate_min_content_cross_size(FlexItem const& item) const
{
if (is_row_layout()) {