mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
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:
committed by
Jelle Raaijmakers
parent
0e8956ee30
commit
0ab06e119e
Notes:
github-actions[bot]
2026-03-26 11:31:28 +00:00
Author: https://github.com/Calme1709 Commit: https://github.com/LadybirdBrowser/ladybird/commit/0ab06e119e8 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8609 Reviewed-by: https://github.com/gmta ✅
@@ -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(", ");
|
||||
|
||||
Reference in New Issue
Block a user