LibWeb: Make non-finite CSS lengths resolve to "auto"

When we're performing max-content layout (a separate throwaway layout
pass that only exists to discover the intrinsic max-content size of
a specific box), we act as if the containing block has infinite width.

This allows an infinite length to propagate into the layout system,
which is fine, but at some point it needs to be turned into a finite
number or some loop conditions will not make sense and we can hang
indefinitely (e.g in the flexible lengths resolution algorithm.)

We fix this by making Length::resolved() turn non-finite values into
an "auto" length.
This commit is contained in:
Andreas Kling 2022-07-06 13:05:31 +02:00
parent b3deec061e
commit e7370443f2

View file

@ -64,6 +64,8 @@ Length Length::resolved(Layout::Node const& layout_node) const
return m_calculated_style->resolve_length(layout_node).release_value();
if (is_relative())
return make_px(to_px(layout_node));
if (!isfinite(m_value))
return make_auto();
return *this;
}