diff --git a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp index 296637de72..9c70497a34 100644 --- a/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.cpp @@ -122,49 +122,44 @@ void InlineFormattingContext::dimension_box_on_line(Box const& box, LayoutMode l return; } - if (box.display().is_flow_root_inside()) { - auto const& width_value = box.computed_values().width(); - if (width_value.is_auto()) { - auto result = calculate_shrink_to_fit_widths(box); + // Any box that has simple flow inside should have generated line box fragments already. + VERIFY(!box.display().is_flow_inside()); - auto available_width = m_available_space->width.to_px() - - box_state.margin_left - - box_state.border_left - - box_state.padding_left - - box_state.padding_right - - box_state.border_right - - box_state.margin_right; + auto const& width_value = box.computed_values().width(); + if (width_value.is_auto()) { + auto result = calculate_shrink_to_fit_widths(box); - auto width = min(max(result.preferred_minimum_width, available_width), result.preferred_width); - box_state.set_content_width(width); + auto available_width = m_available_space->width.to_px() + - box_state.margin_left + - box_state.border_left + - box_state.padding_left + - box_state.padding_right + - box_state.border_right + - box_state.margin_right; + + auto width = min(max(result.preferred_minimum_width, available_width), result.preferred_width); + box_state.set_content_width(width); + } else { + if (width_value.contains_percentage() && !m_available_space->width.is_definite()) { + // NOTE: We can't resolve percentages yet. We'll have to wait until after inner layout. } else { - if (width_value.contains_percentage() && !m_available_space->width.is_definite()) { - // NOTE: We can't resolve percentages yet. We'll have to wait until after inner layout. - } else { - auto container_width = CSS::Length::make_px(m_available_space->width.to_px()); - box_state.set_content_width(width_value.resolved(box, container_width).to_px(box)); - } + auto container_width = CSS::Length::make_px(m_available_space->width.to_px()); + box_state.set_content_width(width_value.resolved(box, container_width).to_px(box)); } - auto independent_formatting_context = layout_inside(box, layout_mode, box_state.available_inner_space_or_constraints_from(*m_available_space)); + } + auto independent_formatting_context = layout_inside(box, layout_mode, box_state.available_inner_space_or_constraints_from(*m_available_space)); - auto const& height_value = box.computed_values().height(); - if (height_value.is_auto()) { - // FIXME: (10.6.6) If 'height' is 'auto', the height depends on the element's descendants per 10.6.7. - parent().compute_height(box, AvailableSpace(AvailableSize::make_indefinite(), AvailableSize::make_indefinite())); - } else { - auto container_height = CSS::Length::make_px(m_containing_block_state.content_height()); - box_state.set_content_height(height_value.resolved(box, container_height).to_px(box)); - } - - if (independent_formatting_context) - independent_formatting_context->parent_context_did_dimension_child_root_box(); - return; + auto const& height_value = box.computed_values().height(); + if (height_value.is_auto()) { + // FIXME: (10.6.6) If 'height' is 'auto', the height depends on the element's descendants per 10.6.7. + parent().compute_height(box, AvailableSpace(AvailableSize::make_indefinite(), AvailableSize::make_indefinite())); + } else { + auto container_height = CSS::Length::make_px(m_containing_block_state.content_height()); + box_state.set_content_height(height_value.resolved(box, container_height).to_px(box)); } - // Non-replaced, non-inline-block, box on a line!? - // I don't think we should be here. Dump the box tree so we can take a look at it. - dbgln("FIXME: I've been asked to dimension a non-replaced, non-inline-block box on a line:"); - dump_tree(box); + if (independent_formatting_context) + independent_formatting_context->parent_context_did_dimension_child_root_box(); } void InlineFormattingContext::apply_justification_to_fragments(CSS::TextJustify text_justify, LineBox& line_box, bool is_last_line)