mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:37:36 +00:00
LibWeb: Remove the internal window object from WebEngineCustomData
Now that no one needs a Window just to create prototypes, we can remove the internal window Object from the main thread VM and get rid of the HTML::Window include for it. This finally solves the reference binding to nullptr error in ladybird that shows up when compiling it with ASAN.
This commit is contained in:
parent
56b381aac0
commit
691a7070f4
2 changed files with 2 additions and 19 deletions
|
@ -9,6 +9,7 @@
|
||||||
#include <LibJS/Runtime/Array.h>
|
#include <LibJS/Runtime/Array.h>
|
||||||
#include <LibJS/Runtime/Environment.h>
|
#include <LibJS/Runtime/Environment.h>
|
||||||
#include <LibJS/Runtime/FinalizationRegistry.h>
|
#include <LibJS/Runtime/FinalizationRegistry.h>
|
||||||
|
#include <LibJS/Runtime/GlobalObject.h>
|
||||||
#include <LibJS/Runtime/NativeFunction.h>
|
#include <LibJS/Runtime/NativeFunction.h>
|
||||||
#include <LibJS/Runtime/VM.h>
|
#include <LibJS/Runtime/VM.h>
|
||||||
#include <LibWeb/Bindings/Intrinsics.h>
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
|
@ -306,12 +307,7 @@ JS::VM& main_thread_vm()
|
||||||
// NOTE: We push a dummy execution context onto the JS execution context stack,
|
// NOTE: We push a dummy execution context onto the JS execution context stack,
|
||||||
// just to make sure that it's never empty.
|
// just to make sure that it's never empty.
|
||||||
auto& custom_data = *verify_cast<WebEngineCustomData>(vm->custom_data());
|
auto& custom_data = *verify_cast<WebEngineCustomData>(vm->custom_data());
|
||||||
custom_data.root_execution_context = MUST(JS::Realm::initialize_host_defined_realm(
|
custom_data.root_execution_context = MUST(JS::Realm::initialize_host_defined_realm(*vm, nullptr, nullptr));
|
||||||
*vm, [&](JS::Realm& realm) -> JS::Object* {
|
|
||||||
custom_data.internal_window_object = JS::make_handle(*HTML::Window::create(realm));
|
|
||||||
return custom_data.internal_window_object.cell();
|
|
||||||
},
|
|
||||||
nullptr));
|
|
||||||
|
|
||||||
auto* root_realm = custom_data.root_execution_context->realm;
|
auto* root_realm = custom_data.root_execution_context->realm;
|
||||||
auto* intrinsics = root_realm->heap().allocate<Intrinsics>(*root_realm, *root_realm);
|
auto* intrinsics = root_realm->heap().allocate<Intrinsics>(*root_realm, *root_realm);
|
||||||
|
@ -323,13 +319,6 @@ JS::VM& main_thread_vm()
|
||||||
return *vm;
|
return *vm;
|
||||||
}
|
}
|
||||||
|
|
||||||
HTML::Window& main_thread_internal_window_object()
|
|
||||||
{
|
|
||||||
auto& vm = main_thread_vm();
|
|
||||||
auto& custom_data = verify_cast<WebEngineCustomData>(*vm.custom_data());
|
|
||||||
return *custom_data.internal_window_object;
|
|
||||||
}
|
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#queue-a-mutation-observer-compound-microtask
|
// https://dom.spec.whatwg.org/#queue-a-mutation-observer-compound-microtask
|
||||||
void queue_mutation_observer_microtask(DOM::Document& document)
|
void queue_mutation_observer_microtask(DOM::Document& document)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include <LibJS/Runtime/VM.h>
|
#include <LibJS/Runtime/VM.h>
|
||||||
#include <LibWeb/DOM/MutationObserver.h>
|
#include <LibWeb/DOM/MutationObserver.h>
|
||||||
#include <LibWeb/HTML/EventLoop/EventLoop.h>
|
#include <LibWeb/HTML/EventLoop/EventLoop.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
|
||||||
|
|
||||||
namespace Web::Bindings {
|
namespace Web::Bindings {
|
||||||
|
|
||||||
|
@ -34,10 +33,6 @@ struct WebEngineCustomData final : public JS::VM::CustomData {
|
||||||
Vector<JS::Handle<DOM::MutationObserver>> mutation_observers;
|
Vector<JS::Handle<DOM::MutationObserver>> mutation_observers;
|
||||||
|
|
||||||
OwnPtr<JS::ExecutionContext> root_execution_context;
|
OwnPtr<JS::ExecutionContext> root_execution_context;
|
||||||
|
|
||||||
// This object is used as the global object for GC-allocated objects that don't
|
|
||||||
// belong to a web-facing global object.
|
|
||||||
JS::Handle<HTML::Window> internal_window_object;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct WebEngineCustomJobCallbackData final : public JS::JobCallback::CustomData {
|
struct WebEngineCustomJobCallbackData final : public JS::JobCallback::CustomData {
|
||||||
|
@ -55,7 +50,6 @@ struct WebEngineCustomJobCallbackData final : public JS::JobCallback::CustomData
|
||||||
|
|
||||||
HTML::ClassicScript* active_script();
|
HTML::ClassicScript* active_script();
|
||||||
JS::VM& main_thread_vm();
|
JS::VM& main_thread_vm();
|
||||||
HTML::Window& main_thread_internal_window_object();
|
|
||||||
void queue_mutation_observer_microtask(DOM::Document&);
|
void queue_mutation_observer_microtask(DOM::Document&);
|
||||||
NonnullOwnPtr<JS::ExecutionContext> create_a_new_javascript_realm(JS::VM&, Function<JS::Object*(JS::Realm&)> create_global_object, Function<JS::Object*(JS::Realm&)> create_global_this_value);
|
NonnullOwnPtr<JS::ExecutionContext> create_a_new_javascript_realm(JS::VM&, Function<JS::Object*(JS::Realm&)> create_global_object, Function<JS::Object*(JS::Realm&)> create_global_this_value);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue