mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-19 07:22:21 +00:00
LibWeb/HTML: Hook up a WorkerAgent for web workers
This commit is contained in:
parent
5290ebfe19
commit
041ff0c7ff
Notes:
github-actions[bot]
2025-04-25 14:45:27 +00:00
Author: https://github.com/shannonbooth
Commit: 041ff0c7ff
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4453
10 changed files with 78 additions and 12 deletions
|
@ -11,10 +11,12 @@
|
|||
|
||||
namespace Web::HTML {
|
||||
|
||||
NonnullOwnPtr<SimilarOriginWindowAgent> SimilarOriginWindowAgent::create()
|
||||
NonnullOwnPtr<SimilarOriginWindowAgent> SimilarOriginWindowAgent::create(GC::Heap& heap)
|
||||
{
|
||||
// See 'creating an agent' step in: https://html.spec.whatwg.org/multipage/webappapis.html#obtain-similar-origin-window-agent
|
||||
return adopt_own(*new SimilarOriginWindowAgent(CanBlock::No));
|
||||
auto agent = adopt_own(*new SimilarOriginWindowAgent(CanBlock::No));
|
||||
agent->event_loop = heap.allocate<HTML::EventLoop>(HTML::EventLoop::Type::Window);
|
||||
return agent;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#relevant-agent
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace Web::HTML {
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#similar-origin-window-agent
|
||||
struct SimilarOriginWindowAgent : public Agent {
|
||||
static NonnullOwnPtr<SimilarOriginWindowAgent> create();
|
||||
static NonnullOwnPtr<SimilarOriginWindowAgent> create(GC::Heap&);
|
||||
|
||||
// https://dom.spec.whatwg.org/#mutation-observer-compound-microtask-queued-flag
|
||||
// Each similar-origin window agent has a mutation observer microtask queued (a boolean), which is initially false. [HTML]
|
||||
|
|
19
Libraries/LibWeb/HTML/Scripting/WorkerAgent.cpp
Normal file
19
Libraries/LibWeb/HTML/Scripting/WorkerAgent.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Shannon Booth <shannon@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/HTML/EventLoop/EventLoop.h>
|
||||
#include <LibWeb/HTML/Scripting/WorkerAgent.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
NonnullOwnPtr<WorkerAgent> WorkerAgent::create(GC::Heap& heap, CanBlock can_block)
|
||||
{
|
||||
auto agent = adopt_own(*new WorkerAgent(can_block));
|
||||
agent->event_loop = heap.allocate<HTML::EventLoop>(HTML::EventLoop::Type::Worker);
|
||||
return agent;
|
||||
}
|
||||
|
||||
}
|
22
Libraries/LibWeb/HTML/Scripting/WorkerAgent.h
Normal file
22
Libraries/LibWeb/HTML/Scripting/WorkerAgent.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Shannon Booth <shannon@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/HTML/Scripting/Agent.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#dedicated-worker-agent
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#shared-worker-agent
|
||||
struct WorkerAgent : public Agent {
|
||||
static NonnullOwnPtr<WorkerAgent> create(GC::Heap&, CanBlock);
|
||||
|
||||
private:
|
||||
using Agent::Agent;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue