From dbc04bbf1ba6c5c2a00459262423dccdadcab403 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Fri, 20 Jan 2023 15:23:17 -0500 Subject: [PATCH] LibWeb: Use type-correct hashing and formatting functions for pixels 1. Don't use double_hash. This is not for doubles, as its name implies. 2. Specialize traits and formatters using the underlying DistinctNumeric type of Web::DevicePixels and Web::CSSPixels. --- Userland/Libraries/LibWeb/PixelUnits.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibWeb/PixelUnits.h b/Userland/Libraries/LibWeb/PixelUnits.h index 0e99009c76..ac40f9a947 100644 --- a/Userland/Libraries/LibWeb/PixelUnits.h +++ b/Userland/Libraries/LibWeb/PixelUnits.h @@ -127,7 +127,7 @@ template<> struct Traits : public GenericTraits { static unsigned hash(Web::CSSPixels const& key) { - return double_hash(key.value()); + return Traits::hash(key.value()); } static bool equals(Web::CSSPixels const& a, Web::CSSPixels const& b) @@ -140,7 +140,7 @@ template<> struct Traits : public GenericTraits { static unsigned hash(Web::DevicePixels const& key) { - return double_hash(key.value()); + return Traits::hash(key.value()); } static bool equals(Web::DevicePixels const& a, Web::DevicePixels const& b) @@ -150,18 +150,18 @@ struct Traits : public GenericTraits { }; template<> -struct Formatter : Formatter { +struct Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Web::CSSPixels const& value) { - return Formatter::format(builder, value.value()); + return Formatter::format(builder, value.value()); } }; template<> -struct Formatter : Formatter { +struct Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Web::DevicePixels const& value) { - return Formatter::format(builder, value.value()); + return Formatter::format(builder, value.value()); } };