summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2023-01-20 15:23:17 -0500
committerJelle Raaijmakers <jelle@gmta.nl>2023-01-21 10:36:14 +0100
commitdbc04bbf1ba6c5c2a00459262423dccdadcab403 (patch)
treeaa963f4be2fa009d62f7470d7fc91df991668303 /Userland/Libraries/LibWeb
parent60b56892cadd01605b55c390aa55dc7d15d11fe2 (diff)
downloadserenity-dbc04bbf1ba6c5c2a00459262423dccdadcab403.zip
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.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/PixelUnits.h12
1 files 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<Web::CSSPixels> : public GenericTraits<Web::CSSPixels> {
static unsigned hash(Web::CSSPixels const& key)
{
- return double_hash(key.value());
+ return Traits<Web::CSSPixels::Type>::hash(key.value());
}
static bool equals(Web::CSSPixels const& a, Web::CSSPixels const& b)
@@ -140,7 +140,7 @@ template<>
struct Traits<Web::DevicePixels> : public GenericTraits<Web::DevicePixels> {
static unsigned hash(Web::DevicePixels const& key)
{
- return double_hash(key.value());
+ return Traits<Web::DevicePixels::Type>::hash(key.value());
}
static bool equals(Web::DevicePixels const& a, Web::DevicePixels const& b)
@@ -150,18 +150,18 @@ struct Traits<Web::DevicePixels> : public GenericTraits<Web::DevicePixels> {
};
template<>
-struct Formatter<Web::CSSPixels> : Formatter<float> {
+struct Formatter<Web::CSSPixels> : Formatter<Web::CSSPixels::Type> {
ErrorOr<void> format(FormatBuilder& builder, Web::CSSPixels const& value)
{
- return Formatter<float>::format(builder, value.value());
+ return Formatter<Web::CSSPixels::Type>::format(builder, value.value());
}
};
template<>
-struct Formatter<Web::DevicePixels> : Formatter<float> {
+struct Formatter<Web::DevicePixels> : Formatter<Web::DevicePixels::Type> {
ErrorOr<void> format(FormatBuilder& builder, Web::DevicePixels const& value)
{
- return Formatter<float>::format(builder, value.value());
+ return Formatter<Web::DevicePixels::Type>::format(builder, value.value());
}
};