Title: [290610] trunk
Revision
290610
Author
[email protected]
Date
2022-02-28 11:59:32 -0800 (Mon, 28 Feb 2022)

Log Message

Adopt the modern Hasher more widely
https://bugs.webkit.org/show_bug.cgi?id=237262

Reviewed by Sam Weinig.

Source/WebCore:

* dom/MessagePortIdentifier.h:
(WebCore::add):
(WTF::MessagePortIdentifierHash::hash):
(WebCore::MessagePortIdentifier::hash const): Deleted.
* history/BackForwardItemIdentifier.h:
(WebCore::add):
(WTF::BackForwardItemIdentifierHash::hash):
(WebCore::BackForwardItemIdentifier::hash const): Deleted.
* loader/ResourceCryptographicDigest.h:
(WebCore::add):
(WTF::DefaultHash<WebCore::ResourceCryptographicDigest>::hash):
* platform/graphics/Color.h:
(WebCore::add):
(WebCore::Color::hash const): Deleted.
* platform/graphics/ColorHash.h:
(WTF::ColorHash::hash):
* platform/graphics/Font.cpp:
(WebCore::add):
(WebCore::CharacterFallbackMapKeyHash::hash):
* platform/graphics/FontCache.cpp:
(WebCore::add):
(WebCore::FontPlatformDataCacheKeyHash::hash):
(WebCore::FontCascadeCacheKeyHash::hash): Deleted.
* platform/graphics/FontCache.h:
(WebCore::add):
(WebCore::FontCascadeCacheKeyHash::hash):
* platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp:
(WebCore::add):
(WebCore::FontFamilySpecificationKeyHash::hash):
* platform/graphics/cocoa/SystemFontDatabaseCoreText.h:
(WebCore::add):
(WebCore::SystemFontDatabaseCoreText::CascadeListParameters::Hash::hash):
(WebCore::SystemFontDatabaseCoreText::CascadeListParameters::hash const): Deleted.
* platform/graphics/freetype/FontCacheFreeType.cpp:
(WebCore::add):
(WebCore::FallbackFontDescriptionKeyHash::hash):

Source/WebKit:

* NetworkProcess/cache/NetworkCache.h:
(WebKit::NetworkCache::add):
(WTF::GlobalFrameIDHash::hash):
(WebKit::NetworkCache::GlobalFrameID::hash const): Deleted.
* Platform/IPC/StringReference.cpp:
(IPC::StringReference::Hash::hash):
* Platform/IPC/StringReference.h:
(IPC::add):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (290609 => 290610)


--- trunk/Source/WebCore/ChangeLog	2022-02-28 19:57:39 UTC (rev 290609)
+++ trunk/Source/WebCore/ChangeLog	2022-02-28 19:59:32 UTC (rev 290610)
@@ -1,3 +1,47 @@
+2022-02-28  Chris Dumez  <[email protected]>
+
+        Adopt the modern Hasher more widely
+        https://bugs.webkit.org/show_bug.cgi?id=237262
+
+        Reviewed by Sam Weinig.
+
+        * dom/MessagePortIdentifier.h:
+        (WebCore::add):
+        (WTF::MessagePortIdentifierHash::hash):
+        (WebCore::MessagePortIdentifier::hash const): Deleted.
+        * history/BackForwardItemIdentifier.h:
+        (WebCore::add):
+        (WTF::BackForwardItemIdentifierHash::hash):
+        (WebCore::BackForwardItemIdentifier::hash const): Deleted.
+        * loader/ResourceCryptographicDigest.h:
+        (WebCore::add):
+        (WTF::DefaultHash<WebCore::ResourceCryptographicDigest>::hash):
+        * platform/graphics/Color.h:
+        (WebCore::add):
+        (WebCore::Color::hash const): Deleted.
+        * platform/graphics/ColorHash.h:
+        (WTF::ColorHash::hash):
+        * platform/graphics/Font.cpp:
+        (WebCore::add):
+        (WebCore::CharacterFallbackMapKeyHash::hash):
+        * platform/graphics/FontCache.cpp:
+        (WebCore::add):
+        (WebCore::FontPlatformDataCacheKeyHash::hash):
+        (WebCore::FontCascadeCacheKeyHash::hash): Deleted.
+        * platform/graphics/FontCache.h:
+        (WebCore::add):
+        (WebCore::FontCascadeCacheKeyHash::hash):
+        * platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp:
+        (WebCore::add):
+        (WebCore::FontFamilySpecificationKeyHash::hash):
+        * platform/graphics/cocoa/SystemFontDatabaseCoreText.h:
+        (WebCore::add):
+        (WebCore::SystemFontDatabaseCoreText::CascadeListParameters::Hash::hash):
+        (WebCore::SystemFontDatabaseCoreText::CascadeListParameters::hash const): Deleted.
+        * platform/graphics/freetype/FontCacheFreeType.cpp:
+        (WebCore::add):
+        (WebCore::FallbackFontDescriptionKeyHash::hash):
+
 2022-02-28  Aditya Keerthi  <[email protected]>
 
         [macOS] Unable to upload ".pages" files to file inputs accepting ".pages" and ".jpeg" files

Modified: trunk/Source/WebCore/dom/MessagePortIdentifier.h (290609 => 290610)


--- trunk/Source/WebCore/dom/MessagePortIdentifier.h	2022-02-28 19:57:39 UTC (rev 290609)
+++ trunk/Source/WebCore/dom/MessagePortIdentifier.h	2022-02-28 19:59:32 UTC (rev 290610)
@@ -36,8 +36,6 @@
     enum PortIdentifierType { };
     ObjectIdentifier<PortIdentifierType> portIdentifier;
 
-    unsigned hash() const;
-
     template<class Encoder> void encode(Encoder&) const;
     template<class Decoder> static std::optional<MessagePortIdentifier> decode(Decoder&);
 
@@ -46,6 +44,11 @@
 #endif
 };
 
+inline void add(Hasher& hasher, const MessagePortIdentifier& identifier)
+{
+    add(hasher, identifier.processIdentifier, identifier.portIdentifier);
+}
+
 inline bool operator==(const MessagePortIdentifier& a, const MessagePortIdentifier& b)
 {
     return a.processIdentifier == b.processIdentifier &&  a.portIdentifier == b.portIdentifier;
@@ -73,11 +76,6 @@
     return { { WTFMove(*processIdentifier), WTFMove(*portIdentifier) } };
 }
 
-inline unsigned MessagePortIdentifier::hash() const
-{
-    return computeHash(processIdentifier.toUInt64(), portIdentifier.toUInt64());
-}
-
 #if !LOG_DISABLED
 
 inline String MessagePortIdentifier::logString() const
@@ -92,7 +90,7 @@
 namespace WTF {
 
 struct MessagePortIdentifierHash {
-    static unsigned hash(const WebCore::MessagePortIdentifier& key) { return key.hash(); }
+    static unsigned hash(const WebCore::MessagePortIdentifier& key) { return computeHash(key); }
     static bool equal(const WebCore::MessagePortIdentifier& a, const WebCore::MessagePortIdentifier& b) { return a == b; }
     static const bool safeToCompareToEmptyOrDeleted = true;
 };

Modified: trunk/Source/WebCore/history/BackForwardItemIdentifier.h (290609 => 290610)


--- trunk/Source/WebCore/history/BackForwardItemIdentifier.h	2022-02-28 19:57:39 UTC (rev 290609)
+++ trunk/Source/WebCore/history/BackForwardItemIdentifier.h	2022-02-28 19:59:32 UTC (rev 290610)
@@ -37,7 +37,6 @@
     enum ItemIdentifierType { };
     ObjectIdentifier<ItemIdentifierType> itemIdentifier;
 
-    unsigned hash() const;
     explicit operator bool() const { return processIdentifier && itemIdentifier; }
 
     template<class Encoder> void encode(Encoder&) const;
@@ -52,6 +51,11 @@
 #endif
 };
 
