2021-09-09 18:03:01 +02:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2021-2023, Andreas Kling <andreas@ladybird.org>
|
2021-09-09 18:03:01 +02:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
2023-02-25 10:42:45 -07:00
|
|
|
#include <LibWeb/HTML/Scripting/Environments.h>
|
2021-09-09 18:03:01 +02:00
|
|
|
#include <LibWeb/HTML/Scripting/Script.h>
|
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
2023-11-19 19:47:52 +01:00
|
|
|
JS_DEFINE_ALLOCATOR(Script);
|
|
|
|
|
2024-10-25 16:27:26 +13:00
|
|
|
Script::Script(URL::URL base_url, ByteString filename, JS::Realm& realm)
|
2021-09-09 18:03:01 +02:00
|
|
|
: m_base_url(move(base_url))
|
2021-09-11 00:30:06 +02:00
|
|
|
, m_filename(move(filename))
|
2024-10-25 16:27:26 +13:00
|
|
|
, m_realm(realm)
|
2021-09-09 18:03:01 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-03-14 13:21:51 -06:00
|
|
|
Script::~Script() = default;
|
2021-09-09 18:03:01 +02:00
|
|
|
|
2024-10-25 16:27:26 +13:00
|
|
|
// https://whatpr.org/html/9893/webappapis.html#settings-object
|
|
|
|
EnvironmentSettingsObject& Script::settings_object()
|
|
|
|
{
|
|
|
|
// The settings object of a script is the settings object of the principal realm of the script's realm.
|
|
|
|
return principal_realm_settings_object(principal_realm(realm()));
|
|
|
|
}
|
|
|
|
|
2022-10-02 23:17:33 +02:00
|
|
|
void Script::visit_host_defined_self(JS::Cell::Visitor& visitor)
|
|
|
|
{
|
2023-11-19 16:18:00 +13:00
|
|
|
visitor.visit(*this);
|
2022-10-02 23:17:33 +02:00
|
|
|
}
|
|
|
|
|
2023-05-18 19:05:56 +02:00
|
|
|
void Script::visit_edges(Visitor& visitor)
|
|
|
|
{
|
|
|
|
Base::visit_edges(visitor);
|
2024-10-25 16:27:26 +13:00
|
|
|
visitor.visit(m_realm);
|
2023-05-18 19:05:56 +02:00
|
|
|
visitor.visit(m_parse_error);
|
|
|
|
visitor.visit(m_error_to_rethrow);
|
|
|
|
}
|
|
|
|
|
2021-09-09 18:03:01 +02:00
|
|
|
}
|