1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:07:44 +00:00

LibWeb: Remove StyleValue::has/to_integer()

Only NumericStyleValue holds integers.

I'm not sure our current distinction between NumericStyleValue holding
an integer or non-integer is useful given it always returns a float.
:thonk:
This commit is contained in:
Sam Atkins 2023-05-26 17:43:20 +01:00 committed by Andreas Kling
parent 4ecf0b7768
commit 5cbf6eb930
5 changed files with 9 additions and 11 deletions

View file

@ -226,10 +226,10 @@ Optional<int> StyleProperties::z_index() const
auto value = property(CSS::PropertyID::ZIndex);
if (value->has_auto())
return {};
if (value->has_integer()) {
if (value->is_numeric() && value->as_numeric().has_integer()) {
// Clamp z-index to the range of a signed 32-bit integer for consistency with other engines.
// NOTE: Casting between 32-bit float and 32-bit integer is finicky here, since INT32_MAX is not representable as a 32-bit float!
auto integer = value->to_integer();
auto integer = value->as_numeric().integer();
if (integer >= static_cast<float>(NumericLimits<int>::max()))
return NumericLimits<int>::max();
if (integer <= static_cast<float>(NumericLimits<int>::min()))
@ -344,9 +344,9 @@ float StyleProperties::flex_shrink() const
int StyleProperties::order() const
{
auto value = property(CSS::PropertyID::Order);
if (!value->has_integer())
if (!value->is_numeric() || !value->as_numeric().has_integer())
return 0;
return value->to_integer();
return value->as_numeric().integer();
}
Optional<CSS::ImageRendering> StyleProperties::image_rendering() const