LibWeb: Change inline float clearance to not reset margin collapsing

When a block container has `clear` set and some clearance is applied,
that clearance prevents margins from adjoining and therefore resets
the margin state. But when a floating box has `clear` set, that
clearance only goes between floating boxes so should not reset margin
state. BlockFormattingContexts already do that correctly, and this PR
changes InlineFormattingContext to do the same.

Fixes #1462; adds reduced input from that issue as test.
This commit is contained in:
Pavel Panchekha 2024-09-20 12:53:45 -06:00 committed by Alexander Kalenik
commit 9075f64cac
Notes: github-actions[bot] 2024-09-20 23:56:34 +00:00
3 changed files with 39 additions and 3 deletions

View file

@ -314,9 +314,11 @@ void InlineFormattingContext::generate_line_boxes()
case InlineLevelIterator::Item::Type::FloatingElement:
if (is<Box>(*item.node)) {
auto introduce_clearance = parent().clear_floating_boxes(*item.node, *this);
if (introduce_clearance == BlockFormattingContext::DidIntroduceClearance::Yes)
parent().reset_margin_state();
[[maybe_unused]] auto introduce_clearance = parent().clear_floating_boxes(*item.node, *this);
// Even if this introduces clearance, we do NOT reset
// the margin state, because that is clearance between
// floats and does not contribute to the height of the
// Inline Formatting Context.
parent().layout_floating_box(static_cast<Layout::Box const&>(*item.node), containing_block(), *m_available_space, 0, &line_builder);
}
break;