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

LibWeb: Break lines until we have enough space between floats

Before this change, we'd always insert one line box fragment, even when
a float was taking up too much space on the line, and the fragment
didn't actually fit.

We now perform line breaks until we have enough space between floats.
This fixes many page layouts where we'd previously see small fragments
of inline content outside the right edge of the containing block.
This commit is contained in:
Andreas Kling 2022-09-11 22:39:01 +02:00
parent c9a7853fef
commit 71ca857b67
4 changed files with 30 additions and 10 deletions

View file

@ -18,7 +18,7 @@ public:
LineBuilder(InlineFormattingContext&, LayoutState&);
~LineBuilder();
void break_line();
void break_line(Optional<float> next_item_width = {});
void append_box(Box const&, float leading_size, float trailing_size, float leading_margin, float trailing_margin);
void append_text_chunk(TextNode const&, size_t offset_in_node, size_t length_in_node, float leading_size, float trailing_size, float leading_margin, float trailing_margin, float content_width, float content_height);
@ -26,7 +26,7 @@ public:
bool break_if_needed(float next_item_width)
{
if (should_break(next_item_width)) {
break_line();
break_line(next_item_width);
return true;
}
return false;