+inline void add(Hasher& hasher, const BackForwardItemIdentifier& identifier)
+{
+    add(hasher, identifier.processIdentifier, identifier.itemIdentifier);
+}
+
 #if !LOG_DISABLED
 
 inline const char* BackForwardItemIdentifier::logString() const
@@ -96,17 +100,12 @@
     return result;
 }
 
-inline unsigned BackForwardItemIdentifier::hash() const
-{
-    return computeHash(processIdentifier.toUInt64(), itemIdentifier.toUInt64());
-}
-
 } // namespace WebCore
 
 namespace WTF {
 
 struct BackForwardItemIdentifierHash {
-    static unsigned hash(const WebCore::BackForwardItemIdentifier& key) { return key.hash(); }
+    static unsigned hash(const WebCore::BackForwardItemIdentifier& key) { return computeHash(key); }
     static bool equal(const WebCore::BackForwardItemIdentifier& a, const WebCore::BackForwardItemIdentifier& b) { return a == b; }
     static const bool safeToCompareToEmptyOrDeleted = true;
 };

Modified: trunk/Source/WebCore/loader/ResourceCryptographicDigest.h (290609 => 290610)


--- trunk/Source/WebCore/loader/ResourceCryptographicDigest.h	2022-02-28 19:57:39 UTC (rev 290609)
+++ trunk/Source/WebCore/loader/ResourceCryptographicDigest.h	2022-02-28 19:59:32 UTC (rev 290610)
@@ -60,6 +60,11 @@
     }
 };
 
