1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 11:17:44 +00:00

LibWeb: Rewrite calculation of available space between floats

This code now works in terms of *intrusion* by left and right side
floats into a given box whose insides we're trying to layout.

Previously, it worked in terms of space occupied by floats in the root
box of the BFC they participated in. That created a bunch of edge cases
since the code asking about the information wasn't operating in root
coordinate space, but in the coordinate space of some arbitrarily nested
block descendant of the root.

This finally allows horizontal margins in the containing block chain to
affect floats and nested content correctly, and it also allows us to
remove a bogus workaround in InlineFormattingContext.
This commit is contained in:
Andreas Kling 2023-05-16 09:46:45 +02:00
parent 9bd4add734
commit bab6796099
8 changed files with 159 additions and 40 deletions

View file

@ -167,10 +167,6 @@ void LineBuilder::update_last_line()
CSSPixels x_offset_bottom = m_context.leftmost_x_offset_at(m_current_y + current_line_height - 1);
CSSPixels x_offset = max(x_offset_top, x_offset_bottom);
// If the IFC's containing block has left-side margin, it has already been shifted to the right by that amount.
// We subtract the margin-left here to ensure that the left-side "space used by floats" doesn't get applied twice.
x_offset = max(CSSPixels(0), x_offset - m_containing_block_state.margin_left);
CSSPixels excess_horizontal_space = m_available_width_for_current_line - line_box.width();
switch (text_align) {