Browse Source

LibWeb: Teach AK how to hash StorageKeys

Andrew Kaster 9 months ago
parent
commit
f4f70068a8
1 changed files with 11 additions and 0 deletions
  1. 11 0
      Userland/Libraries/LibWeb/StorageAPI/StorageKey.h

+ 11 - 0
Userland/Libraries/LibWeb/StorageAPI/StorageKey.h

@@ -7,6 +7,7 @@
 #pragma once
 #pragma once
 
 
 #include <AK/Optional.h>
 #include <AK/Optional.h>
+#include <AK/Traits.h>
 #include <LibURL/Origin.h>
 #include <LibURL/Origin.h>
 #include <LibWeb/Forward.h>
 #include <LibWeb/Forward.h>
 
 
@@ -32,3 +33,13 @@ Optional<StorageKey> obtain_a_storage_key(HTML::Environment const&);
 StorageKey obtain_a_storage_key_for_non_storage_purposes(HTML::Environment const&);
 StorageKey obtain_a_storage_key_for_non_storage_purposes(HTML::Environment const&);
 
 
 }
 }
+
+namespace AK {
+template<>
+struct Traits<Web::StorageAPI::StorageKey> : public DefaultTraits<Web::StorageAPI::StorageKey> {
+    static unsigned hash(Web::StorageAPI::StorageKey const& key)
+    {
+        return Traits<URL::Origin>::hash(key.origin);
+    }
+};
+}