|
@@ -836,11 +836,16 @@ void FlexFormattingContext::determine_hypothetical_cross_size_of_item(FlexItem&
|
|
} else {
|
|
} else {
|
|
// Item has indefinite main size, layout with "fit-content"
|
|
// Item has indefinite main size, layout with "fit-content"
|
|
|
|
|
|
- float fit_content_main_size;
|
|
|
|
- if (is_row_layout())
|
|
|
|
- fit_content_main_size = calculate_fit_content_width(item.box, m_available_space->main);
|
|
|
|
- else
|
|
|
|
- fit_content_main_size = calculate_fit_content_height(item.box, m_available_space->main);
|
|
|
|
|
|
+ // If we're in a column layout and looking for the width, just use the fit-content width.
|
|
|
|
+ if (!is_row_layout()) {
|
|
|
|
+ item.hypothetical_cross_size = calculate_fit_content_width(item.box, m_available_space->cross);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // We're in a row layout, looking for the height. Figure out the fit-content width,
|
|
|
|
+ // then layout with that and see what height comes out of it.
|
|
|
|
+
|
|
|
|
+ float fit_content_main_size = calculate_fit_content_width(item.box, m_available_space->main);
|
|
|
|
|
|
FormattingState throwaway_state(&m_state);
|
|
FormattingState throwaway_state(&m_state);
|
|
auto& box_state = throwaway_state.get_mutable(item.box);
|
|
auto& box_state = throwaway_state.get_mutable(item.box);
|
|
@@ -850,18 +855,10 @@ void FlexFormattingContext::determine_hypothetical_cross_size_of_item(FlexItem&
|
|
// NOTE: Flex items should always create an independent formatting context!
|
|
// NOTE: Flex items should always create an independent formatting context!
|
|
VERIFY(independent_formatting_context);
|
|
VERIFY(independent_formatting_context);
|
|
|
|
|
|
- if (is_row_layout()) {
|
|
|
|
- box_state.content_width = fit_content_main_size;
|
|
|
|
- } else {
|
|
|
|
- box_state.content_height = fit_content_main_size;
|
|
|
|
- }
|
|
|
|
|
|
+ box_state.content_width = fit_content_main_size;
|
|
independent_formatting_context->run(item.box, LayoutMode::Default);
|
|
independent_formatting_context->run(item.box, LayoutMode::Default);
|
|
|
|
|
|
- if (is_row_layout()) {
|
|
|
|
- item.hypothetical_cross_size = BlockFormattingContext::compute_theoretical_height(throwaway_state, item.box);
|
|
|
|
- } else {
|
|
|
|
- item.hypothetical_cross_size = box_state.content_width;
|
|
|
|
- }
|
|
|
|
|
|
+ item.hypothetical_cross_size = BlockFormattingContext::compute_theoretical_height(throwaway_state, item.box);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|