mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 17:24:48 -05:00
4417f63ca0
These are defined by the ServiceWorker spec, not the HTML one.
45 lines
1.2 KiB
C++
45 lines
1.2 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 {
|
|
|
|
class ServiceWorker : public DOM::EventTarget {
|
|
WEB_PLATFORM_OBJECT(ServiceWorker, DOM::EventTarget);
|
|
|
|
public:
|
|
[[nodiscard]] static GC::Ref<ServiceWorker> create(JS::Realm& realm);
|
|
|
|
virtual ~ServiceWorker() override;
|
|
|
|
String script_url() const { return m_script_url; }
|
|
Bindings::ServiceWorkerState service_worker_state() const { return m_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&, String script_url);
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
|
|
String m_script_url;
|
|
Bindings::ServiceWorkerState m_state { Bindings::ServiceWorkerState::Parsed };
|
|
};
|
|
|
|
}
|