From 232e41a238f1eb3c96aac20d30d98eb9e012c680 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 25 Jun 2020 12:40:07 +0200 Subject: [PATCH] LibWeb: Remove empty trailing line boxes Sometimes we end up with an empty line box at the bottom of a block. Instead of worrying about this in all the places we split into lines, just remove the trailing box (if any) after splitting is finshed. --- Libraries/LibWeb/Layout/LayoutBlock.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Libraries/LibWeb/Layout/LayoutBlock.cpp b/Libraries/LibWeb/Layout/LayoutBlock.cpp index b48d2968fb..560cb47fe1 100644 --- a/Libraries/LibWeb/Layout/LayoutBlock.cpp +++ b/Libraries/LibWeb/Layout/LayoutBlock.cpp @@ -185,6 +185,10 @@ void LayoutBlock::layout_inline_children(LayoutMode layout_mode) line_box.trim_trailing_whitespace(); } + // If there's an empty line box at the bottom, just remove it instead of giving it height. + if (!m_line_boxes.is_empty() && m_line_boxes.last().fragments().is_empty()) + m_line_boxes.take_last(); + auto text_align = style().text_align(); float min_line_height = specified_style().line_height(*this); float line_spacing = min_line_height - specified_style().font().glyph_height();