summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS/Length.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-07-06 13:05:31 +0200
committerAndreas Kling <kling@serenityos.org>2022-07-06 20:31:19 +0200
commite7370443f2d40505086c1c9d5cd1e8c12a739b06 (patch)
tree93ced8971af0ea5175d12cda91c2ea0bbc4522cb /Userland/Libraries/LibWeb/CSS/Length.cpp
parentb3deec061e8ebe5cbf9ef36333c88461e5c02cbc (diff)
downloadserenity-e7370443f2d40505086c1c9d5cd1e8c12a739b06.zip
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.
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS/Length.cpp')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Length.cpp2
1 files changed, 2 insertions, 0 deletions
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;
}