From e7370443f2d40505086c1c9d5cd1e8c12a739b06 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 6 Jul 2022 13:05:31 +0200 Subject: [PATCH] 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. --- Userland/Libraries/LibWeb/CSS/Length.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Userland/Libraries/LibWeb/CSS/Length.cpp b/Userland/Libraries/LibWeb/CSS/Length.cpp index ea9c5362e8..c8ada1dd86 100644 --- a/Userland/Libraries/LibWeb/CSS/Length.cpp +++ b/Userland/Libraries/LibWeb/CSS/Length.cpp @@ -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; }