LibWeb: Layout inner floats/abspos boxes after laying out the top float

Calling parent_context_did_dimension_child_root_box immediately after
laying out the inside of the floating box is not correct, as we haven't
worked out the dimensions of the floating box yet.

In particular, this caused the icons in the top bar of Cookie Clicker
to not hug the top of the viewport. This is because the icons are
absolutely positioned elements inside a floating element which has
padding applied to it. Since we laid out the abspos element before
the floating element, it got padding values of 0 from the parent, the
default value, meaning it didn't take away the padding of it's floating
parent.

This follows how abspos boxes layout their inside boxes as well.
This commit is contained in:
Luke Wilde 2022-10-24 19:46:32 +01:00 committed by Andreas Kling
parent 0e232b1c8d
commit 488a979306
Notes: sideshowbarker 2024-07-17 05:18:58 +09:00

View file

@ -556,8 +556,7 @@ void BlockFormattingContext::layout_floating_box(Box const& box, BlockContainer
float width_of_containing_block = available_space.width.to_px();
compute_width(box, available_space, layout_mode);
if (auto independent_formatting_context = layout_inside(box, layout_mode, box_state.available_inner_space_or_constraints_from(available_space)))
independent_formatting_context->parent_context_did_dimension_child_root_box();
auto independent_formatting_context = layout_inside(box, layout_mode, box_state.available_inner_space_or_constraints_from(available_space));
compute_height(box, available_space);
// First we place the box normally (to get the right y coordinate.)
@ -674,6 +673,9 @@ void BlockFormattingContext::layout_floating_box(Box const& box, BlockContainer
if (line_builder)
line_builder->recalculate_available_space();
if (independent_formatting_context)
independent_formatting_context->parent_context_did_dimension_child_root_box();
}
void BlockFormattingContext::layout_list_item_marker(ListItemBox const& list_item_box)