+inline void add(Hasher& hasher, const ResourceCryptographicDigest& digest)
+{
+    add(hasher, digest.algorithm, digest.value);
+}
+
 struct EncodedResourceCryptographicDigest {
     using Algorithm = ResourceCryptographicDigest::Algorithm;
     
@@ -85,7 +90,7 @@
 template<> struct DefaultHash<WebCore::ResourceCryptographicDigest> {
     static unsigned hash(const WebCore::ResourceCryptographicDigest& digest)
     {
-        return pairIntHash(intHash(static_cast<unsigned>(digest.algorithm)), StringHasher::computeHash(digest.value.data(), digest.value.size()));
+        return computeHash(digest);
     }
     static bool equal(const WebCore::ResourceCryptographicDigest& a, const WebCore::ResourceCryptographicDigest& b)
     {

Modified: trunk/Source/WebCore/platform/graphics/Color.h (290609 => 290610)


--- trunk/Source/WebCore/platform/graphics/Color.h	2022-02-28 19:57:39 UTC (rev 290609)
+++ trunk/Source/WebCore/platform/graphics/Color.h	2022-02-28 19:59:32 UTC (rev 290610)
@@ -84,8 +84,6 @@
 
     ~Color();
 
-    unsigned hash() const;
-
     bool isValid() const;
     bool isSemantic() const;
     bool usesColorFunctionSerialization() const;
@@ -180,6 +178,8 @@
     String debugDescription() const;
 
 private:
+    friend void add(Hasher&, const Color&);
+
     class OutOfLineComponents : public ThreadSafeRefCounted<OutOfLineComponents> {
     public:
         static Ref<OutOfLineComponents> create(ColorComponents<float, 4> components)
@@ -257,6 +257,14 @@
     uint64_t m_colorAndFlags { invalidColorAndFlags };
 };
 
+inline void add(Hasher& hasher, const Color& color)
+{
+    if (color.isOutOfLine())
+        add(hasher, color.asOutOfLine().unresolvedComponents(), color.colorSpace(), color.flags().toRaw());
+    else
+        add(hasher, color.asPackedInline().value, color.flags().toRaw());
+}
+
 bool operator==(const Color&, const Color&);
 bool operator!=(const Color&, const Color&);
 
@@ -365,13 +373,6 @@
         asOutOfLine().deref();
 }
 
-inline unsigned Color::hash() const
-{
-    if (isOutOfLine())
-        return computeHash(asOutOfLine().unresolvedComponents(), colorSpace(), flags().toRaw());
-    return computeHash(asPackedInline().value, flags().toRaw());
-}
-
 inline bool Color::isValid() const
 {
     return flags().contains(FlagsIncludingPrivate::Valid);
@@ -627,12 +628,6 @@
     return Color { asSRGBA(PackedColor::RGBA { value }), flags };
 }
 
-inline void add(Hasher& hasher, const Color& color)
-{
-    // FIXME: We don't want to hash a hash; do better.
-    add(hasher, color.hash());
-}
-
 } // namespace WebCore
 
 namespace WTF {

Modified: trunk/Source/WebCore/platform/graphics/ColorHash.h (290609 => 290610)


--- trunk/Source/WebCore/platform/graphics/ColorHash.h	2022-02-28 19:57:39 UTC (rev 290609)
+++ trunk/Source/WebCore/platform/graphics/ColorHash.h	2022-02-28 19:59:32 UTC (rev 290610)
@@ -31,7 +31,7 @@
 namespace WTF {
 
 struct ColorHash {
-    static unsigned hash(const WebCore::Color& key) { return key.hash(); }
+    static unsigned hash(const WebCore::Color& key) { return computeHash(key); }
     static bool equal(const WebCore::Color& a, const WebCore::Color& b) { return a == b; }
     static const bool safeToCompareToEmptyOrDeleted = true;
 };

Modified: trunk/Source/WebCore/platform/graphics/Font.cpp (290609 => 290610)


--- trunk/Source/WebCore/platform/graphics/Font.cpp	2022-02-28 19:57:39 UTC (rev 290609)
+++ trunk/Source/WebCore/platform/graphics/Font.cpp	2022-02-28 19:59:32 UTC (rev 290610)
@@ -559,6 +559,11 @@
     bool isForPlatformFont { false };
 };
 
+inline void add(Hasher& hasher, const CharacterFallbackMapKey& key)
+{
+    add(hasher, key.locale, key.character, key.isForPlatformFont);
+}
+
 inline bool operator==(const CharacterFallbackMapKey& a, const CharacterFallbackMapKey& b)
 {
     return a.locale == b.locale && a.character == b.character && a.isForPlatformFont == b.isForPlatformFont;
@@ -565,7 +570,7 @@
 }
 
 struct CharacterFallbackMapKeyHash {
-    static unsigned hash(const CharacterFallbackMapKey& key) { return computeHash(key.locale, key.character, key.isForPlatformFont); }
+    static unsigned hash(const CharacterFallbackMapKey& key) { return computeHash(key); }
     static bool equal(const CharacterFallbackMapKey& a, const CharacterFallbackMapKey& b) { return a == b; }
     static const bool safeToCompareToEmptyOrDeleted = true;
 };

Modified: trunk/Source/WebCore/platform/graphics/FontCache.cpp (290609 => 290610)


--- trunk/Source/WebCore/platform/graphics/FontCache.cpp	2022-02-28 19:57:39 UTC (rev 290609)
+++ trunk/Source/WebCore/platform/graphics/FontCache.cpp	2022-02-28 19:59:32 UTC (rev 290610)
@@ -86,6 +86,11 @@
     FontCreationContext fontCreationContext;
 };
 
+inline void add(Hasher& hasher, const FontPlatformDataCacheKey& key)
+{
+    add(hasher, key.descriptionKey, key.family, key.fontCreationContext);
+}
+
 static bool operator==(const FontPlatformDataCacheKey& a, const FontPlatformDataCacheKey& b)
 {
     return a.descriptionKey == b.descriptionKey
@@ -94,7 +99,7 @@
 }
 
 struct FontPlatformDataCacheKeyHash {
-    static unsigned hash(const FontPlatformDataCacheKey& key) { return computeHash(key.descriptionKey, key.family, key.fontCreationContext); }
+    static unsigned hash(const FontPlatformDataCacheKey& key) { return computeHash(key); }
     static bool equal(const FontPlatformDataCacheKey& a, const FontPlatformDataCacheKey& b) { return a == b; }
     static constexpr bool safeToCompareToEmptyOrDeleted = true;
 };
@@ -362,11 +367,6 @@
         && a.families == b.families;
 }
 
-unsigned FontCascadeCacheKeyHash::hash(const FontCascadeCacheKey& key)
-{
-    return computeHash(key.fontDescriptionKey, key.fontSelectorId, key.fontSelectorVersion, key.families);
-}
-
 void FontCache::invalidateFontCascadeCache()
 {
     m_fontCascadeCache.clear();

Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (290609 => 290610)


--- trunk/Source/WebCore/platform/graphics/FontCache.h	2022-02-28 19:57:39 UTC (rev 290609)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h	2022-02-28 19:59:32 UTC (rev 290610)
@@ -257,6 +257,11 @@
     unsigned fontSelectorVersion;
 };
 
+inline void add(Hasher& hasher, const FontCascadeCacheKey& key)
+{
+    add(hasher, key.fontDescriptionKey, key.families, key.fontSelectorId, key.fontSelectorVersion);
+}
+
 bool operator==(const FontCascadeCacheKey&, const FontCascadeCacheKey&);
 
 struct FontCascadeCacheEntry {
@@ -267,7 +272,7 @@
 };
 
 struct FontCascadeCacheKeyHash {
-    static unsigned hash(const FontCascadeCacheKey&);
+    static unsigned hash(const FontCascadeCacheKey& key) { return computeHash(key); }
     static bool equal(const FontCascadeCacheKey& a, const FontCascadeCacheKey& b) { return a == b; }
     static constexpr bool safeToCompareToEmptyOrDeleted = false;
 };

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp (290609 => 290610)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp	2022-02-28 19:57:39 UTC (rev 290609)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontFamilySpecificationCoreText.cpp	2022-02-28 19:59:32 UTC (rev 290610)
@@ -64,8 +64,14 @@
     bool isHashTableDeletedValue() const { return fontDescriptionKey.isHashTableDeletedValue(); }
 };
 
+inline void add(Hasher& hasher, const FontFamilySpecificationKey& key)
+{
+    // FIXME: Ideally, we wouldn't be hashing a hash.
+    add(hasher, safeCFHash(key.fontDescriptor.get()), key.fontDescriptionKey);
+}
+
 struct FontFamilySpecificationKeyHash {
-    static unsigned hash(const FontFamilySpecificationKey& key) { return computeHash(safeCFHash(key.fontDescriptor.get()), key.fontDescriptionKey); }
+    static unsigned hash(const FontFamilySpecificationKey& key) { return computeHash(key); }
     static bool equal(const FontFamilySpecificationKey& a, const FontFamilySpecificationKey& b) { return a == b; }
     static const bool safeToCompareToEmptyOrDeleted = true;
 };

Modified: trunk/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.h (290609 => 290610)


--- trunk/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.h	2022-02-28 19:57:39 UTC (rev 290609)
+++ trunk/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.h	2022-02-28 19:59:32 UTC (rev 290610)
@@ -70,13 +70,8 @@
                 && italic == other.italic;
         }
 
-        unsigned hash() const
-        {
-            return computeHash(fontName, locale, weight, width, size, allowUserInstalledFonts, italic);
-        }
-
         struct Hash {
-            static unsigned hash(const CascadeListParameters& parameters) { return parameters.hash(); }
+            static unsigned hash(const CascadeListParameters&);
             static bool equal(const CascadeListParameters& a, const CascadeListParameters& b) { return a == b; }
             static const bool safeToCompareToEmptyOrDeleted = true;
         };
