mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-18 09:50:27 +00:00
This ensures that we are explicitly declaring the allocator to use when allocating a cell(-inheriting) type, instead of silently falling back to size-based allocation. Since this is done in allocate_cell, this will only be detected for types that are actively being allocated. However, since that means they're _not_ being allocated, that means it's safe to not declare an allocator to use for those. For example, the base TypedArray<T>, which is never directly allocated and only the defined specializations are ever allocated.
48 lines
1.4 KiB
C++
48 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2024, Andrew Kaster <andrew@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/Bindings/ServiceWorkerPrototype.h>
|
|
#include <LibWeb/DOM/EventTarget.h>
|
|
|
|
#define ENUMERATE_SERVICE_WORKER_EVENT_HANDLERS(E) \
|
|
E(onstatechange, HTML::EventNames::statechange) \
|
|
E(onerror, HTML::EventNames::error)
|
|
|
|
namespace Web::ServiceWorker {
|
|
|
|
// https://w3c.github.io/ServiceWorker/#serviceworker-interface
|
|
class ServiceWorker : public DOM::EventTarget {
|
|
WEB_PLATFORM_OBJECT(ServiceWorker, DOM::EventTarget);
|
|
GC_DECLARE_ALLOCATOR(ServiceWorker);
|
|
|
|
public:
|
|
[[nodiscard]] static GC::Ref<ServiceWorker> create(JS::Realm& realm, ServiceWorkerRecord*);
|
|
|
|
virtual ~ServiceWorker() override;
|
|
|
|
String script_url() const;
|
|
Bindings::ServiceWorkerState service_worker_state() const { return m_state; }
|
|
void set_service_worker_state(Bindings::ServiceWorkerState state) { m_state = state; }
|
|
|
|
#undef __ENUMERATE
|
|
#define __ENUMERATE(attribute_name, event_name) \
|
|
void set_##attribute_name(WebIDL::CallbackType*); \
|
|
WebIDL::CallbackType* attribute_name();
|
|
ENUMERATE_SERVICE_WORKER_EVENT_HANDLERS(__ENUMERATE)
|
|
#undef __ENUMERATE
|
|
|
|
private:
|
|
ServiceWorker(JS::Realm&, ServiceWorkerRecord*);
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
|
|
Bindings::ServiceWorkerState m_state { Bindings::ServiceWorkerState::Parsed };
|
|
ServiceWorkerRecord* m_service_worker_record;
|
|
};
|
|
|
|
}
|