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

LibWeb: Replace to_px() with to_px_or_zero() in InlineFormattingContext

to_px() usage should be avoided because it might leak saturated
(infinite) values into layout calculations.
This commit is contained in:
Aliaksandr Kalenik 2023-08-12 18:30:18 +02:00 committed by Andreas Kling
parent 4646867a9f
commit fce4801460
7 changed files with 29 additions and 21 deletions

View file

@ -136,7 +136,7 @@ CSSPixels LineBuilder::y_for_float_to_be_inserted_here(Box const& box)
bool LineBuilder::should_break(CSSPixels next_item_width)
{
if (!isfinite(m_available_width_for_current_line.to_double()))
if (m_available_width_for_current_line.is_max_content())
return false;
auto const& line_boxes = m_containing_block_state.line_boxes;
@ -169,7 +169,7 @@ 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);
CSSPixels excess_horizontal_space = m_available_width_for_current_line - line_box.width();
CSSPixels excess_horizontal_space = m_available_width_for_current_line.to_px_or_zero() - line_box.width();
// If (after justification, if any) the inline contents of a line box are too long to fit within it,
// then the contents are start-aligned: any content that doesn't fit overflows the line boxs end edge.