mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:27:44 +00:00
LibWeb: Port Worker to new String
This commit is contained in:
parent
836cb73d29
commit
e905f25911
3 changed files with 11 additions and 11 deletions
|
@ -17,7 +17,7 @@
|
||||||
namespace Web::HTML {
|
namespace Web::HTML {
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/workers.html#dedicated-workers-and-the-worker-interface
|
// https://html.spec.whatwg.org/multipage/workers.html#dedicated-workers-and-the-worker-interface
|
||||||
Worker::Worker(DeprecatedFlyString const& script_url, WorkerOptions const options, DOM::Document& document)
|
Worker::Worker(String const& script_url, WorkerOptions const options, DOM::Document& document)
|
||||||
: DOM::EventTarget(document.realm())
|
: DOM::EventTarget(document.realm())
|
||||||
, m_script_url(script_url)
|
, m_script_url(script_url)
|
||||||
, m_options(options)
|
, m_options(options)
|
||||||
|
@ -47,7 +47,7 @@ void Worker::visit_edges(Cell::Visitor& visitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/workers.html#dom-worker
|
// https://html.spec.whatwg.org/multipage/workers.html#dom-worker
|
||||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<Worker>> Worker::create(DeprecatedFlyString const& script_url, WorkerOptions const options, DOM::Document& document)
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<Worker>> Worker::create(String const& script_url, WorkerOptions const options, DOM::Document& document)
|
||||||
{
|
{
|
||||||
dbgln_if(WEB_WORKER_DEBUG, "WebWorker: Creating worker with script_url = {}", script_url);
|
dbgln_if(WEB_WORKER_DEBUG, "WebWorker: Creating worker with script_url = {}", script_url);
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Worker>> Worker::create(DeprecatedFlyString
|
||||||
auto& outside_settings = document.relevant_settings_object();
|
auto& outside_settings = document.relevant_settings_object();
|
||||||
|
|
||||||
// 3. Parse the scriptURL argument relative to outside settings.
|
// 3. Parse the scriptURL argument relative to outside settings.
|
||||||
auto url = document.parse_url(script_url);
|
auto url = document.parse_url(script_url.to_deprecated_string());
|
||||||
|
|
||||||
// 4. If this fails, throw a "SyntaxError" DOMException.
|
// 4. If this fails, throw a "SyntaxError" DOMException.
|
||||||
if (!url.is_valid()) {
|
if (!url.is_valid()) {
|
||||||
|
|
|
@ -26,9 +26,9 @@
|
||||||
namespace Web::HTML {
|
namespace Web::HTML {
|
||||||
|
|
||||||
struct WorkerOptions {
|
struct WorkerOptions {
|
||||||
DeprecatedString type { "classic" };
|
String type { String::from_utf8("classic"sv).release_value_but_fixme_should_propagate_errors() };
|
||||||
DeprecatedString credentials { "same-origin" };
|
String credentials { String::from_utf8("same-origin"sv).release_value_but_fixme_should_propagate_errors() };
|
||||||
DeprecatedString name { "" };
|
String name { String {} };
|
||||||
};
|
};
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/workers.html#dedicated-workers-and-the-worker-interface
|
// https://html.spec.whatwg.org/multipage/workers.html#dedicated-workers-and-the-worker-interface
|
||||||
|
@ -36,8 +36,8 @@ class Worker : public DOM::EventTarget {
|
||||||
WEB_PLATFORM_OBJECT(Worker, DOM::EventTarget);
|
WEB_PLATFORM_OBJECT(Worker, DOM::EventTarget);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Worker>> create(DeprecatedFlyString const& script_url, WorkerOptions const options, DOM::Document& document);
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Worker>> create(String const& script_url, WorkerOptions const options, DOM::Document& document);
|
||||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Worker>> construct_impl(JS::Realm& realm, DeprecatedFlyString const& script_url, WorkerOptions const options)
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Worker>> construct_impl(JS::Realm& realm, String const& script_url, WorkerOptions const options)
|
||||||
{
|
{
|
||||||
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
||||||
return Worker::create(script_url, options, window.associated_document());
|
return Worker::create(script_url, options, window.associated_document());
|
||||||
|
@ -60,7 +60,7 @@ public:
|
||||||
#undef __ENUMERATE
|
#undef __ENUMERATE
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Worker(DeprecatedFlyString const&, const WorkerOptions, DOM::Document&);
|
Worker(String const&, const WorkerOptions, DOM::Document&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static HTML::EventLoop& get_vm_event_loop(JS::VM& target_vm)
|
static HTML::EventLoop& get_vm_event_loop(JS::VM& target_vm)
|
||||||
|
@ -71,7 +71,7 @@ private:
|
||||||
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
DeprecatedFlyString m_script_url;
|
String m_script_url;
|
||||||
WorkerOptions m_options;
|
WorkerOptions m_options;
|
||||||
|
|
||||||
JS::GCPtr<DOM::Document> m_document;
|
JS::GCPtr<DOM::Document> m_document;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#import <DOM/EventTarget.idl>
|
#import <DOM/EventTarget.idl>
|
||||||
#import <DOM/EventHandler.idl>
|
#import <DOM/EventHandler.idl>
|
||||||
|
|
||||||
[Exposed=(Window)]
|
[Exposed=(Window), UseNewAKString]
|
||||||
interface Worker : EventTarget {
|
interface Worker : EventTarget {
|
||||||
constructor(DOMString scriptURL, optional WorkerOptions options = {});
|
constructor(DOMString scriptURL, optional WorkerOptions options = {});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue