Properly position absolutes with static insets that are children of floats

Previously, final float positions were calculated when their parents
were positioned. This prevented proper positioning of absolute children
of floats with static insets, because they accumulate offsets as they
are hoisted up the tree.

This change moves the final float positioning to
`PlacementState::place_fragment` for the float itself so that it happens
before any insets are updated for hoisted descendants. In addition to
simplifying the code, this makes it a bit more efficient. Finally,
floats are taken into account when updating static insets of hoisted
boxes.

Fixes #29826.
This commit is contained in:
Martin Robinson 2023-06-21 08:31:55 +02:00 committed by Oriol Brufau
parent 9edc2c664f
commit 30ab348116
17 changed files with 114 additions and 135 deletions

View file

@ -167,8 +167,8 @@ impl PositioningContext {
parent_fragment: &Fragment,
) {
let fragment_rect = match &parent_fragment {
Fragment::Box(b) => &b.content_rect,
Fragment::AbsoluteOrFixedPositioned(_) | Fragment::Float(_) => return,
Fragment::Box(b) | Fragment::Float(b) => &b.content_rect,
Fragment::AbsoluteOrFixedPositioned(_) => return,
Fragment::Anonymous(a) => &a.rect,
_ => unreachable!(),
};