LibWeb: Apply vertical clearance to next line after <br> with clear:

We were introducing a line break and applying vertical clearance to the
inline formatting context, but that vertical clearance only applied to
new floating boxes. We should move the current block offset to the
vertical clearance to make sure the next line box starts beyond the
cleared floats.

There was a layout test for `<br>` with `clear: ..` set, but that test
did not actually do anything - removing the `clear` property would
result in the same layout. Replace that test with something that
actually tests float clearing.

Relates to #4058.
This commit is contained in:
Jelle Raaijmakers 2025-03-27 11:34:20 +00:00
commit 683d6b77dd
Notes: github-actions[bot] 2025-03-27 13:58:54 +00:00
4 changed files with 25 additions and 45 deletions

View file

@ -13,8 +13,6 @@
#include <LibWeb/Layout/InlineFormattingContext.h>
#include <LibWeb/Layout/InlineLevelIterator.h>
#include <LibWeb/Layout/LineBuilder.h>
#include <LibWeb/Layout/ReplacedBox.h>
#include <LibWeb/Layout/SVGSVGBox.h>
namespace Web::Layout {
@ -285,8 +283,10 @@ void InlineFormattingContext::generate_line_boxes()
line_builder.break_line(LineBuilder::ForcedBreak::Yes);
if (item.node) {
auto introduce_clearance = parent().clear_floating_boxes(*item.node, *this);
if (introduce_clearance == BlockFormattingContext::DidIntroduceClearance::Yes)
if (introduce_clearance == BlockFormattingContext::DidIntroduceClearance::Yes) {
line_builder.set_current_block_offset(vertical_float_clearance());
parent().reset_margin_state();
}
}
break;
}
@ -392,9 +392,8 @@ void InlineFormattingContext::generate_line_boxes()
}
}
for (auto& line_box : line_boxes) {
for (auto& line_box : line_boxes)
line_box.trim_trailing_whitespace();
}
line_builder.remove_last_line_if_empty();