mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 04:09:13 +00:00
LibWeb: Create separate DedicatedWorkerGlobalScope class
This is how it's supposed to have been from the beginning, we were just lazy :).
This commit is contained in:
parent
f99c7ad85d
commit
40a2bb32c3
Notes:
sideshowbarker
2024-07-17 02:08:15 +09:00
Author: https://github.com/ADKaster
Commit: 40a2bb32c3
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/543
13 changed files with 179 additions and 43 deletions
52
Userland/Libraries/LibWeb/HTML/DedicatedWorkerGlobalScope.h
Normal file
52
Userland/Libraries/LibWeb/HTML/DedicatedWorkerGlobalScope.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/Bindings/DedicatedWorkerGlobalScopeGlobalMixin.h>
|
||||
#include <LibWeb/Bindings/WorkerGlobalScopePrototype.h>
|
||||
#include <LibWeb/HTML/WorkerGlobalScope.h>
|
||||
|
||||
#define ENUMERATE_DEDICATED_WORKER_GLOBAL_SCOPE_EVENT_HANDLERS(E) \
|
||||
E(onmessage, HTML::EventNames::message) \
|
||||
E(onmessageerror, HTML::EventNames::messageerror)
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
class DedicatedWorkerGlobalScope
|
||||
: public WorkerGlobalScope
|
||||
, public Bindings::DedicatedWorkerGlobalScopeGlobalMixin {
|
||||
WEB_PLATFORM_OBJECT(DedicatedWorkerGlobalScope, WorkerGlobalScope);
|
||||
JS_DECLARE_ALLOCATOR(DedicatedWorkerGlobalScope);
|
||||
|
||||
public:
|
||||
virtual ~DedicatedWorkerGlobalScope() override;
|
||||
|
||||
WebIDL::ExceptionOr<void> post_message(JS::Value message, StructuredSerializeOptions const&);
|
||||
|
||||
void set_name(String name) { m_name = move(name); }
|
||||
String name() const { return m_name; }
|
||||
|
||||
void close();
|
||||
|
||||
#undef __ENUMERATE
|
||||
#define __ENUMERATE(attribute_name, event_name) \
|
||||
void set_##attribute_name(WebIDL::CallbackType*); \
|
||||
WebIDL::CallbackType* attribute_name();
|
||||
ENUMERATE_DEDICATED_WORKER_GLOBAL_SCOPE_EVENT_HANDLERS(__ENUMERATE)
|
||||
#undef __ENUMERATE
|
||||
|
||||
virtual void finalize() override;
|
||||
|
||||
private:
|
||||
DedicatedWorkerGlobalScope(JS::Realm&, JS::NonnullGCPtr<Web::Page>);
|
||||
|
||||
virtual void initialize_web_interfaces_impl() override;
|
||||
|
||||
String m_name;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue