diff options
7 files changed, 35 insertions, 20 deletions
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp index f3afa78ba7..1295198537 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp @@ -3275,7 +3275,6 @@ void generate_prototype_implementation(IDL::Interface const& interface) #endif #include <LibWeb/Bindings/ExceptionOrUtils.h> #include <LibWeb/Bindings/LocationObject.h> -#include <LibWeb/Bindings/WorkerLocationWrapper.h> #include <LibWeb/Bindings/WorkerNavigatorWrapper.h> #include <LibWeb/DOM/Element.h> #include <LibWeb/DOM/Event.h> diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h index bc711fdb32..2b94dd4d7d 100644 --- a/Userland/Libraries/LibWeb/Forward.h +++ b/Userland/Libraries/LibWeb/Forward.h @@ -453,7 +453,6 @@ class LocationObject; class OptionConstructor; class RangePrototype; class WindowProxy; -class WorkerLocationWrapper; class WorkerNavigatorWrapper; class Wrappable; class Wrapper; diff --git a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp index 350e4ec11d..f360e57e40 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp +++ b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.cpp @@ -28,6 +28,12 @@ WorkerGlobalScope::WorkerGlobalScope(JS::Realm& realm) WorkerGlobalScope::~WorkerGlobalScope() = default; +void WorkerGlobalScope::visit_edges(Cell::Visitor& visitor) +{ + Base::visit_edges(visitor); + visitor.visit(m_location); +} + // https://html.spec.whatwg.org/multipage/workers.html#importing-scripts-and-libraries DOM::ExceptionOr<void> WorkerGlobalScope::import_scripts(Vector<String> urls) { @@ -56,7 +62,7 @@ DOM::ExceptionOr<void> WorkerGlobalScope::import_scripts(Vector<String> urls) } // https://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-location -NonnullRefPtr<WorkerLocation const> WorkerGlobalScope::location() const +JS::NonnullGCPtr<WorkerLocation> WorkerGlobalScope::location() const { // The location attribute must return the WorkerLocation object whose associated WorkerGlobalScope object is the WorkerGlobalScope object. return *m_location; diff --git a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h index 269b9f1ab9..592c792e3d 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h +++ b/Userland/Libraries/LibWeb/HTML/WorkerGlobalScope.h @@ -41,7 +41,7 @@ public: // https://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-self JS::NonnullGCPtr<WorkerGlobalScope> self() const { return *this; } - NonnullRefPtr<WorkerLocation const> location() const; + JS::NonnullGCPtr<WorkerLocation> location() const; NonnullRefPtr<WorkerNavigator const> navigator() const; DOM::ExceptionOr<void> import_scripts(Vector<String> urls); @@ -68,13 +68,15 @@ public: // Spec note: While the WorkerLocation object is created after the WorkerGlobalScope object, // this is not problematic as it cannot be observed from script. - void set_location(NonnullRefPtr<WorkerLocation> loc) { m_location = move(loc); } + void set_location(JS::NonnullGCPtr<WorkerLocation> loc) { m_location = move(loc); } protected: explicit WorkerGlobalScope(JS::Realm&); private: - RefPtr<WorkerLocation> m_location; + virtual void visit_edges(Cell::Visitor&) override; + + JS::GCPtr<WorkerLocation> m_location; // FIXME: Implement WorkerNavigator according to the spec NonnullRefPtr<WorkerNavigator> m_navigator; diff --git a/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp b/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp index 4499aa0aa3..fac203d735 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp +++ b/Userland/Libraries/LibWeb/HTML/WorkerLocation.cpp @@ -117,8 +117,18 @@ String WorkerLocation::hash() const } WorkerLocation::WorkerLocation(WorkerGlobalScope& global_scope) - : m_global_scope(global_scope) + : PlatformObject(global_scope.realm()) + , m_global_scope(global_scope) { + // FIXME: Set prototype once we can get to worker scope prototypes. +} + +WorkerLocation::~WorkerLocation() = default; + +void WorkerLocation::visit_edges(Cell::Visitor& visitor) +{ + Base::visit_edges(visitor); + visitor.visit(m_global_scope); } } diff --git a/Userland/Libraries/LibWeb/HTML/WorkerLocation.h b/Userland/Libraries/LibWeb/HTML/WorkerLocation.h index 384b74bfc7..49bcc0463a 100644 --- a/Userland/Libraries/LibWeb/HTML/WorkerLocation.h +++ b/Userland/Libraries/LibWeb/HTML/WorkerLocation.h @@ -6,23 +6,18 @@ #pragma once -#include <AK/RefCounted.h> -#include <LibWeb/Bindings/Wrappable.h> -#include <LibWeb/Forward.h> +#include <LibWeb/Bindings/PlatformObject.h> namespace Web::HTML { // https://html.spec.whatwg.org/multipage/workers.html#worker-locations -class WorkerLocation - : public RefCounted<WorkerLocation> - , public Bindings::Wrappable { +class WorkerLocation : public Bindings::PlatformObject { + WEB_PLATFORM_OBJECT(WorkerLocation, Bindings::PlatformObject); + public: - using WrapperType = Bindings::WorkerLocationWrapper; + static JS::NonnullGCPtr<WorkerLocation> create(WorkerGlobalScope&); - static NonnullRefPtr<WorkerLocation> create(WorkerGlobalScope& global_scope) - { - return adopt_ref(*new WorkerLocation(global_scope)); - } + virtual ~WorkerLocation() override; String href() const; String origin() const; @@ -35,9 +30,13 @@ public: String hash() const; private: - WorkerLocation(WorkerGlobalScope&); + explicit WorkerLocation(WorkerGlobalScope&); + + virtual void visit_edges(Cell::Visitor&) override; WorkerGlobalScope& m_global_scope; }; } + +WRAPPER_HACK(WorkerLocation, Web::HTML) diff --git a/Userland/Libraries/LibWeb/idl_files.cmake b/Userland/Libraries/LibWeb/idl_files.cmake index 20db0f4104..92833ff7ce 100644 --- a/Userland/Libraries/LibWeb/idl_files.cmake +++ b/Userland/Libraries/LibWeb/idl_files.cmake @@ -152,7 +152,7 @@ libweb_js_wrapper(HTML/SubmitEvent NO_INSTANCE) libweb_js_wrapper(HTML/TextMetrics NO_INSTANCE) libweb_js_wrapper(HTML/Worker NO_INSTANCE) libweb_js_wrapper(HTML/WorkerGlobalScope NO_INSTANCE) -libweb_js_wrapper(HTML/WorkerLocation) +libweb_js_wrapper(HTML/WorkerLocation NO_INSTANCE) libweb_js_wrapper(HTML/WorkerNavigator) libweb_js_wrapper(HighResolutionTime/Performance NO_INSTANCE) libweb_js_wrapper(IntersectionObserver/IntersectionObserver NO_INSTANCE) |