mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibGC+Everywhere: Factor out a LibGC from LibJS
Resulting in a massive rename across almost everywhere! Alongside the namespace change, we now have the following names: * JS::NonnullGCPtr -> GC::Ref * JS::GCPtr -> GC::Ptr * JS::HeapFunction -> GC::Function * JS::CellImpl -> GC::Cell * JS::Handle -> GC::Root
This commit is contained in:
committed by
Andreas Kling
parent
ce23efc5f6
commit
f87041bf3a
@@ -13,7 +13,7 @@ target_include_directories(webworkerservice PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/
|
||||
target_include_directories(webworkerservice PRIVATE ${LADYBIRD_SOURCE_DIR})
|
||||
target_include_directories(webworkerservice PRIVATE ${LADYBIRD_SOURCE_DIR}/Services/)
|
||||
|
||||
target_link_libraries(webworkerservice PUBLIC LibCore LibFileSystem LibGfx LibIPC LibJS LibRequests LibWeb LibWebView LibUnicode LibImageDecoderClient LibMain LibURL)
|
||||
target_link_libraries(webworkerservice PUBLIC LibCore LibFileSystem LibGfx LibIPC LibJS LibRequests LibWeb LibWebView LibUnicode LibImageDecoderClient LibMain LibURL LibGC)
|
||||
|
||||
if (ENABLE_QT)
|
||||
qt_add_executable(WebWorker main.cpp)
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <AK/HashMap.h>
|
||||
#include <LibGC/Root.h>
|
||||
#include <LibIPC/ConnectionFromClient.h>
|
||||
#include <LibJS/Forward.h>
|
||||
#include <LibJS/Heap/Handle.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/Loader/FileRequest.h>
|
||||
#include <LibWeb/Worker/WebWorkerClientEndpoint.h>
|
||||
@@ -44,7 +44,7 @@ private:
|
||||
virtual void start_dedicated_worker(URL::URL const& url, Web::Bindings::WorkerType const& type, Web::Bindings::RequestCredentials const& credentials, String const& name, Web::HTML::TransferDataHolder const&, Web::HTML::SerializedEnvironmentSettingsObject const&) override;
|
||||
virtual void handle_file_return(i32 error, Optional<IPC::File> const& file, i32 request_id) override;
|
||||
|
||||
JS::Handle<PageHost> m_page_host;
|
||||
GC::Root<PageHost> m_page_host;
|
||||
|
||||
// FIXME: Route console messages to the Browser UI using a ConsoleClient
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ DedicatedWorkerHost::~DedicatedWorkerHost() = default;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/workers.html#run-a-worker
|
||||
// FIXME: Extract out into a helper for both shared and dedicated workers
|
||||
void DedicatedWorkerHost::run(JS::NonnullGCPtr<Web::Page> page, Web::HTML::TransferDataHolder message_port_data, Web::HTML::SerializedEnvironmentSettingsObject const& outside_settings_snapshot)
|
||||
void DedicatedWorkerHost::run(GC::Ref<Web::Page> page, Web::HTML::TransferDataHolder message_port_data, Web::HTML::SerializedEnvironmentSettingsObject const& outside_settings_snapshot)
|
||||
{
|
||||
bool const is_shared = false;
|
||||
|
||||
@@ -55,7 +55,7 @@ void DedicatedWorkerHost::run(JS::NonnullGCPtr<Web::Page> page, Web::HTML::Trans
|
||||
|
||||
// 8. Let worker global scope be the global object of realm execution context's Realm component.
|
||||
// NOTE: This is the DedicatedWorkerGlobalScope or SharedWorkerGlobalScope object created in the previous step.
|
||||
JS::NonnullGCPtr<Web::HTML::WorkerGlobalScope> worker_global_scope = verify_cast<Web::HTML::WorkerGlobalScope>(realm_execution_context->realm->global_object());
|
||||
GC::Ref<Web::HTML::WorkerGlobalScope> worker_global_scope = verify_cast<Web::HTML::WorkerGlobalScope>(realm_execution_context->realm->global_object());
|
||||
|
||||
// 9. Set up a worker environment settings object with realm execution context,
|
||||
// outside settings, and unsafeWorkerCreationTime, and let inside settings be the result.
|
||||
@@ -92,7 +92,7 @@ void DedicatedWorkerHost::run(JS::NonnullGCPtr<Web::Page> page, Web::HTML::Trans
|
||||
: Web::Fetch::Infrastructure::Request::Destination::Worker;
|
||||
|
||||
// In both cases, let performFetch be the following perform the fetch hook given request, isTopLevel and processCustomFetchResponse:
|
||||
auto perform_fetch_function = [inner_settings, worker_global_scope](JS::NonnullGCPtr<Web::Fetch::Infrastructure::Request> request, Web::HTML::TopLevelModule is_top_level, Web::Fetch::Infrastructure::FetchAlgorithms::ProcessResponseConsumeBodyFunction process_custom_fetch_response) -> Web::WebIDL::ExceptionOr<void> {
|
||||
auto perform_fetch_function = [inner_settings, worker_global_scope](GC::Ref<Web::Fetch::Infrastructure::Request> request, Web::HTML::TopLevelModule is_top_level, Web::Fetch::Infrastructure::FetchAlgorithms::ProcessResponseConsumeBodyFunction process_custom_fetch_response) -> Web::WebIDL::ExceptionOr<void> {
|
||||
auto& realm = inner_settings->realm();
|
||||
auto& vm = realm.vm();
|
||||
|
||||
@@ -106,10 +106,10 @@ void DedicatedWorkerHost::run(JS::NonnullGCPtr<Web::Page> page, Web::HTML::Trans
|
||||
}
|
||||
|
||||
// 2. Set request's reserved client to inside settings.
|
||||
request->set_reserved_client(JS::GCPtr<Web::HTML::EnvironmentSettingsObject>(inner_settings));
|
||||
request->set_reserved_client(GC::Ptr<Web::HTML::EnvironmentSettingsObject>(inner_settings));
|
||||
|
||||
// We need to store the process custom fetch response function on the heap here, because we're storing it in another heap function
|
||||
auto process_custom_fetch_response_function = JS::create_heap_function(vm.heap(), move(process_custom_fetch_response));
|
||||
auto process_custom_fetch_response_function = GC::create_function(vm.heap(), move(process_custom_fetch_response));
|
||||
|
||||
// 3. Fetch request with processResponseConsumeBody set to the following steps given response response and null, failure, or a byte sequence bodyBytes:
|
||||
fetch_algorithms_input.process_response_consume_body = [worker_global_scope, process_custom_fetch_response_function](auto response, auto body_bytes) {
|
||||
@@ -142,7 +142,7 @@ void DedicatedWorkerHost::run(JS::NonnullGCPtr<Web::Page> page, Web::HTML::Trans
|
||||
};
|
||||
auto perform_fetch = Web::HTML::create_perform_the_fetch_hook(inner_settings->heap(), move(perform_fetch_function));
|
||||
|
||||
auto on_complete_function = [inner_settings, worker_global_scope, message_port_data = move(message_port_data), url = m_url](JS::GCPtr<Web::HTML::Script> script) mutable {
|
||||
auto on_complete_function = [inner_settings, worker_global_scope, message_port_data = move(message_port_data), url = m_url](GC::Ptr<Web::HTML::Script> script) mutable {
|
||||
auto& realm = inner_settings->realm();
|
||||
// 1. If script is null or if script's error to rethrow is non-null, then:
|
||||
if (!script || !script->error_to_rethrow().is_null()) {
|
||||
|
||||
@@ -21,10 +21,10 @@ public:
|
||||
explicit DedicatedWorkerHost(URL::URL url, Web::Bindings::WorkerType type, String name);
|
||||
~DedicatedWorkerHost();
|
||||
|
||||
void run(JS::NonnullGCPtr<Web::Page>, Web::HTML::TransferDataHolder message_port_data, Web::HTML::SerializedEnvironmentSettingsObject const&);
|
||||
void run(GC::Ref<Web::Page>, Web::HTML::TransferDataHolder message_port_data, Web::HTML::SerializedEnvironmentSettingsObject const&);
|
||||
|
||||
private:
|
||||
JS::Handle<Web::HTML::WorkerDebugConsoleClient> m_console;
|
||||
GC::Root<Web::HTML::WorkerDebugConsoleClient> m_console;
|
||||
|
||||
URL::URL m_url;
|
||||
Web::Bindings::WorkerType m_type;
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
|
||||
namespace WebWorker {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(PageHost);
|
||||
GC_DEFINE_ALLOCATOR(PageHost);
|
||||
|
||||
JS::NonnullGCPtr<PageHost> PageHost::create(JS::VM& vm, ConnectionFromClient& client)
|
||||
GC::Ref<PageHost> PageHost::create(JS::VM& vm, ConnectionFromClient& client)
|
||||
{
|
||||
return vm.heap().allocate<PageHost>(client);
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
namespace WebWorker {
|
||||
|
||||
class PageHost final : public Web::PageClient {
|
||||
JS_CELL(PageHost, Web::PageClient);
|
||||
JS_DECLARE_ALLOCATOR(PageHost);
|
||||
GC_CELL(PageHost, Web::PageClient);
|
||||
GC_DECLARE_ALLOCATOR(PageHost);
|
||||
|
||||
public:
|
||||
static JS::NonnullGCPtr<PageHost> create(JS::VM& vm, ConnectionFromClient& client);
|
||||
static GC::Ref<PageHost> create(JS::VM& vm, ConnectionFromClient& client);
|
||||
|
||||
virtual ~PageHost();
|
||||
|
||||
@@ -45,7 +45,7 @@ private:
|
||||
void setup_palette();
|
||||
|
||||
ConnectionFromClient& m_client;
|
||||
JS::NonnullGCPtr<Web::Page> m_page;
|
||||
GC::Ref<Web::Page> m_page;
|
||||
RefPtr<Gfx::PaletteImpl> m_palette_impl;
|
||||
};
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
# include <QCoreApplication>
|
||||
#endif
|
||||
|
||||
static ErrorOr<void> initialize_resource_loader(JS::Heap&, int request_server_socket);
|
||||
static ErrorOr<void> initialize_resource_loader(GC::Heap&, int request_server_socket);
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
@@ -71,7 +71,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
return event_loop.exec();
|
||||
}
|
||||
|
||||
static ErrorOr<void> initialize_resource_loader(JS::Heap& heap, int request_server_socket)
|
||||
static ErrorOr<void> initialize_resource_loader(GC::Heap& heap, int request_server_socket)
|
||||
{
|
||||
static_assert(IsSame<IPC::Transport, IPC::TransportSocket>, "Need to handle other IPC transports here");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user