summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Origin.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-02-08 19:39:47 +0100
committerAndreas Kling <kling@serenityos.org>2022-02-08 21:53:20 +0100
commita856cf8d4c92b56b651e87df604f4d04a6e977dd (patch)
tree0faac2dbf10075488d727aaf3150ee2dc5562f31 /Userland/Libraries/LibWeb/Origin.h
parent5dceba29a47f5555a101ed1d30a585aac17f5551 (diff)
downloadserenity-a856cf8d4c92b56b651e87df604f4d04a6e977dd.zip
LibWeb: Allow using Origin as a HashMap key
Diffstat (limited to 'Userland/Libraries/LibWeb/Origin.h')
-rw-r--r--Userland/Libraries/LibWeb/Origin.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/Origin.h b/Userland/Libraries/LibWeb/Origin.h
index 3595e791a3..d224b0d734 100644
--- a/Userland/Libraries/LibWeb/Origin.h
+++ b/Userland/Libraries/LibWeb/Origin.h
@@ -33,6 +33,9 @@ public:
&& port() == other.port();
}
+ bool operator==(Origin const& other) const { return is_same(other); }
+ bool operator!=(Origin const& other) const { return !is_same(other); }
+
private:
String m_protocol;
String m_host;
@@ -40,3 +43,13 @@ private:
};
}
+
+namespace AK {
+template<>
+struct Traits<Web::Origin> : public GenericTraits<Web::Origin> {
+ static unsigned hash(Web::Origin const& origin)
+ {
+ return pair_int_hash(origin.protocol().hash(), pair_int_hash(int_hash(origin.port()), origin.host().hash()));
+ }
+};
+} // namespace AK