diff options
author | Andreas Kling <kling@serenityos.org> | 2023-01-25 14:16:25 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-01-26 12:34:56 +0100 |
commit | 61d65294fa9b2d74fafbb67fa9066a59cc793641 (patch) | |
tree | 95a81ea2a6e9dacc6d0e2faaf34978e746198321 /Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp | |
parent | 0bbc54c20088e9bdf97f282c959ede84b112c46f (diff) | |
download | serenity-61d65294fa9b2d74fafbb67fa9066a59cc793641.zip |
LibWeb: Always pass some available space to flex item fit-content sizing
Same deal as flex item intrinsic sizing: if we have definite size for
the item, use that, otherwise fall back to the available space.
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp index 22e38489d9..712d1faf4c 100644 --- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp @@ -1862,14 +1862,20 @@ CSSPixels FlexFormattingContext::calculate_max_content_main_size(FlexItem const& CSSPixels FlexFormattingContext::calculate_fit_content_main_size(FlexItem const& item) const { - return is_row_layout() ? calculate_fit_content_width(item.box, m_available_space_for_items->space) - : calculate_fit_content_height(item.box, m_available_space_for_items->space); + if (is_row_layout()) + return calculate_fit_content_width(item.box, m_available_space_for_items->space); + if (item.cross_size.has_value()) + return calculate_fit_content_height(item.box, AvailableSpace(AvailableSize::make_definite(item.cross_size.value()), m_available_space_for_items->space.height)); + return calculate_fit_content_height(item.box, m_available_space_for_items->space); } CSSPixels FlexFormattingContext::calculate_fit_content_cross_size(FlexItem const& item) const { - return !is_row_layout() ? calculate_fit_content_width(item.box, m_available_space_for_items->space) - : calculate_fit_content_height(item.box, m_available_space_for_items->space); + if (!is_row_layout()) + return calculate_fit_content_width(item.box, m_available_space_for_items->space); + if (item.main_size.has_value()) + return calculate_fit_content_height(item.box, AvailableSpace(AvailableSize::make_definite(item.main_size.value()), m_available_space_for_items->space.height)); + return calculate_fit_content_height(item.box, m_available_space_for_items->space); } CSSPixels FlexFormattingContext::calculate_min_content_cross_size(FlexItem const& item) const |