From 83554526f0488b063e0fff07f0fd11d86301e765 Mon Sep 17 00:00:00 2001 From: networkException Date: Sun, 2 Oct 2022 23:17:33 +0200 Subject: LibWeb: Allow all Script types to be used as [[HostDefined]] values This patch adds support for all child classes of Web::HTML::Script to be used in the [[HostDefined]] field of JS::Modules and JS::Scripts. --- Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp | 5 ----- Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.h | 5 +---- Userland/Libraries/LibWeb/HTML/Scripting/Script.cpp | 5 +++++ Userland/Libraries/LibWeb/HTML/Scripting/Script.h | 7 ++++++- 4 files changed, 12 insertions(+), 10 deletions(-) (limited to 'Userland/Libraries/LibWeb/HTML/Scripting') diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp index 7aef833c9e..7ac67f244d 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp @@ -166,9 +166,4 @@ void ClassicScript::visit_edges(Cell::Visitor& visitor) visitor.visit(m_script_record); } -void ClassicScript::visit_host_defined_self(Cell::Visitor& visitor) -{ - visitor.visit(this); -} - } diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.h b/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.h index 41004659c3..6780c656aa 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.h @@ -13,9 +13,7 @@ namespace Web::HTML { // https://html.spec.whatwg.org/multipage/webappapis.html#classic-script -class ClassicScript final - : public Script - , public JS::Script::HostDefined { +class ClassicScript final : public Script { JS_CELL(ClassicScript, Script); public: @@ -42,7 +40,6 @@ private: ClassicScript(AK::URL base_url, String filename, EnvironmentSettingsObject& environment_settings_object); virtual void visit_edges(Cell::Visitor&) override; - virtual void visit_host_defined_self(Cell::Visitor&) override; JS::GCPtr m_script_record; MutedErrors m_muted_errors { MutedErrors::No }; diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Script.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/Script.cpp index ae7371b007..72c13bd8f8 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/Script.cpp +++ b/Userland/Libraries/LibWeb/HTML/Scripting/Script.cpp @@ -17,4 +17,9 @@ Script::Script(AK::URL base_url, String filename, EnvironmentSettingsObject& env Script::~Script() = default; +void Script::visit_host_defined_self(JS::Cell::Visitor& visitor) +{ + visitor.visit(this); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Script.h b/Userland/Libraries/LibWeb/HTML/Scripting/Script.h index 862cee3763..b3a5a52e09 100644 --- a/Userland/Libraries/LibWeb/HTML/Scripting/Script.h +++ b/Userland/Libraries/LibWeb/HTML/Scripting/Script.h @@ -8,12 +8,15 @@ #include #include +#include #include namespace Web::HTML { // https://html.spec.whatwg.org/multipage/webappapis.html#concept-script -class Script : public JS::Cell { +class Script + : public JS::Cell + , public JS::Script::HostDefined { JS_CELL(Script, JS::Cell); public: @@ -28,6 +31,8 @@ protected: Script(AK::URL base_url, String filename, EnvironmentSettingsObject& environment_settings_object); private: + virtual void visit_host_defined_self(JS::Cell::Visitor&) override; + AK::URL m_base_url; String m_filename; EnvironmentSettingsObject& m_settings_object; -- cgit v1.2.3