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

LibWeb: Collapse margin-left with space used by left-side floats

We had an issue where boxes with margin-left were shifted right by
left-side floats twice instead of just once.
This commit is contained in:
Andreas Kling 2023-03-10 22:06:20 +01:00
parent 1cf5737e9e
commit f97754942c
3 changed files with 29 additions and 0 deletions

View file

@ -158,6 +158,10 @@ 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) {