Serenity Operating System
1/*
2 * Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#pragma once
8
9#include <AK/DeprecatedString.h>
10#include <AK/Forward.h>
11#include <AK/Optional.h>
12#include <AK/Traits.h>
13#include <LibJS/Forward.h>
14#include <LibJS/Runtime/PropertyKey.h>
15
16namespace Web::HTML {
17
18struct CrossOriginProperty {
19 DeprecatedString property;
20 Optional<bool> needs_get {};
21 Optional<bool> needs_set {};
22};
23
24struct CrossOriginKey {
25 FlatPtr current_settings_object;
26 FlatPtr relevant_settings_object;
27 JS::PropertyKey property_key;
28};
29
30using CrossOriginPropertyDescriptorMap = HashMap<CrossOriginKey, JS::PropertyDescriptor>;
31
32}
33
34namespace AK {
35
36template<>
37struct Traits<Web::HTML::CrossOriginKey> : public GenericTraits<Web::HTML::CrossOriginKey> {
38 static unsigned hash(Web::HTML::CrossOriginKey const& key)
39 {
40 return pair_int_hash(
41 Traits<JS::PropertyKey>::hash(key.property_key),
42 pair_int_hash(ptr_hash(key.current_settings_object), ptr_hash(key.relevant_settings_object)));
43 }
44
45 static bool equals(Web::HTML::CrossOriginKey const& a, Web::HTML::CrossOriginKey const& b)
46 {
47 return a.current_settings_object == b.current_settings_object
48 && a.relevant_settings_object == b.relevant_settings_object
49 && Traits<JS::PropertyKey>::equals(a.property_key, b.property_key);
50 }
51};
52
53}