ladybird/Libraries/LibWeb/HTML/ShadowRealmGlobalScope.h
Andreas Kling 5b26777904 LibWeb: Don't WEB_SET_PROTOTYPE_FOR_INTERFACE for ShadowRealm global
We weren't doing this before either, but through a slightly sneaky
mechanism: we had overridden Cell::initialize() in
ShadowRealmGlobalScope as a no-op.

Instead of that, do the same thing Window and Worker globals do and
make all of the globals that inherit UniversalGlobalScopeMixin opt
out of WEB_SET_PROTOTYPE_FOR_INTERFACE in EventTarget::initialize().
2026-02-06 13:50:54 +01:00

54 lines
1.6 KiB
C++

/*
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/Bindings/ShadowRealmGlobalScopeGlobalMixin.h>
#include <LibWeb/DOM/EventTarget.h>
#include <LibWeb/HTML/UniversalGlobalScope.h>
namespace Web::HTML {
// https://whatpr.org/html/9893/webappapis.html#shadowrealmglobalscope
class ShadowRealmGlobalScope
: public DOM::EventTarget
, public UniversalGlobalScopeMixin
, public Bindings::ShadowRealmGlobalScopeGlobalMixin {
WEB_PLATFORM_OBJECT(ShadowRealmGlobalScope, DOM::EventTarget);
GC_DECLARE_ALLOCATOR(ShadowRealmGlobalScope);
public:
virtual ~ShadowRealmGlobalScope() override;
static GC::Ref<ShadowRealmGlobalScope> create(JS::Realm&);
virtual DOM::EventTarget& this_impl() override { return *this; }
virtual DOM::EventTarget const& this_impl() const override { return *this; }
// https://whatpr.org/html/9893/webappapis.html#dom-shadowrealmglobalscope-self
GC::Ref<ShadowRealmGlobalScope> self()
{
// The self getter steps are to return this.
return *this;
}
using UniversalGlobalScopeMixin::atob;
using UniversalGlobalScopeMixin::btoa;
using UniversalGlobalScopeMixin::queue_microtask;
using UniversalGlobalScopeMixin::structured_clone;
void initialize_web_interfaces();
protected:
explicit ShadowRealmGlobalScope(JS::Realm&);
virtual bool is_universal_global_scope_mixin() const final { return true; }
virtual void visit_edges(Cell::Visitor&) override;
};
}