mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-02 23:56:06 +00:00
WebContent: Added IPC calls for initializing JS console and sending input
This commit is contained in:
parent
225baa3cb7
commit
51f073ff39
Notes:
sideshowbarker
2024-07-18 21:51:54 +09:00
Author: https://github.com/xeons
Commit: 51f073ff39
Pull-request: https://github.com/SerenityOS/serenity/pull/5556
8 changed files with 272 additions and 1 deletions
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue