1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:18:14 +00:00

LibHTML: Fix broken line splitting behavior in LayoutReplaced

Replaced elements will now properly create line breaks when they use up
the available horizontal space.

This fixes an issue with <img>'s lining up instead of breaking.
This commit is contained in:
Andreas Kling 2019-10-13 17:24:00 +02:00
parent 282456dc37
commit 44979ad7a5
4 changed files with 23 additions and 3 deletions

View file

@ -17,7 +17,8 @@ void LayoutReplaced::split_into_lines(LayoutBlock& container)
{
layout();
if (container.line_boxes().is_empty())
container.line_boxes().append(LineBox());
container.line_boxes().last().add_fragment(*this, 0, 0, rect().width(), rect().height());
auto* line_box = &container.ensure_last_line_box();
if (line_box->width() + width() > container.width())
line_box = &container.add_line_box();
line_box->add_fragment(*this, 0, 0, width(), height());
}