mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 00:50:22 +00:00
LibWeb: Introduce the 'ShadowRealmGlobalScope' interface
This object represents the global object for a shadow realm. The IDL generator will need to be adjusted to the '[Global]' extended attribute and no '[Exposed]' field (the change in the test is not correct, as I understand it), but this should be enough to get us started on shadow realms.
This commit is contained in:
parent
b105c06824
commit
c69a9812c8
Notes:
github-actions[bot]
2024-11-05 17:59:48 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/c69a9812c8c Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1993 Reviewed-by: https://github.com/ADKaster ✅
6 changed files with 85 additions and 0 deletions
|
@ -338,6 +338,7 @@ ServiceWorkerContainer
|
|||
ServiceWorkerRegistration
|
||||
Set
|
||||
ShadowRealm
|
||||
ShadowRealmGlobalScope
|
||||
ShadowRoot
|
||||
SharedArrayBuffer
|
||||
SourceBuffer
|
||||
|
|
|
@ -462,6 +462,7 @@ set(SOURCES
|
|||
HTML/ServiceWorkerRegistration.cpp
|
||||
HTML/SessionHistoryEntry.cpp
|
||||
HTML/SessionHistoryTraversalQueue.cpp
|
||||
HTML/ShadowRealmGlobalScope.cpp
|
||||
HTML/SharedResourceRequest.cpp
|
||||
HTML/SourceSet.cpp
|
||||
HTML/Storage.cpp
|
||||
|
|
38
Userland/Libraries/LibWeb/HTML/ShadowRealmGlobalScope.cpp
Normal file
38
Userland/Libraries/LibWeb/HTML/ShadowRealmGlobalScope.cpp
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/ShadowRealmGlobalScopePrototype.h>
|
||||
#include <LibWeb/HTML/ShadowRealmGlobalScope.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(ShadowRealmGlobalScope);
|
||||
|
||||
ShadowRealmGlobalScope::ShadowRealmGlobalScope(JS::Realm& realm)
|
||||
: DOM::EventTarget(realm)
|
||||
{
|
||||
}
|
||||
|
||||
ShadowRealmGlobalScope::~ShadowRealmGlobalScope() = default;
|
||||
|
||||
JS::NonnullGCPtr<ShadowRealmGlobalScope> ShadowRealmGlobalScope::create(JS::Realm& realm)
|
||||
{
|
||||
return realm.heap().allocate<ShadowRealmGlobalScope>(realm, realm);
|
||||
}
|
||||
|
||||
void ShadowRealmGlobalScope::initialize(JS::Realm&)
|
||||
{
|
||||
// FIXME: This does not work as we do not have any intrinsics in the [HostDefined] of a shadow realm. Figure out how this _should_ work.
|
||||
// Base::initialize(realm);
|
||||
// WEB_SET_PROTOTYPE_FOR_INTERFACE(ShadowRealmGlobalScope);
|
||||
}
|
||||
|
||||
void ShadowRealmGlobalScope::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
}
|
||||
|
||||
}
|
38
Userland/Libraries/LibWeb/HTML/ShadowRealmGlobalScope.h
Normal file
38
Userland/Libraries/LibWeb/HTML/ShadowRealmGlobalScope.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/DOM/EventTarget.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
// https://whatpr.org/html/9893/webappapis.html#shadowrealmglobalscope
|
||||
class ShadowRealmGlobalScope : public DOM::EventTarget {
|
||||
WEB_PLATFORM_OBJECT(ShadowRealmGlobalScope, DOM::EventTarget);
|
||||
JS_DECLARE_ALLOCATOR(ShadowRealmGlobalScope);
|
||||
|
||||
public:
|
||||
virtual ~ShadowRealmGlobalScope() override;
|
||||
|
||||
static JS::NonnullGCPtr<ShadowRealmGlobalScope> create(JS::Realm&);
|
||||
|
||||
// https://whatpr.org/html/9893/webappapis.html#dom-shadowrealmglobalscope-self
|
||||
JS::NonnullGCPtr<ShadowRealmGlobalScope> self()
|
||||
{
|
||||
// The self getter steps are to return this.
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
explicit ShadowRealmGlobalScope(JS::Realm&);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
};
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
// https://whatpr.org/html/9893/webappapis.html#shadowrealmglobalscope
|
||||
// FIXME: This is not correct! We should not have Exposed=Window here.
|
||||
[Global, Exposed=Window]
|
||||
interface ShadowRealmGlobalScope : EventTarget {
|
||||
readonly attribute ShadowRealmGlobalScope self;
|
||||
};
|
|
@ -222,6 +222,7 @@ libweb_js_bindings(HTML/RadioNodeList)
|
|||
libweb_js_bindings(HTML/ServiceWorker)
|
||||
libweb_js_bindings(HTML/ServiceWorkerContainer)
|
||||
libweb_js_bindings(HTML/ServiceWorkerRegistration)
|
||||
libweb_js_bindings(HTML/ShadowRealmGlobalScope)
|
||||
libweb_js_bindings(HTML/Storage)
|
||||
libweb_js_bindings(HTML/SubmitEvent)
|
||||
libweb_js_bindings(HTML/TextMetrics)
|
||||
|
|
Loading…
Reference in a new issue