From f2a15ecea7494e0f741b197e99904dd4f9457fca Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Thu, 17 Aug 2023 17:11:04 +0200 Subject: [PATCH] LibWeb/Layout: Replace `isfinite()` with `might_be_saturated()` Since we switched to using fixed-point math for CSSPixels, it cannot represent infinite values, so we need to check if the value is saturated instead. --- Userland/Libraries/LibWeb/Layout/AvailableSpace.cpp | 2 +- Userland/Libraries/LibWeb/Layout/FormattingContext.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibWeb/Layout/AvailableSpace.cpp b/Userland/Libraries/LibWeb/Layout/AvailableSpace.cpp index 189ac7e3a0..ee5fbfb0b0 100644 --- a/Userland/Libraries/LibWeb/Layout/AvailableSpace.cpp +++ b/Userland/Libraries/LibWeb/Layout/AvailableSpace.cpp @@ -11,7 +11,7 @@ namespace Web::Layout { AvailableSize AvailableSize::make_definite(CSSPixels value) { - VERIFY(isfinite(value.to_double())); + VERIFY(!value.might_be_saturated()); return AvailableSize { Type::Definite, value }; } diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp index 3d5381223e..baf050ef4a 100644 --- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -1307,7 +1307,7 @@ CSSPixels FormattingContext::calculate_min_content_width(Layout::Box const& box) cache.min_content_width = context->automatic_content_width(); - if (!isfinite(cache.min_content_width->to_double())) { + if (cache.min_content_width->might_be_saturated()) { // HACK: If layout calculates a non-finite result, something went wrong. Force it to zero and log a little whine. dbgln("FIXME: Calculated non-finite min-content width for {}", box.debug_description()); cache.min_content_width = 0; @@ -1345,7 +1345,7 @@ CSSPixels FormattingContext::calculate_max_content_width(Layout::Box const& box) cache.max_content_width = context->automatic_content_width(); - if (!isfinite(cache.max_content_width->to_double())) { + if (cache.max_content_width->might_be_saturated()) { // HACK: If layout calculates a non-finite result, something went wrong. Force it to zero and log a little whine. dbgln("FIXME: Calculated non-finite max-content width for {}", box.debug_description()); cache.max_content_width = 0; @@ -1388,7 +1388,7 @@ CSSPixels FormattingContext::calculate_min_content_height(Layout::Box const& box context->run(box, LayoutMode::IntrinsicSizing, AvailableSpace(AvailableSize::make_definite(width), AvailableSize::make_min_content())); auto min_content_height = context->automatic_content_height(); - if (!isfinite(min_content_height.to_double())) { + if (min_content_height.might_be_saturated()) { // HACK: If layout calculates a non-finite result, something went wrong. Force it to zero and log a little whine. dbgln("FIXME: Calculated non-finite min-content height for {}", box.debug_description()); min_content_height = 0; @@ -1433,7 +1433,7 @@ CSSPixels FormattingContext::calculate_max_content_height(Layout::Box const& box auto max_content_height = context->automatic_content_height(); - if (!isfinite(max_content_height.to_double())) { + if (max_content_height.might_be_saturated()) { // HACK: If layout calculates a non-finite result, something went wrong. Force it to zero and log a little whine. dbgln("FIXME: Calculated non-finite max-content height for {}", box.debug_description()); max_content_height = 0;