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

LibWeb: Don't round fragment widths while accumulating in LineBuilder

By rounding the fragment widths, we sometimes inserted line breaks
prematurely, even though the fragment *would* fit.
This commit is contained in:
Andreas Kling 2022-09-28 18:35:22 +02:00
parent d64a8c3d2a
commit e8a5233b94

View file

@ -103,7 +103,7 @@ float LineBuilder::y_for_float_to_be_inserted_here(Box const& box)
float current_line_width = ensure_last_line_box().width(); float current_line_width = ensure_last_line_box().width();
// If there's already inline content on the current line, check if the new float can fit // If there's already inline content on the current line, check if the new float can fit
// alongside the content. If not, place it on the next line. // alongside the content. If not, place it on the next line.
if (current_line_width > 0 && roundf(current_line_width + width) > m_available_width_for_current_line) if (current_line_width > 0 && (current_line_width + width) > m_available_width_for_current_line)
candidate_y += m_context.containing_block().line_height(); candidate_y += m_context.containing_block().line_height();
// Then, look for the next Y position where we can fit the new float. // Then, look for the next Y position where we can fit the new float.
@ -138,7 +138,7 @@ bool LineBuilder::should_break(float next_item_width)
return false; return false;
} }
auto current_line_width = ensure_last_line_box().width(); auto current_line_width = ensure_last_line_box().width();
return roundf(current_line_width + next_item_width) > m_available_width_for_current_line; return (current_line_width + next_item_width) > m_available_width_for_current_line;
} }
static float box_baseline(LayoutState const& state, Box const& box) static float box_baseline(LayoutState const& state, Box const& box)