mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-05 07:39:16 +00:00
LibWeb: Correctly round non-integer z-indexes
Previously we would just cast to an int. Gains us 3 WPT tests.
This commit is contained in:
parent
9a5b740da1
commit
15cee5cc15
Notes:
github-actions[bot]
2025-08-05 05:39:02 +00:00
Author: https://github.com/Calme1709
Commit: 15cee5cc15
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5713
Reviewed-by: https://github.com/tcl3 ✅
3 changed files with 73 additions and 2 deletions
|
@ -338,7 +338,7 @@ Optional<int> ComputedProperties::z_index() const
|
|||
return {};
|
||||
|
||||
// Clamp z-index to the range of a signed 32-bit integer for consistency with other engines.
|
||||
auto clamp = [](auto number) -> int {
|
||||
auto clamp = [](long number) -> int {
|
||||
if (number >= NumericLimits<int>::max())
|
||||
return NumericLimits<int>::max();
|
||||
if (number <= NumericLimits<int>::min())
|
||||
|
@ -352,7 +352,8 @@ Optional<int> ComputedProperties::z_index() const
|
|||
if (value.is_calculated()) {
|
||||
auto maybe_double = value.as_calculated().resolve_number_deprecated({});
|
||||
if (maybe_double.has_value()) {
|
||||
return clamp(maybe_double.value());
|
||||
// Round up on half
|
||||
return clamp(floor(maybe_double.value() + 0.5f));
|
||||
}
|
||||
}
|
||||
return {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue