summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-07-23 01:40:09 +0200
committerAndreas Kling <kling@serenityos.org>2022-07-25 15:03:18 +0200
commitfac4529082eb118e801c8957b326b22bf57afe9c (patch)
treee37dbba44d84103750c6a7ca8473e95dad816f90 /Userland
parent050e70cc7e8f1a8b4c4b0c79966cb76c151c8174 (diff)
downloadserenity-fac4529082eb118e801c8957b326b22bf57afe9c.zip
LibWeb: Honor flex container sizing constraints in available space
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
index a1b9652ccc..71a526cbe0 100644
--- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
@@ -62,6 +62,20 @@ void FlexFormattingContext::run(Box const& run_box, LayoutMode layout_mode)
bool cross_is_constrained = false;
determine_available_main_and_cross_space(main_is_constrained, cross_is_constrained, main_min_size, main_max_size, cross_min_size, cross_max_size);
+ if (m_flex_container_state.width_constraint == SizeConstraint::MaxContent || m_flex_container_state.height_constraint == SizeConstraint::MaxContent) {
+ if (is_row_layout())
+ m_available_space->main = INFINITY;
+ else
+ m_available_space->cross = INFINITY;
+ }
+
+ if (m_flex_container_state.width_constraint == SizeConstraint::MinContent || m_flex_container_state.height_constraint == SizeConstraint::MinContent) {
+ if (is_row_layout())
+ m_available_space->main = 0;
+ else
+ m_available_space->cross = 0;
+ }
+
// 3. Determine the flex base size and hypothetical main size of each item
for (auto& flex_item : m_flex_items) {
if (flex_item.box.is_replaced_box()) {