@@ -125,4 +120,14 @@
     HashMap<String, String> m_monospaceFamilies;
 };
 
+inline void add(Hasher& hasher, const SystemFontDatabaseCoreText::CascadeListParameters& parameters)
+{
+    add(hasher, parameters.fontName, parameters.locale, parameters.weight, parameters.width, parameters.size, parameters.allowUserInstalledFonts, parameters.italic);
 }
+
+inline unsigned SystemFontDatabaseCoreText::CascadeListParameters::Hash::hash(const CascadeListParameters& parameters)
+{
+    return computeHash(parameters);
+}
+
+} // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp (290609 => 290610)


--- trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp	2022-02-28 19:57:39 UTC (rev 290609)
+++ trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp	2022-02-28 19:59:32 UTC (rev 290610)
@@ -225,8 +225,13 @@
 
 };
 
+inline void add(Hasher& hasher, const FallbackFontDescriptionKey& key)
+{
+    add(hasher, key.descriptionKey, key.coloredFont);
+}
+
 struct FallbackFontDescriptionKeyHash {
-    static unsigned hash(const FallbackFontDescriptionKey& key) { return computeHash(key.descriptionKey, key.coloredFont); }
+    static unsigned hash(const FallbackFontDescriptionKey& key) { return computeHash(key); }
     static bool equal(const FallbackFontDescriptionKey& a, const FallbackFontDescriptionKey& b) { return a == b; }
     static const bool safeToCompareToEmptyOrDeleted = true;
 };

Modified: trunk/Source/WebKit/ChangeLog (290609 => 290610)


--- trunk/Source/WebKit/ChangeLog	2022-02-28 19:57:39 UTC (rev 290609)
+++ trunk/Source/WebKit/ChangeLog	2022-02-28 19:59:32 UTC (rev 290610)
@@ -1,3 +1,19 @@
+2022-02-28  Chris Dumez  <[email protected]>
+
+        Adopt the modern Hasher more widely
+        https://bugs.webkit.org/show_bug.cgi?id=237262
+
+        Reviewed by Sam Weinig.
+
+        * NetworkProcess/cache/NetworkCache.h:
+        (WebKit::NetworkCache::add):
+        (WTF::GlobalFrameIDHash::hash):
+        (WebKit::NetworkCache::GlobalFrameID::hash const): Deleted.
+        * Platform/IPC/StringReference.cpp:
+        (IPC::StringReference::Hash::hash):
+        * Platform/IPC/StringReference.h:
+        (IPC::add):
+
 2022-02-28  Alex Christensen  <[email protected]>
 
         Fix typo in adattributiond sandbox

Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.h (290609 => 290610)


--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.h	2022-02-28 19:57:39 UTC (rev 290609)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.h	2022-02-28 19:59:32 UTC (rev 290610)
@@ -35,6 +35,7 @@
 #include <WebCore/ResourceResponse.h>
 #include <pal/SessionID.h>
 #include <wtf/CompletionHandler.h>
+#include <wtf/Hasher.h>
 #include <wtf/OptionSet.h>
 #include <wtf/Seconds.h>
 #include <wtf/WeakHashSet.h>
@@ -53,13 +54,11 @@
     WebPageProxyIdentifier webPageProxyID;
     WebCore::PageIdentifier webPageID;
     WebCore::FrameIdentifier frameID;
-
-    unsigned hash() const;
 };
 
-inline unsigned GlobalFrameID::hash() const
+inline void add(Hasher& hasher, const GlobalFrameID& identifier)
 {
-    return computeHash(webPageID, frameID);
+    add(hasher, identifier.webPageID, identifier.frameID);
 }
 
 inline bool operator==(const GlobalFrameID& a, const GlobalFrameID& b)
