2023-07-06 07:37:29 -04: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 20:39:18 +13:00
|
|
|
TemporaryExecutionContext::TemporaryExecutionContext(JS::Realm& realm, CallbacksEnabled callbacks_enabled)
|
2026-04-03 18:12:46 +02:00
|
|
|
: TemporaryExecutionContext(principal_realm_settings_object(realm), callbacks_enabled)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TemporaryExecutionContext::TemporaryExecutionContext(EnvironmentSettingsObject& settings, CallbacksEnabled callbacks_enabled)
|
|
|
|
|
: m_settings(settings)
|
2024-01-18 13:04:52 -07:00
|
|
|
, m_callbacks_enabled(callbacks_enabled)
|
2023-07-06 07:37:29 -04:00
|
|
|
{
|
2026-04-03 18:12:46 +02:00
|
|
|
prepare_to_run_script(m_settings);
|
2024-01-18 13:04:52 -07:00
|
|
|
if (m_callbacks_enabled == CallbacksEnabled::Yes)
|
2026-04-03 18:12:46 +02:00
|
|
|
prepare_to_run_callback(m_settings);
|
2023-07-06 07:37:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TemporaryExecutionContext::~TemporaryExecutionContext()
|
|
|
|
|
{
|
2026-04-03 18:12:46 +02:00
|
|
|
clean_up_after_running_script(m_settings);
|
2024-01-18 13:04:52 -07:00
|
|
|
if (m_callbacks_enabled == CallbacksEnabled::Yes)
|
2026-04-03 18:12:46 +02:00
|
|
|
clean_up_after_running_callback(m_settings);
|
2023-07-06 07:37:29 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|