Share more code for non-replaced float-avoiding blocks (#34585)

Block-level elements that establish an independent formatting context
(or are replaced) need to avoid overlapping floats.

In the non-replaced case, we have two different subcases, depending on
whether the inline size of the element is known. This patch makes them
share more logic.

Then `solve_clearance_and_inline_margins_avoiding_floats()` would only
be used in the replaced case, so it's removed, inlining its logic.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2024-12-12 13:53:44 +01:00 committed by GitHub
parent 0ffa5fa277
commit acf0074f8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 46 additions and 86 deletions

View file

@ -1103,11 +1103,8 @@ impl SequentialLayoutState {
let placement_rect = placement.place();
let position = &placement_rect.start_corner;
let has_clearance = clear_position.is_some() || position.block > ceiling;
let clearance = if has_clearance {
Some(position.block - self.position_with_zero_clearance(block_start_margin))
} else {
None
};
let clearance = has_clearance
.then(|| position.block - self.position_with_zero_clearance(block_start_margin));
(clearance, placement_rect)
}