@@ -75,7 +74,7 @@
 namespace WTF {
 
 struct GlobalFrameIDHash {
-    static unsigned hash(const WebKit::NetworkCache::GlobalFrameID& key) { return key.hash(); }
+    static unsigned hash(const WebKit::NetworkCache::GlobalFrameID& key) { return computeHash(key); }
     static bool equal(const WebKit::NetworkCache::GlobalFrameID& a, const WebKit::NetworkCache::GlobalFrameID& b) { return a == b; }
     static const bool safeToCompareToEmptyOrDeleted = true;
 };

Modified: trunk/Source/WebKit/Platform/IPC/StringReference.cpp (290609 => 290610)


--- trunk/Source/WebKit/Platform/IPC/StringReference.cpp	2022-02-28 19:57:39 UTC (rev 290609)
+++ trunk/Source/WebKit/Platform/IPC/StringReference.cpp	2022-02-28 19:59:32 UTC (rev 290610)
@@ -57,9 +57,9 @@
     return true;
 }
 
-unsigned StringReference::Hash::hash(const StringReference& a)
+unsigned StringReference::Hash::hash(const StringReference& string)
 {
-    return StringHasher::computeHash(reinterpret_cast<const unsigned char*>(a.data()), a.size());
+    return computeHash(string);
 }
 
 } // namespace IPC

Modified: trunk/Source/WebKit/Platform/IPC/StringReference.h (290609 => 290610)


--- trunk/Source/WebKit/Platform/IPC/StringReference.h	2022-02-28 19:57:39 UTC (rev 290609)
+++ trunk/Source/WebKit/Platform/IPC/StringReference.h	2022-02-28 19:59:32 UTC (rev 290610)
@@ -29,6 +29,7 @@
 #include <string.h>
 #include <wtf/Forward.h>
 #include <wtf/HashTraits.h>
+#include <wtf/Hasher.h>
 
 namespace IPC {
 
@@ -79,6 +80,11 @@
     size_t m_size;
 };
 
+inline void add(Hasher& hasher, const StringReference& string)
+{
+    add(hasher, Span { string.data(), string.size() });
+}
+
 inline bool operator==(const StringReference& a, const StringReference& b)
 {
     return a.size() == b.size() && !memcmp(a.data(), b.data(), a.size());

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/ColorTests.cpp (290609 => 290610)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/ColorTests.cpp	2022-02-28 19:57:39 UTC (rev 290609)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/ColorTests.cpp	2022-02-28 19:59:32 UTC (rev 290610)
@@ -31,6 +31,7 @@
 #include <WebCore/ColorConversion.h>
 #include <WebCore/ColorSerialization.h>
 #include <WebCore/ColorTypes.h>
+#include <wtf/Hasher.h>
 #include <wtf/MathExtras.h>
 
 using namespace WebCore;
@@ -299,19 +300,19 @@
     {
         Color c1 { DisplayP3<float> { 1.0, 0.5, 0.25, 1.0 } };
         Color c2 { DisplayP3<float> { 1.0, 0.5, 0.25, 1.0 } };
-        EXPECT_EQ(c1.hash(), c2.hash());
+        EXPECT_EQ(computeHash(c1), computeHash(c2));
     }
 
     {
         Color c1 { DisplayP3<float> { 1.0, 0.5, 0.25, 1.0 } };
         Color c2 { SRGBA<float> { 1.0, 0.5, 0.25, 1.0 } };
-        EXPECT_NE(c1.hash(), c2.hash());
+        EXPECT_NE(computeHash(c1), computeHash(c2));
     }
 
     auto componentBytes = SRGBA<uint8_t> { 255, 128, 63, 127 };
     Color rgb1 { convertColor<SRGBA<float>>(componentBytes) };
     Color rgb2 { componentBytes };
-    EXPECT_NE(rgb1.hash(), rgb2.hash());
+    EXPECT_NE(computeHash(rgb1), computeHash(rgb2));
 }
 
 TEST(Color, MoveConstructor)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to