LibWeb: Use i32 max for clamping 'infinite' calculated integers

This required us to change our range values from `float`s to `double`s
since `float` can't exactly represent i32 max
This commit is contained in:
Callum Law
2026-03-25 16:43:51 +13:00
committed by Jelle Raaijmakers
parent 0e8956ee30
commit 0ab06e119e
Notes: github-actions[bot] 2026-03-26 11:31:28 +00:00
5 changed files with 38 additions and 8 deletions

View File

@@ -1024,9 +1024,16 @@ AcceptedTypeRangeMap property_accepted_type_ranges(PropertyID property_id)
if (limits.size() != 2)
VERIFY_NOT_REACHED();
// FIXME: Use min and max values for i32 instead of float where applicable (e.g. for "integer")
auto min = limits.get(0) == "-∞" ? "AK::NumericLimits<float>::lowest()"_string : *limits.get(0);
auto max = limits.get(1) == "" ? "AK::NumericLimits<float>::max()"_string : *limits.get(1);
String min;
String max;
if (type_name == "integer") {
min = limits.get(0) == "-∞" ? "AK::NumericLimits<i32>::min()"_string : *limits.get(0);
max = limits.get(1) == "" ? "AK::NumericLimits<i32>::max()"_string : *limits.get(1);
} else {
min = limits.get(0) == "-∞" ? "AK::NumericLimits<float>::lowest()"_string : *limits.get(0);
max = limits.get(1) == "" ? "AK::NumericLimits<float>::max()"_string : *limits.get(1);
}
if (!ranges_builder.is_empty())
ranges_builder.appendff(", ");