summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-09-07 13:25:17 +0200
committerAndreas Kling <kling@serenityos.org>2022-09-07 17:47:33 +0200
commita42506c8b918ea92d4d91a66dc61aaf14ddd49e6 (patch)
tree21e3351c7364eeaf6e78af21b1f7e8dcdb1d68f7
parent21a89b65fc4198e9f6de00cf07d24485bb6623d6 (diff)
downloadserenity-a42506c8b918ea92d4d91a66dc61aaf14ddd49e6.zip
LibWeb: Fix three accidental float truncations
We were doing this: max(0, some_floating_point_value) This returns an `int` result based on the type of `0`, oops!
-rw-r--r--Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp2
-rw-r--r--Userland/Libraries/LibWeb/Layout/FormattingContext.cpp4
2 files changed, 3 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
index 74ce95d209..8b68e5efd3 100644
--- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
@@ -738,7 +738,7 @@ void FlexFormattingContext::determine_flex_base_size_and_hypothetical_main_size(
// The hypothetical main size is the itemโ€™s flex base size clamped according to its used min and max main sizes (and flooring the content box size at zero).
auto clamp_min = has_main_min_size(child_box) ? specified_main_min_size(child_box) : automatic_minimum_size(flex_item);
auto clamp_max = has_main_max_size(child_box) ? specified_main_max_size(child_box) : NumericLimits<float>::max();
- flex_item.hypothetical_main_size = max(0, css_clamp(flex_item.flex_base_size, clamp_min, clamp_max));
+ flex_item.hypothetical_main_size = max(0.0f, css_clamp(flex_item.flex_base_size, clamp_min, clamp_max));
}
// https://drafts.csswg.org/css-flexbox-1/#min-size-auto
diff --git a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
index e0932e97ca..2a08e9f126 100644
--- a/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FormattingContext.cpp
@@ -286,7 +286,7 @@ float FormattingContext::compute_auto_height_for_block_level_element(LayoutState
continue;
// FIXME: Handle margin collapsing.
- return max(0, child_box_state.offset.y() + child_box_state.content_height() + child_box_state.margin_box_bottom());
+ return max(0.0f, child_box_state.offset.y() + child_box_state.content_height() + child_box_state.margin_box_bottom());
}
}
@@ -354,7 +354,7 @@ float FormattingContext::compute_auto_height_for_block_formatting_context_root(L
return IterationDecision::Continue;
});
- return max(0, bottom.value_or(0) - top.value_or(0));
+ return max(0.0f, bottom.value_or(0) - top.value_or(0));
}
// 10.3.2 Inline, replaced elements, https://www.w3.org/TR/CSS22/visudet.html#inline-replaced-width