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

LibWeb: Don't drop single <br/> lines

Previously, when having inline contexts consisting of just a `<br/>`
tag, we would not create a line box.

Ensure that there is always a line box when a line is explicitly being
broken and also ensure it won't be trimmed due to being empty.

This will a fix a number of sites that use `<br>` tags for layouts
between block elements (even though the spec says they shouldn't).
This commit is contained in:
Mathis Wiehl 2023-03-15 21:11:38 +01:00 committed by Sam Atkins
parent 2fe4be40af
commit 9927dab993
4 changed files with 29 additions and 2 deletions

View file

@ -26,6 +26,9 @@ LineBuilder::~LineBuilder()
void LineBuilder::break_line(Optional<CSSPixels> next_item_width)
{
auto last_line_box = ensure_last_line_box();
last_line_box.m_has_break = true;
update_last_line();
size_t break_count = 0;
bool floats_intrude_at_current_y = false;
@ -305,7 +308,7 @@ void LineBuilder::remove_last_line_if_empty()
{
// If there's an empty line box at the bottom, just remove it instead of giving it height.
auto& line_boxes = m_containing_block_state.line_boxes;
if (!line_boxes.is_empty() && line_boxes.last().fragments().is_empty()) {
if (!line_boxes.is_empty() && line_boxes.last().is_empty()) {
line_boxes.take_last();
m_last_line_needs_update = false;
}