1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:47:35 +00:00

Ladybird: Fix build after LibWeb+LibJS GC changes

This commit is contained in:
Andreas Kling 2022-09-06 00:42:16 +02:00 committed by Andrew Kaster
parent 9789d8b769
commit dcab11f5e9
5 changed files with 27 additions and 28 deletions

View file

@ -12,28 +12,27 @@
#include "WebView.h"
#include <LibJS/Interpreter.h>
#include <LibJS/MarkupGenerator.h>
#include <LibWeb/Bindings/WindowObject.h>
#include <LibWeb/HTML/Scripting/ClassicScript.h>
#include <LibWeb/HTML/Scripting/Environments.h>
#include <LibWeb/HTML/Window.h>
namespace Ladybird {
ConsoleClient::ConsoleClient(JS::Console& console, WeakPtr<JS::Interpreter> interpreter, WebView& view)
ConsoleClient::ConsoleClient(JS::Console& console, JS::Realm& realm, WebView& view)
: JS::ConsoleClient(console)
, m_view(view)
, m_interpreter(interpreter)
, m_realm(realm)
{
JS::DeferGC defer_gc(m_interpreter->heap());
JS::DeferGC defer_gc(realm.heap());
auto& vm = m_interpreter->vm();
auto& realm = m_interpreter->realm();
auto& window = static_cast<Web::Bindings::WindowObject&>(realm.global_object());
auto& vm = realm.vm();
auto& window = static_cast<Web::HTML::Window&>(realm.global_object());
auto console_global_object = m_interpreter->heap().allocate_without_realm<ConsoleGlobalObject>(realm, window);
auto console_global_object = realm.heap().allocate_without_realm<ConsoleGlobalObject>(realm, window);
// NOTE: We need to push an execution context here for NativeFunction::create() to succeed during global object initialization.
// It gets removed immediately after creating the interpreter in Document::interpreter().
auto& eso = verify_cast<Web::HTML::EnvironmentSettingsObject>(*m_interpreter->realm().host_defined());
auto& eso = verify_cast<Web::HTML::EnvironmentSettingsObject>(*realm.host_defined());
vm.push_execution_context(eso.realm_execution_context());
console_global_object->initialize(realm);
vm.pop_execution_context();
@ -43,7 +42,10 @@ ConsoleClient::ConsoleClient(JS::Console& console, WeakPtr<JS::Interpreter> inte
void ConsoleClient::handle_input(String const& js_source)
{
auto& settings = verify_cast<Web::HTML::EnvironmentSettingsObject>(*m_interpreter->realm().host_defined());
if (!m_realm)
return;
auto& settings = verify_cast<Web::HTML::EnvironmentSettingsObject>(*m_realm->host_defined());
auto script = Web::HTML::ClassicScript::create("(console)", js_source, settings, settings.api_base_url());
// FIXME: Add parse error printouts back once ClassicScript can report parse errors.