1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 04:57:44 +00:00

WebContent: Added IPC calls for initializing JS console and sending input

This commit is contained in:
Brandon Scott 2021-02-27 21:44:49 -06:00 committed by Andreas Kling
parent 225baa3cb7
commit 51f073ff39
8 changed files with 272 additions and 1 deletions

View file

@ -28,7 +28,10 @@
#include <AK/Debug.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/SystemTheme.h>
#include <LibJS/Console.h>
#include <LibJS/Heap/Heap.h>
#include <LibJS/Interpreter.h>
#include <LibJS/Parser.h>
#include <LibJS/Runtime/VM.h>
#include <LibWeb/Bindings/MainThreadVM.h>
#include <LibWeb/DOM/Document.h>
@ -216,4 +219,23 @@ void ClientConnection::handle(const Messages::WebContentServer::GetSource&)
}
}
void ClientConnection::handle(const Messages::WebContentServer::JSConsoleInitialize&)
{
if (auto* document = page().main_frame().document()) {
auto interpreter = document->interpreter().make_weak_ptr();
if (m_interpreter.ptr() == interpreter.ptr())
return;
m_interpreter = interpreter;
m_console_client = make<WebContentConsoleClient>(interpreter->global_object().console(), interpreter, *this);
interpreter->global_object().console().set_client(*m_console_client.ptr());
}
}
void ClientConnection::handle(const Messages::WebContentServer::JSConsoleInput& message)
{
if (m_console_client)
m_console_client->handle_input(message.js_source());
}
}