ladybird/Userland/Libraries/LibWeb/HTML/CrossOrigin/CrossOriginPropertyDescriptorMap.h
Shannon Booth b2f3ed8b5a LibWeb: Rename current settings object to 'current principal'
Aligning the name with the the PR implementing the javascript
shadow realm proposal into the web platform. This commit
simply performs the rename before implementing the behaviour
change.

The actual change to the behaviour of the AO is not implemented in this
commit to support 'synthetic' shadow realms as the surrounding
infrastructure is not in place yet.

Not all specs have a MR open to align with this proposed change to the
HTML standard. But in this case we can just apply the same mechanical
change everywhere.
2024-11-01 12:15:17 -07:00

53 lines
1.4 KiB
C++

/*
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Forward.h>
#include <AK/Optional.h>
#include <AK/String.h>
#include <AK/Traits.h>
#include <LibJS/Forward.h>
#include <LibJS/Runtime/PropertyKey.h>
namespace Web::HTML {
struct CrossOriginProperty {
String property;
Optional<bool> needs_get {};
Optional<bool> needs_set {};
};
struct CrossOriginKey {
FlatPtr current_principal_settings_object;
FlatPtr relevant_settings_object;
JS::PropertyKey property_key;
};
using CrossOriginPropertyDescriptorMap = HashMap<CrossOriginKey, JS::PropertyDescriptor>;
}
namespace AK {
template<>
struct Traits<Web::HTML::CrossOriginKey> : public DefaultTraits<Web::HTML::CrossOriginKey> {
static unsigned hash(Web::HTML::CrossOriginKey const& key)
{
return pair_int_hash(
Traits<JS::PropertyKey>::hash(key.property_key),
pair_int_hash(ptr_hash(key.current_principal_settings_object), ptr_hash(key.relevant_settings_object)));
}
static bool equals(Web::HTML::CrossOriginKey const& a, Web::HTML::CrossOriginKey const& b)
{
return a.current_principal_settings_object == b.current_principal_settings_object
&& a.relevant_settings_object == b.relevant_settings_object
&& Traits<JS::PropertyKey>::equals(a.property_key, b.property_key);
}
};
}