1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:07:34 +00:00

LibWeb: Don't break text lines if white-space: nowrap

If white-space is nowrap then we don't want to break a text_node
into multiple line boxes. This fixes the width calculation in the
min-content case for white-space: nowrap elements. Before this
the min-width would be the width of the biggest line box.
This commit is contained in:
Enver Balalic 2022-04-03 21:05:09 +02:00 committed by Andreas Kling
parent fd82121319
commit 7381474835

View file

@ -252,7 +252,8 @@ void InlineFormattingContext::generate_line_boxes(LayoutMode layout_mode)
case InlineLevelIterator::Item::Type::Text: {
auto& text_node = verify_cast<Layout::TextNode>(*item.node);
if (line_builder.break_if_needed(layout_mode, item.border_box_width())) {
if (text_node.computed_values().white_space() != CSS::WhiteSpace::Nowrap && line_builder.break_if_needed(layout_mode, item.border_box_width())) {
// If whitespace caused us to break, we swallow the whitespace instead of
// putting it on the next line.