mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 03:25:13 +00:00
LibWeb: Move ServiceWorker classes to ServiceWorker namespace
These are defined by the ServiceWorker spec, not the HTML one.
This commit is contained in:
parent
2918405360
commit
4417f63ca0
Notes:
github-actions[bot]
2024-11-30 10:20:43 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/4417f63ca08 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2653
19 changed files with 44 additions and 37 deletions
|
@ -463,9 +463,6 @@ set(SOURCES
|
|||
HTML/Scripting/SerializedEnvironmentSettingsObject.cpp
|
||||
HTML/SelectedFile.cpp
|
||||
HTML/SelectItem.cpp
|
||||
HTML/ServiceWorker.cpp
|
||||
HTML/ServiceWorkerContainer.cpp
|
||||
HTML/ServiceWorkerRegistration.cpp
|
||||
HTML/SessionHistoryEntry.cpp
|
||||
HTML/SessionHistoryTraversalQueue.cpp
|
||||
HTML/ShadowRealmGlobalScope.cpp
|
||||
|
@ -670,7 +667,10 @@ set(SOURCES
|
|||
SecureContexts/AbstractOperations.cpp
|
||||
ServiceWorker/Job.cpp
|
||||
ServiceWorker/Registration.cpp
|
||||
ServiceWorker/ServiceWorker.cpp
|
||||
ServiceWorker/ServiceWorkerContainer.cpp
|
||||
ServiceWorker/ServiceWorkerRecord.cpp
|
||||
ServiceWorker/ServiceWorkerRegistration.cpp
|
||||
SRI/SRI.cpp
|
||||
StorageAPI/NavigatorStorage.cpp
|
||||
StorageAPI/StorageKey.cpp
|
||||
|
|
|
@ -516,8 +516,6 @@ class PluginArray;
|
|||
class PromiseRejectionEvent;
|
||||
class RadioNodeList;
|
||||
class SelectedFile;
|
||||
class ServiceWorkerContainer;
|
||||
class ServiceWorkerRegistration;
|
||||
class SessionHistoryEntry;
|
||||
class SharedResourceRequest;
|
||||
class Storage;
|
||||
|
@ -716,6 +714,12 @@ namespace Web::Selection {
|
|||
class Selection;
|
||||
}
|
||||
|
||||
namespace Web::ServiceWorker {
|
||||
class ServiceWorker;
|
||||
class ServiceWorkerContainer;
|
||||
class ServiceWorkerRegistration;
|
||||
}
|
||||
|
||||
namespace Web::Streams {
|
||||
class ByteLengthQueuingStrategy;
|
||||
class CountQueuingStrategy;
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
#include <LibWeb/Clipboard/Clipboard.h>
|
||||
#include <LibWeb/HTML/Navigator.h>
|
||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/HTML/ServiceWorkerContainer.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/Loader/ResourceLoader.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/ServiceWorker/ServiceWorkerContainer.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
|
@ -117,10 +117,10 @@ Optional<FlyString> Navigator::do_not_track() const
|
|||
return {};
|
||||
}
|
||||
|
||||
GC::Ref<ServiceWorkerContainer> Navigator::service_worker()
|
||||
GC::Ref<ServiceWorker::ServiceWorkerContainer> Navigator::service_worker()
|
||||
{
|
||||
if (!m_service_worker_container)
|
||||
m_service_worker_container = realm().create<ServiceWorkerContainer>(realm());
|
||||
m_service_worker_container = realm().create<ServiceWorker::ServiceWorkerContainer>(realm());
|
||||
return *m_service_worker_container;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
|
||||
Optional<FlyString> do_not_track() const;
|
||||
|
||||
GC::Ref<ServiceWorkerContainer> service_worker();
|
||||
GC::Ref<ServiceWorker::ServiceWorkerContainer> service_worker();
|
||||
|
||||
GC::Ref<MediaCapabilitiesAPI::MediaCapabilities> media_capabilities();
|
||||
|
||||
|
@ -86,7 +86,7 @@ private:
|
|||
GC::Ptr<UserActivation> m_user_activation;
|
||||
|
||||
// https://w3c.github.io/ServiceWorker/#navigator-serviceworker
|
||||
GC::Ptr<ServiceWorkerContainer> m_service_worker_container;
|
||||
GC::Ptr<ServiceWorker::ServiceWorkerContainer> m_service_worker_container;
|
||||
|
||||
// https://w3c.github.io/media-capabilities/#dom-navigator-mediacapabilities
|
||||
GC::Ptr<MediaCapabilitiesAPI::MediaCapabilities> m_media_capabilities;
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
#import <HTML/NavigatorLanguage.idl>
|
||||
#import <HTML/NavigatorOnLine.idl>
|
||||
#import <HTML/PluginArray.idl>
|
||||
#import <HTML/ServiceWorkerContainer.idl>
|
||||
#import <HTML/UserActivation.idl>
|
||||
#import <MediaCapabilitiesAPI/MediaCapabilities.idl>
|
||||
#import <ServiceWorker/ServiceWorkerContainer.idl>
|
||||
#import <StorageAPI/NavigatorStorage.idl>
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/system-state.html#navigator
|
||||
|
|
|
@ -47,10 +47,10 @@ GC::Ref<MediaCapabilitiesAPI::MediaCapabilities> WorkerNavigator::media_capabili
|
|||
return *m_media_capabilities;
|
||||
}
|
||||
|
||||
GC::Ref<ServiceWorkerContainer> WorkerNavigator::service_worker()
|
||||
GC::Ref<ServiceWorker::ServiceWorkerContainer> WorkerNavigator::service_worker()
|
||||
{
|
||||
if (!m_service_worker_container)
|
||||
m_service_worker_container = realm().create<ServiceWorkerContainer>(realm());
|
||||
m_service_worker_container = realm().create<ServiceWorker::ServiceWorkerContainer>(realm());
|
||||
return *m_service_worker_container;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
#include <LibWeb/HTML/NavigatorID.h>
|
||||
#include <LibWeb/HTML/NavigatorLanguage.h>
|
||||
#include <LibWeb/HTML/NavigatorOnLine.h>
|
||||
#include <LibWeb/HTML/ServiceWorkerContainer.h>
|
||||
#include <LibWeb/MediaCapabilitiesAPI/MediaCapabilities.h>
|
||||
#include <LibWeb/ServiceWorker/ServiceWorkerContainer.h>
|
||||
#include <LibWeb/StorageAPI/NavigatorStorage.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -32,7 +32,7 @@ class WorkerNavigator : public Bindings::PlatformObject
|
|||
public:
|
||||
[[nodiscard]] static GC::Ref<WorkerNavigator> create(WorkerGlobalScope&);
|
||||
|
||||
GC::Ref<ServiceWorkerContainer> service_worker();
|
||||
GC::Ref<ServiceWorker::ServiceWorkerContainer> service_worker();
|
||||
|
||||
virtual ~WorkerNavigator() override;
|
||||
|
||||
|
@ -50,7 +50,7 @@ private:
|
|||
// https://w3c.github.io/media-capabilities/#dom-workernavigator-mediacapabilities
|
||||
GC::Ptr<MediaCapabilitiesAPI::MediaCapabilities> m_media_capabilities;
|
||||
|
||||
GC::Ptr<ServiceWorkerContainer> m_service_worker_container;
|
||||
GC::Ptr<ServiceWorker::ServiceWorkerContainer> m_service_worker_container;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/HTML/EventNames.h>
|
||||
#include <LibWeb/HTML/ServiceWorker.h>
|
||||
#include <LibWeb/ServiceWorker/ServiceWorker.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
namespace Web::ServiceWorker {
|
||||
|
||||
ServiceWorker::ServiceWorker(JS::Realm& realm, String script_url)
|
||||
: DOM::EventTarget(realm)
|
|
@ -13,7 +13,7 @@
|
|||
E(onstatechange, HTML::EventNames::statechange) \
|
||||
E(onerror, HTML::EventNames::error)
|
||||
|
||||
namespace Web::HTML {
|
||||
namespace Web::ServiceWorker {
|
||||
|
||||
class ServiceWorker : public DOM::EventTarget {
|
||||
WEB_PLATFORM_OBJECT(ServiceWorker, DOM::EventTarget);
|
|
@ -10,17 +10,18 @@
|
|||
#include <LibWeb/Bindings/ServiceWorkerContainerPrototype.h>
|
||||
#include <LibWeb/DOMURL/DOMURL.h>
|
||||
#include <LibWeb/HTML/EventNames.h>
|
||||
#include <LibWeb/HTML/ServiceWorkerContainer.h>
|
||||
#include <LibWeb/ServiceWorker/Job.h>
|
||||
#include <LibWeb/ServiceWorker/ServiceWorker.h>
|
||||
#include <LibWeb/ServiceWorker/ServiceWorkerContainer.h>
|
||||
#include <LibWeb/StorageAPI/StorageKey.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
namespace Web::ServiceWorker {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(ServiceWorkerContainer);
|
||||
|
||||
ServiceWorkerContainer::ServiceWorkerContainer(JS::Realm& realm)
|
||||
: DOM::EventTarget(realm)
|
||||
, m_service_worker_client(relevant_settings_object(*this))
|
||||
, m_service_worker_client(HTML::relevant_settings_object(*this))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -61,7 +62,7 @@ GC::Ref<WebIDL::Promise> ServiceWorkerContainer::register_(String script_url, Re
|
|||
auto client = m_service_worker_client;
|
||||
|
||||
// 4. Let scriptURL be the result of parsing scriptURL with this's relevant settings object’s API base URL.
|
||||
auto base_url = relevant_settings_object(*this).api_base_url();
|
||||
auto base_url = HTML::relevant_settings_object(*this).api_base_url();
|
||||
auto parsed_script_url = DOMURL::parse(script_url, base_url);
|
||||
|
||||
// 5. Let scopeURL be null.
|
||||
|
@ -80,7 +81,7 @@ GC::Ref<WebIDL::Promise> ServiceWorkerContainer::register_(String script_url, Re
|
|||
}
|
||||
|
||||
// https://w3c.github.io/ServiceWorker/#start-register-algorithm
|
||||
void ServiceWorkerContainer::start_register(Optional<URL::URL> scope_url, URL::URL script_url, GC::Ref<WebIDL::Promise> promise, EnvironmentSettingsObject& client, URL::URL referrer, Bindings::WorkerType worker_type, Bindings::ServiceWorkerUpdateViaCache update_via_cache)
|
||||
void ServiceWorkerContainer::start_register(Optional<URL::URL> scope_url, URL::URL script_url, GC::Ref<WebIDL::Promise> promise, HTML::EnvironmentSettingsObject& client, URL::URL referrer, Bindings::WorkerType worker_type, Bindings::ServiceWorkerUpdateViaCache update_via_cache)
|
||||
{
|
||||
auto& realm = this->realm();
|
||||
auto& vm = realm.vm();
|
||||
|
@ -155,7 +156,7 @@ void ServiceWorkerContainer::start_register(Optional<URL::URL> scope_url, URL::U
|
|||
}
|
||||
|
||||
// 11. Let job be the result of running Create Job with register, storage key, scopeURL, scriptURL, promise, and client.
|
||||
auto job = ServiceWorker::Job::create(vm, ServiceWorker::Job::Type::Register, storage_key.value(), scope_url.value(), script_url, promise, client);
|
||||
auto job = Job::create(vm, Job::Type::Register, storage_key.value(), scope_url.value(), script_url, promise, client);
|
||||
|
||||
// 12. Set job’s worker type to workerType.
|
||||
job->worker_type = worker_type;
|
||||
|
@ -167,7 +168,7 @@ void ServiceWorkerContainer::start_register(Optional<URL::URL> scope_url, URL::U
|
|||
job->referrer = move(referrer);
|
||||
|
||||
// 15. Invoke Schedule Job with job.
|
||||
ServiceWorker::schedule_job(vm, job);
|
||||
schedule_job(vm, job);
|
||||
}
|
||||
|
||||
#undef __ENUMERATE
|
|
@ -18,7 +18,7 @@
|
|||
E(onmessage, HTML::EventNames::message) \
|
||||
E(onmessageerror, HTML::EventNames::messageerror)
|
||||
|
||||
namespace Web::HTML {
|
||||
namespace Web::ServiceWorker {
|
||||
|
||||
struct RegistrationOptions {
|
||||
Optional<String> scope;
|
||||
|
@ -49,9 +49,9 @@ private:
|
|||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
void start_register(Optional<URL::URL> scope_url, URL::URL script_url, GC::Ref<WebIDL::Promise>, EnvironmentSettingsObject&, URL::URL referrer, Bindings::WorkerType, Bindings::ServiceWorkerUpdateViaCache);
|
||||
void start_register(Optional<URL::URL> scope_url, URL::URL script_url, GC::Ref<WebIDL::Promise>, HTML::EnvironmentSettingsObject&, URL::URL referrer, Bindings::WorkerType, Bindings::ServiceWorkerUpdateViaCache);
|
||||
|
||||
GC::Ref<EnvironmentSettingsObject> m_service_worker_client;
|
||||
GC::Ref<HTML::EnvironmentSettingsObject> m_service_worker_client;
|
||||
};
|
||||
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
#import <DOM/EventTarget.idl>
|
||||
#import <DOM/EventHandler.idl>
|
||||
#import <HTML/ServiceWorkerRegistration.idl>
|
||||
#import <HTML/Worker.idl>
|
||||
#import <ServiceWorker/ServiceWorkerRegistration.idl>
|
||||
|
||||
// https://w3c.github.io/ServiceWorker/#serviceworkercontainer-interface
|
||||
[SecureContext, Exposed=(Window,Worker)]
|
|
@ -7,9 +7,9 @@
|
|||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/Bindings/ServiceWorkerRegistrationPrototype.h>
|
||||
#include <LibWeb/HTML/ServiceWorkerRegistration.h>
|
||||
#include <LibWeb/ServiceWorker/ServiceWorkerRegistration.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
namespace Web::ServiceWorker {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(ServiceWorkerRegistration);
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <LibWeb/DOM/EventTarget.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
namespace Web::ServiceWorker {
|
||||
|
||||
class ServiceWorkerRegistration : public DOM::EventTarget {
|
||||
WEB_PLATFORM_OBJECT(ServiceWorkerRegistration, DOM::EventTarget);
|
|
@ -1,6 +1,6 @@
|
|||
#import <DOM/EventTarget.idl>
|
||||
#import <DOM/EventHandler.idl>
|
||||
#import <HTML/ServiceWorker.idl>
|
||||
#import <ServiceWorker/ServiceWorker.idl>
|
||||
|
||||
// https://w3c.github.io/ServiceWorker/#serviceworkerregistration-interface
|
||||
[SecureContext, Exposed=(Window,Worker)]
|
|
@ -221,9 +221,6 @@ libweb_js_bindings(HTML/PluginArray)
|
|||
libweb_js_bindings(HTML/PopStateEvent)
|
||||
libweb_js_bindings(HTML/PromiseRejectionEvent)
|
||||
libweb_js_bindings(HTML/RadioNodeList)
|
||||
libweb_js_bindings(HTML/ServiceWorker)
|
||||
libweb_js_bindings(HTML/ServiceWorkerContainer)
|
||||
libweb_js_bindings(HTML/ServiceWorkerRegistration)
|
||||
libweb_js_bindings(HTML/ShadowRealmGlobalScope GLOBAL)
|
||||
libweb_js_bindings(HTML/Storage)
|
||||
libweb_js_bindings(HTML/SubmitEvent)
|
||||
|
@ -278,6 +275,9 @@ libweb_js_bindings(RequestIdleCallback/IdleDeadline)
|
|||
libweb_js_bindings(ResizeObserver/ResizeObserver)
|
||||
libweb_js_bindings(ResizeObserver/ResizeObserverEntry)
|
||||
libweb_js_bindings(ResizeObserver/ResizeObserverSize)
|
||||
libweb_js_bindings(ServiceWorker/ServiceWorker)
|
||||
libweb_js_bindings(ServiceWorker/ServiceWorkerContainer)
|
||||
libweb_js_bindings(ServiceWorker/ServiceWorkerRegistration)
|
||||
libweb_js_bindings(Streams/ByteLengthQueuingStrategy)
|
||||
libweb_js_bindings(Streams/CountQueuingStrategy)
|
||||
libweb_js_bindings(Streams/ReadableByteStreamController)
|
||||
|
|
|
@ -4308,6 +4308,7 @@ using namespace Web::PerformanceTimeline;
|
|||
using namespace Web::RequestIdleCallback;
|
||||
using namespace Web::ResizeObserver;
|
||||
using namespace Web::Selection;
|
||||
using namespace Web::ServiceWorker;
|
||||
using namespace Web::StorageAPI;
|
||||
using namespace Web::Streams;
|
||||
using namespace Web::SVG;
|
||||
|
|
|
@ -35,6 +35,7 @@ static constexpr Array libweb_interface_namespaces = {
|
|||
"ResizeObserver"sv,
|
||||
"SVG"sv,
|
||||
"Selection"sv,
|
||||
"ServiceWorker"sv,
|
||||
"UIEvents"sv,
|
||||
"WebAudio"sv,
|
||||
"WebGL"sv,
|
||||
|
|
Loading…
Add table
Reference in a new issue