2023-07-06 08:37:29 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <LibWeb/HTML/Scripting/Environments.h>
|
|
|
|
|
#include <LibWeb/HTML/Scripting/TemporaryExecutionContext.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
|
2024-10-24 04:39:18 -03:00
|
|
|
TemporaryExecutionContext::TemporaryExecutionContext(JS::Realm& realm, CallbacksEnabled callbacks_enabled)
|
2026-04-03 13:12:46 -03:00
|
|
|
: TemporaryExecutionContext(principal_realm_settings_object(realm), callbacks_enabled)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TemporaryExecutionContext::TemporaryExecutionContext(EnvironmentSettingsObject& settings, CallbacksEnabled callbacks_enabled)
|
|
|
|
|
: m_settings(settings)
|
2024-01-18 17:04:52 -03:00
|
|
|
, m_callbacks_enabled(callbacks_enabled)
|
2023-07-06 08:37:29 -03:00
|
|
|
{
|
2026-04-03 13:12:46 -03:00
|
|
|
prepare_to_run_script(m_settings);
|
2024-01-18 17:04:52 -03:00
|
|
|
if (m_callbacks_enabled == CallbacksEnabled::Yes)
|
2026-04-03 13:12:46 -03:00
|
|
|
prepare_to_run_callback(m_settings);
|
2023-07-06 08:37:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TemporaryExecutionContext::~TemporaryExecutionContext()
|
|
|
|
|
{
|
2026-04-03 13:12:46 -03:00
|
|
|
clean_up_after_running_script(m_settings);
|
2024-01-18 17:04:52 -03:00
|
|
|
if (m_callbacks_enabled == CallbacksEnabled::Yes)
|
2026-04-03 13:12:46 -03:00
|
|
|
clean_up_after_running_callback(m_settings);
|
2023-07-06 08:37:29 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|