summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp20
-rw-r--r--Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.h3
-rw-r--r--Userland/Libraries/LibWeb/HTML/Scripting/Script.cpp3
-rw-r--r--Userland/Libraries/LibWeb/HTML/Scripting/Script.h6
4 files changed, 17 insertions, 15 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp
index 7b85e2c752..546d6387de 100644
--- a/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp
@@ -71,17 +71,18 @@ NonnullRefPtr<ClassicScript> ClassicScript::create(String filename, StringView s
// https://html.spec.whatwg.org/multipage/webappapis.html#run-a-classic-script
JS::Completion ClassicScript::run(RethrowErrors rethrow_errors)
{
- auto& global_object = m_settings_object.global_object();
+ auto& global_object = settings_object().global_object();
auto& vm = global_object.vm();
- // 1. Let settings be the settings object of script. (NOTE: Not necessary)
+ // 1. Let settings be the settings object of script.
+ auto& settings = settings_object();
// 2. Check if we can run script with settings. If this returns "do not run" then return NormalCompletion(empty).
- if (m_settings_object.can_run_script() == RunScriptDecision::DoNotRun)
+ if (settings.can_run_script() == RunScriptDecision::DoNotRun)
return JS::normal_completion({});
// 3. Prepare to run script given settings.
- m_settings_object.prepare_to_run_script();
+ settings.prepare_to_run_script();
// 4. Let evaluationStatus be null.
JS::Completion evaluation_status;
@@ -107,7 +108,7 @@ JS::Completion ClassicScript::run(RethrowErrors rethrow_errors)
// 1. If rethrow errors is true and script's muted errors is false, then:
if (rethrow_errors == RethrowErrors::Yes && m_muted_errors == MutedErrors::No) {
// 1. Clean up after running script with settings.
- m_settings_object.clean_up_after_running_script();
+ settings.clean_up_after_running_script();
// 2. Rethrow evaluationStatus.[[Value]].
return JS::throw_completion(*evaluation_status.value());
@@ -116,7 +117,7 @@ JS::Completion ClassicScript::run(RethrowErrors rethrow_errors)
// 2. If rethrow errors is true and script's muted errors is true, then:
if (rethrow_errors == RethrowErrors::Yes && m_muted_errors == MutedErrors::Yes) {
// 1. Clean up after running script with settings.
- m_settings_object.clean_up_after_running_script();
+ settings.clean_up_after_running_script();
// 2. Throw a "NetworkError" DOMException.
return Bindings::throw_dom_exception_if_needed(global_object, [] {
@@ -131,14 +132,14 @@ JS::Completion ClassicScript::run(RethrowErrors rethrow_errors)
report_exception(evaluation_status);
// 2. Clean up after running script with settings.
- m_settings_object.clean_up_after_running_script();
+ settings.clean_up_after_running_script();
// 3. Return evaluationStatus.
return evaluation_status;
}
// 8. Clean up after running script with settings.
- m_settings_object.clean_up_after_running_script();
+ settings.clean_up_after_running_script();
// 9. If evaluationStatus is a normal completion, then return evaluationStatus.
VERIFY(!evaluation_status.is_abrupt());
@@ -149,8 +150,7 @@ JS::Completion ClassicScript::run(RethrowErrors rethrow_errors)
}
ClassicScript::ClassicScript(AK::URL base_url, String filename, EnvironmentSettingsObject& environment_settings_object)
- : Script(move(base_url), move(filename))
- , m_settings_object(environment_settings_object)
+ : Script(move(base_url), move(filename), environment_settings_object)
{
}
diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.h b/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.h
index 18ae0e49b7..7d092c33b4 100644
--- a/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.h
+++ b/Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.h
@@ -28,8 +28,6 @@ public:
JS::Script* script_record() { return m_script_record; }
JS::Script const* script_record() const { return m_script_record; }
- EnvironmentSettingsObject& settings_object() { return m_settings_object; }
-
enum class RethrowErrors {
No,
Yes,
@@ -41,7 +39,6 @@ public:
private:
ClassicScript(AK::URL base_url, String filename, EnvironmentSettingsObject& environment_settings_object);
- EnvironmentSettingsObject& m_settings_object;
RefPtr<JS::Script> m_script_record;
MutedErrors m_muted_errors { MutedErrors::No };
Optional<JS::Parser::Error> m_error_to_rethrow;
diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Script.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/Script.cpp
index ac89905577..ae7371b007 100644
--- a/Userland/Libraries/LibWeb/HTML/Scripting/Script.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Scripting/Script.cpp
@@ -8,9 +8,10 @@
namespace Web::HTML {
-Script::Script(AK::URL base_url, String filename)
+Script::Script(AK::URL base_url, String filename, EnvironmentSettingsObject& environment_settings_object)
: m_base_url(move(base_url))
, m_filename(move(filename))
+ , m_settings_object(environment_settings_object)
{
}
diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Script.h b/Userland/Libraries/LibWeb/HTML/Scripting/Script.h
index 36f5885717..f80c052cb1 100644
--- a/Userland/Libraries/LibWeb/HTML/Scripting/Script.h
+++ b/Userland/Libraries/LibWeb/HTML/Scripting/Script.h
@@ -8,6 +8,7 @@
#include <AK/RefCounted.h>
#include <AK/URL.h>
+#include <LibWeb/Forward.h>
namespace Web::HTML {
@@ -19,12 +20,15 @@ public:
AK::URL const& base_url() const { return m_base_url; }
String const& filename() const { return m_filename; }
+ EnvironmentSettingsObject& settings_object() { return m_settings_object; }
+
protected:
- Script(AK::URL base_url, String filename);
+ Script(AK::URL base_url, String filename, EnvironmentSettingsObject& environment_settings_object);
private:
AK::URL m_base_url;
String m_filename;
+ EnvironmentSettingsObject& m_settings_object;
};
}