mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:57:44 +00:00
LibWeb: Implement the [[CrossOriginPropertyDescriptorMap]] internal slot
This commit is contained in:
parent
11d0e37d8e
commit
8b4e5220aa
3 changed files with 59 additions and 0 deletions
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/Traits.h>
|
||||
#include <LibJS/Forward.h>
|
||||
|
||||
namespace Web::Bindings {
|
||||
|
||||
struct CrossOriginKey {
|
||||
FlatPtr current_settings_object;
|
||||
FlatPtr relevant_settings_object;
|
||||
JS::PropertyKey property_key;
|
||||
};
|
||||
|
||||
using CrossOriginPropertyDescriptorMap = HashMap<CrossOriginKey, JS::PropertyDescriptor>;
|
||||
|
||||
}
|
||||
|
||||
namespace AK {
|
||||
|
||||
template<>
|
||||
struct Traits<Web::Bindings::CrossOriginKey> : public GenericTraits<Web::Bindings::CrossOriginKey> {
|
||||
static unsigned hash(Web::Bindings::CrossOriginKey const& key)
|
||||
{
|
||||
return pair_int_hash(
|
||||
Traits<JS::PropertyKey>::hash(key.property_key),
|
||||
pair_int_hash(ptr_hash(key.current_settings_object), ptr_hash(key.relevant_settings_object)));
|
||||
}
|
||||
|
||||
static bool equals(Web::Bindings::CrossOriginKey const& a, Web::Bindings::CrossOriginKey const& b)
|
||||
{
|
||||
return a.current_settings_object == b.current_settings_object
|
||||
&& a.relevant_settings_object == b.relevant_settings_object
|
||||
&& Traits<JS::PropertyKey>::equals(a.property_key, b.property_key);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
|
@ -10,6 +10,7 @@
|
|||
#include <AK/URL.h>
|
||||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
#include <LibWeb/Bindings/CrossOriginAbstractOperations.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web {
|
||||
|
@ -30,6 +31,9 @@ public:
|
|||
// FIXME: There should also be a custom [[GetPrototypeOf]], [[GetOwnProperty]], [[DefineOwnProperty]], [[Get]], [[Set]], [[Delete]] and [[OwnPropertyKeys]],
|
||||
// but we don't have the infrastructure in place to implement them yet.
|
||||
|
||||
CrossOriginPropertyDescriptorMap const& cross_origin_property_descriptor_map() const { return m_cross_origin_property_descriptor_map; }
|
||||
CrossOriginPropertyDescriptorMap& cross_origin_property_descriptor_map() { return m_cross_origin_property_descriptor_map; }
|
||||
|
||||
private:
|
||||
DOM::Document const* relevant_document() const;
|
||||
AK::URL url() const;
|
||||
|
@ -47,6 +51,9 @@ private:
|
|||
JS_DECLARE_NATIVE_FUNCTION(search_getter);
|
||||
JS_DECLARE_NATIVE_FUNCTION(protocol_getter);
|
||||
JS_DECLARE_NATIVE_FUNCTION(port_getter);
|
||||
|
||||
// [[CrossOriginPropertyDescriptorMap]], https://html.spec.whatwg.org/multipage/browsers.html#crossoriginpropertydescriptormap
|
||||
CrossOriginPropertyDescriptorMap m_cross_origin_property_descriptor_map;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Copyright (c) 2020-2022, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2021, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -13,6 +14,7 @@
|
|||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
#include <LibWeb/Bindings/CallbackType.h>
|
||||
#include <LibWeb/Bindings/CrossOriginAbstractOperations.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/HTML/GlobalEventHandlers.h>
|
||||
|
||||
|
@ -68,6 +70,9 @@ public:
|
|||
|
||||
virtual JS::ThrowCompletionOr<bool> internal_set_prototype_of(JS::Object* prototype) override;
|
||||
|
||||
CrossOriginPropertyDescriptorMap const& cross_origin_property_descriptor_map() const { return m_cross_origin_property_descriptor_map; }
|
||||
CrossOriginPropertyDescriptorMap& cross_origin_property_descriptor_map() { return m_cross_origin_property_descriptor_map; }
|
||||
|
||||
private:
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
|
@ -136,6 +141,9 @@ private:
|
|||
|
||||
HashMap<String, JS::Object*> m_prototypes;
|
||||
HashMap<String, JS::NativeFunction*> m_constructors;
|
||||
|
||||
// [[CrossOriginPropertyDescriptorMap]], https://html.spec.whatwg.org/multipage/browsers.html#crossoriginpropertydescriptormap
|
||||
CrossOriginPropertyDescriptorMap m_cross_origin_property_descriptor_map;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue