mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb: Move name attribute to WorkerGlobalScope from subclasses
Also refactor the other properties of WorkerGlobalScope to match the spec better.
This commit is contained in:
parent
cef9564728
commit
b10a98b0cb
Notes:
github-actions[bot]
2025-05-18 23:51:28 +00:00
Author: https://github.com/ADKaster
Commit: b10a98b0cb
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4806
Reviewed-by: https://github.com/shannonbooth
Reviewed-by: https://github.com/trflynn89
4 changed files with 13 additions and 17 deletions
|
@ -28,9 +28,6 @@ public:
|
||||||
WebIDL::ExceptionOr<void> post_message(JS::Value message, StructuredSerializeOptions const&);
|
WebIDL::ExceptionOr<void> post_message(JS::Value message, StructuredSerializeOptions const&);
|
||||||
WebIDL::ExceptionOr<void> post_message(JS::Value message, Vector<GC::Root<JS::Object>> const& transfer);
|
WebIDL::ExceptionOr<void> post_message(JS::Value message, Vector<GC::Root<JS::Object>> const& transfer);
|
||||||
|
|
||||||
void set_name(String name) { m_name = move(name); }
|
|
||||||
String name() const { return m_name; }
|
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
#undef __ENUMERATE
|
#undef __ENUMERATE
|
||||||
|
@ -46,8 +43,6 @@ private:
|
||||||
DedicatedWorkerGlobalScope(JS::Realm&, GC::Ref<Web::Page>);
|
DedicatedWorkerGlobalScope(JS::Realm&, GC::Ref<Web::Page>);
|
||||||
|
|
||||||
virtual void initialize_web_interfaces_impl() override;
|
virtual void initialize_web_interfaces_impl() override;
|
||||||
|
|
||||||
String m_name;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,8 @@ HashTable<GC::RawRef<SharedWorkerGlobalScope>>& all_shared_worker_global_scopes(
|
||||||
return set;
|
return set;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedWorkerGlobalScope::SharedWorkerGlobalScope(JS::Realm& realm, GC::Ref<Web::Page> page, String name)
|
SharedWorkerGlobalScope::SharedWorkerGlobalScope(JS::Realm& realm, GC::Ref<Web::Page> page)
|
||||||
: WorkerGlobalScope(realm, page)
|
: WorkerGlobalScope(realm, page)
|
||||||
, m_name(move(name))
|
|
||||||
{
|
{
|
||||||
all_shared_worker_global_scopes().set(*this);
|
all_shared_worker_global_scopes().set(*this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,6 @@ class SharedWorkerGlobalScope
|
||||||
public:
|
public:
|
||||||
virtual ~SharedWorkerGlobalScope() override;
|
virtual ~SharedWorkerGlobalScope() override;
|
||||||
|
|
||||||
String const& name() const { return m_name; }
|
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
#define __ENUMERATE(attribute_name, event_name) \
|
#define __ENUMERATE(attribute_name, event_name) \
|
||||||
|
@ -36,12 +34,10 @@ public:
|
||||||
#undef __ENUMERATE
|
#undef __ENUMERATE
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SharedWorkerGlobalScope(JS::Realm&, GC::Ref<Web::Page>, String name);
|
SharedWorkerGlobalScope(JS::Realm&, GC::Ref<Web::Page>);
|
||||||
|
|
||||||
virtual void initialize_web_interfaces_impl() override;
|
virtual void initialize_web_interfaces_impl() override;
|
||||||
virtual void finalize() override;
|
virtual void finalize() override;
|
||||||
|
|
||||||
String m_name;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
HashTable<GC::RawRef<SharedWorkerGlobalScope>>& all_shared_worker_global_scopes();
|
HashTable<GC::RawRef<SharedWorkerGlobalScope>>& all_shared_worker_global_scopes();
|
||||||
|
|
|
@ -83,6 +83,12 @@ public:
|
||||||
URL::URL const& url() const { return m_url.value(); }
|
URL::URL const& url() const { return m_url.value(); }
|
||||||
void set_url(URL::URL const& url) { m_url = url; }
|
void set_url(URL::URL const& url) { m_url = url; }
|
||||||
|
|
||||||
|
String const& name() const { return m_name; }
|
||||||
|
void set_name(String name) { m_name = move(name); }
|
||||||
|
|
||||||
|
Bindings::WorkerType type() const { return m_type; }
|
||||||
|
void set_type(Bindings::WorkerType type) { m_type = type; }
|
||||||
|
|
||||||
// Spec note: While the WorkerLocation object is created after the WorkerGlobalScope object,
|
// Spec note: While the WorkerLocation object is created after the WorkerGlobalScope object,
|
||||||
// this is not problematic as it cannot be observed from script.
|
// this is not problematic as it cannot be observed from script.
|
||||||
void set_location(GC::Ref<WorkerLocation> loc) { m_location = move(loc); }
|
void set_location(GC::Ref<WorkerLocation> loc) { m_location = move(loc); }
|
||||||
|
@ -121,14 +127,13 @@ private:
|
||||||
|
|
||||||
GC::Ref<Web::Page> m_page;
|
GC::Ref<Web::Page> m_page;
|
||||||
|
|
||||||
// FIXME: Add all these internal slots
|
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/workers.html#concept-WorkerGlobalScope-owner-set
|
// https://html.spec.whatwg.org/multipage/workers.html#concept-WorkerGlobalScope-owner-set
|
||||||
// A WorkerGlobalScope object has an associated owner set (a set of Document and WorkerGlobalScope objects). It is initially empty and populated when the worker is created or obtained.
|
// FIXME: A WorkerGlobalScope object has an associated owner set (a set of Document and WorkerGlobalScope objects). It is initially empty and populated when the worker is created or obtained.
|
||||||
// Note: It is a set, instead of a single owner, to accommodate SharedWorkerGlobalScope objects.
|
// Note: It is a set, instead of a single owner, to accommodate SharedWorkerGlobalScope objects.
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-type
|
// https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-type
|
||||||
// A WorkerGlobalScope object has an associated type ("classic" or "module"). It is set during creation.
|
// A WorkerGlobalScope object has an associated type ("classic" or "module"). It is set during creation.
|
||||||
|
Bindings::WorkerType m_type { Bindings::WorkerType::Classic };
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-url
|
// https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-url
|
||||||
// A WorkerGlobalScope object has an associated url (null or a URL). It is initially null.
|
// A WorkerGlobalScope object has an associated url (null or a URL). It is initially null.
|
||||||
|
@ -140,6 +145,7 @@ private:
|
||||||
// For DedicatedWorkerGlobalScope instances, it is simply a developer-supplied name, useful mostly for debugging purposes.
|
// For DedicatedWorkerGlobalScope instances, it is simply a developer-supplied name, useful mostly for debugging purposes.
|
||||||
// For SharedWorkerGlobalScope instances, it allows obtaining a reference to a common shared worker via the SharedWorker() constructor.
|
// For SharedWorkerGlobalScope instances, it allows obtaining a reference to a common shared worker via the SharedWorker() constructor.
|
||||||
// For ServiceWorkerGlobalScope objects, it doesn't make sense (and as such isn't exposed through the JavaScript API at all).
|
// For ServiceWorkerGlobalScope objects, it doesn't make sense (and as such isn't exposed through the JavaScript API at all).
|
||||||
|
String m_name;
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-policy-container
|
// https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-policy-container
|
||||||
// A WorkerGlobalScope object has an associated policy container (a policy container). It is initially a new policy container.
|
// A WorkerGlobalScope object has an associated policy container (a policy container). It is initially a new policy container.
|
||||||
|
@ -147,10 +153,10 @@ private:
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-embedder-policy
|
// https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-embedder-policy
|
||||||
// A WorkerGlobalScope object has an associated embedder policy (an embedder policy).
|
// A WorkerGlobalScope object has an associated embedder policy (an embedder policy).
|
||||||
EmbedderPolicy m_embedder_policy;
|
// FIXME: Should be removed, https://github.com/whatwg/html/issues/11316
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-module-map
|
// https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-module-map
|
||||||
// A WorkerGlobalScope object has an associated module map. It is a module map, initially empty.
|
// FIXME: A WorkerGlobalScope object has an associated module map. It is a module map, initially empty.
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-cross-origin-isolated-capability
|
// https://html.spec.whatwg.org/multipage/workers.html#concept-workerglobalscope-cross-origin-isolated-capability
|
||||||
bool m_cross_origin_isolated_capability { false };
|
bool m_cross_origin_isolated_capability { false };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue