1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:27:45 +00:00

LibWeb+WebWorker: Move worker execution into a new WebWorker process

We now create a WorkerAgent for the parent context, which is currently
only a Window. Note that Workers can have Workers per the spec.

The WorkerAgent spawns a WebWorker process to hold the actual
script execution of the Worker. This is modeled with the
DedicatedWorkerHost object in the WebWorker process.
A start_dedicated_worker IPC method in the WebWorker IPC creates the
WorkerHost object. Future different worker types may use different IPC
messages to create their WorkerHost instance.

This implementation cannot yet postMessage between the parent and the
child processes.

Co-Authored-By: Andreas Kling <kling@serenityos.org>
This commit is contained in:
Andrew Kaster 2023-11-08 11:47:41 -07:00 committed by Andreas Kling
parent 3dbbb5b263
commit 124c378472
31 changed files with 998 additions and 267 deletions

View file

@ -0,0 +1,44 @@
/*
* Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibGfx/Rect.h>
#include <LibWeb/Page/Page.h>
#include <LibWeb/PixelUnits.h>
#include <WebWorker/Forward.h>
namespace WebWorker {
class PageHost final : public Web::PageClient {
AK_MAKE_NONCOPYABLE(PageHost);
AK_MAKE_NONMOVABLE(PageHost);
public:
static NonnullOwnPtr<PageHost> create(ConnectionFromClient& client) { return adopt_own(*new PageHost(client)); }
virtual ~PageHost();
virtual Web::Page& page() override;
virtual Web::Page const& page() const override;
virtual bool is_connection_open() const override;
virtual Gfx::Palette palette() const override;
virtual Web::DevicePixelRect screen_rect() const override;
virtual double device_pixels_per_css_pixel() const override;
virtual Web::CSS::PreferredColorScheme preferred_color_scheme() const override;
virtual void paint(Web::DevicePixelRect const&, Gfx::Bitmap&) override;
virtual void request_file(Web::FileRequest) override;
private:
explicit PageHost(ConnectionFromClient&);
void setup_palette();
ConnectionFromClient& m_client;
NonnullOwnPtr<Web::Page> m_page;
RefPtr<Gfx::PaletteImpl> m_palette_impl;
};
}