mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-21 15:40:28 +00:00
This allows us to align our implementation in the same order as the specification. No functional change with the current implementation of this AO. However, this change is required in order to correctly implement a proposed update of the shadow realm proposal for integration with the HTML spec host bindings in order to give the ShadowRealm object the correct 'intrinsic' realm. This is due to that proposed change adding a step which manipulates the currently executing Javascript execution context, making the ordering important.
46 lines
1.9 KiB
C++
46 lines
1.9 KiB
C++
/*
|
|
* Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibJS/Runtime/Completion.h>
|
|
#include <LibJS/Runtime/ExecutionContext.h>
|
|
#include <LibJS/Runtime/Object.h>
|
|
#include <LibJS/Runtime/Realm.h>
|
|
|
|
namespace JS {
|
|
|
|
class ShadowRealm final : public Object {
|
|
JS_OBJECT(ShadowRealm, Object);
|
|
JS_DECLARE_ALLOCATOR(ShadowRealm);
|
|
|
|
public:
|
|
virtual ~ShadowRealm() override = default;
|
|
|
|
[[nodiscard]] Realm const& shadow_realm() const { return *m_shadow_realm; }
|
|
[[nodiscard]] Realm& shadow_realm() { return *m_shadow_realm; }
|
|
void set_shadow_realm(NonnullGCPtr<Realm> realm) { m_shadow_realm = realm; }
|
|
|
|
[[nodiscard]] ExecutionContext const& execution_context() const { return *m_execution_context; }
|
|
[[nodiscard]] ExecutionContext& execution_context() { return *m_execution_context; }
|
|
void set_execution_context(NonnullOwnPtr<ExecutionContext> context) { m_execution_context = move(context); }
|
|
|
|
private:
|
|
ShadowRealm(Object& prototype);
|
|
|
|
virtual void visit_edges(Visitor&) override;
|
|
|
|
// 3.5 Properties of ShadowRealm Instances, https://tc39.es/proposal-shadowrealm/#sec-properties-of-shadowrealm-instances
|
|
GCPtr<Realm> m_shadow_realm; // [[ShadowRealm]]
|
|
OwnPtr<ExecutionContext> m_execution_context; // [[ExecutionContext]]
|
|
};
|
|
|
|
ThrowCompletionOr<void> copy_name_and_length(VM&, FunctionObject& function, FunctionObject& target, Optional<StringView> prefix = {}, Optional<unsigned> arg_count = {});
|
|
ThrowCompletionOr<Value> perform_shadow_realm_eval(VM&, StringView source_text, Realm& caller_realm, Realm& eval_realm);
|
|
ThrowCompletionOr<Value> shadow_realm_import_value(VM&, ByteString specifier_string, ByteString export_name_string, Realm& caller_realm, Realm& eval_realm, ExecutionContext& eval_context);
|
|
ThrowCompletionOr<Value> get_wrapped_value(VM&, Realm& caller_realm, Value);
|
|
|
|
}
|