From 762f20944c1340c182ec8930f95ccb000385b918 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 19 Oct 2019 09:44:40 +0200 Subject: [PATCH] LibHTML: Replaced elements should not break lines at start of line If the current line box already has zero width, there's no point in inserting a line break to make space, since we'll just be at x=0 after breaking as well. This removes an ugly unnecessary line break before images wider than their containing block. :^) --- Libraries/LibHTML/Layout/LayoutReplaced.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/LibHTML/Layout/LayoutReplaced.cpp b/Libraries/LibHTML/Layout/LayoutReplaced.cpp index 2551ecd4c8..a215d782dd 100644 --- a/Libraries/LibHTML/Layout/LayoutReplaced.cpp +++ b/Libraries/LibHTML/Layout/LayoutReplaced.cpp @@ -18,7 +18,7 @@ void LayoutReplaced::split_into_lines(LayoutBlock& container) layout(); auto* line_box = &container.ensure_last_line_box(); - if (line_box->width() + width() > container.width()) + if (line_box->width() > 0 && line_box->width() + width() > container.width()) line_box = &container.add_line_box(); line_box->add_fragment(*this, 0, 0, width(), height()); }