1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:17:34 +00:00

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.
This commit is contained in:
Aliaksandr Kalenik 2023-08-17 17:11:04 +02:00 committed by Andreas Kling
parent c40e441894
commit f2a15ecea7
2 changed files with 5 additions and 5 deletions

View file

@ -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;