2021-09-09 13:03:01 -03:00
|
|
|
/*
|
2024-10-04 08:19:50 -03:00
|
|
|
* Copyright (c) 2021-2023, Andreas Kling <andreas@ladybird.org>
|
2021-09-09 13:03:01 -03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
2023-02-25 14:42:45 -03:00
|
|
|
#include <LibWeb/HTML/Scripting/Environments.h>
|
2021-09-09 13:03:01 -03:00
|
|
|
#include <LibWeb/HTML/Scripting/Script.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
GC_DEFINE_ALLOCATOR(Script);
|
2023-11-19 15:47:52 -03:00
|
|
|
|
2024-10-25 00:27:26 -03:00
|
|
|
Script::Script(URL::URL base_url, ByteString filename, JS::Realm& realm)
|
2021-09-09 13:03:01 -03:00
|
|
|
: m_base_url(move(base_url))
|
2021-09-10 19:30:06 -03:00
|
|
|
, m_filename(move(filename))
|
2024-10-25 00:27:26 -03:00
|
|
|
, m_realm(realm)
|
2021-09-09 13:03:01 -03:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-14 16:21:51 -03:00
|
|
|
Script::~Script() = default;
|
2021-09-09 13:03:01 -03:00
|
|
|
|
2024-10-25 00:27:26 -03: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 18:17:33 -03:00
|
|
|
void Script::visit_host_defined_self(JS::Cell::Visitor& visitor)
|
|
|
|
|
{
|
2023-11-19 00:18:00 -03:00
|
|
|
visitor.visit(*this);
|
2022-10-02 18:17:33 -03:00
|
|
|
}
|
|
|
|
|
|
2023-05-18 14:05:56 -03:00
|
|
|
void Script::visit_edges(Visitor& visitor)
|
|
|
|
|
{
|
|
|
|
|
Base::visit_edges(visitor);
|
2024-10-25 00:27:26 -03:00
|
|
|
visitor.visit(m_realm);
|
2023-05-18 14:05:56 -03:00
|
|
|
visitor.visit(m_parse_error);
|
|
|
|
|
visitor.visit(m_error_to_rethrow);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-09 13:03:01 -03:00
|
|
|
}
|