summaryrefslogtreecommitdiff
path: root/Userland/Services/WebContent
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2021-09-04 11:14:25 +0100
committerAndreas Kling <kling@serenityos.org>2021-09-06 18:20:26 +0200
commitc619a57cf8f0d38c5acd71d6ae221b57b015a249 (patch)
treea8e2cc97241beccef0b33db03fe6a4a07f29efa2 /Userland/Services/WebContent
parent5220d6d2e50ce9ab7e5238a080438dea5d3d6656 (diff)
downloadserenity-c619a57cf8f0d38c5acd71d6ae221b57b015a249.zip
LibWeb+WebContent: Add new console-message IPC calls
This patch introduces three new IPC calls for WebContent: - `Client::did_output_js_console_message(index)`: Notifies the client that a new console message was logged. - `Server::js_console_request_messages(start_index)`: Ask the server for console messages starting at the given index. - `Client::did_get_js_console_messages(start_index, types, messages)`: Send the client the messages they requested. This mechanism will replace the current `Client::did_js_console_output()` call in the next few commits. This will allow us to display messages in the console that happened before the console was opened.
Diffstat (limited to 'Userland/Services/WebContent')
-rw-r--r--Userland/Services/WebContent/ClientConnection.cpp17
-rw-r--r--Userland/Services/WebContent/ClientConnection.h5
-rw-r--r--Userland/Services/WebContent/WebContentClient.ipc4
-rw-r--r--Userland/Services/WebContent/WebContentServer.ipc1
4 files changed, 27 insertions, 0 deletions
diff --git a/Userland/Services/WebContent/ClientConnection.cpp b/Userland/Services/WebContent/ClientConnection.cpp
index 031ae6307b..7d9064ad04 100644
--- a/Userland/Services/WebContent/ClientConnection.cpp
+++ b/Userland/Services/WebContent/ClientConnection.cpp
@@ -283,6 +283,18 @@ void ClientConnection::js_console_initialize()
}
}
+void ClientConnection::initialize_js_console(Badge<PageHost>)
+{
+ auto* document = page().top_level_browsing_context().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::js_console_input(const String& js_source)
{
if (m_console_client)
@@ -306,6 +318,11 @@ void ClientConnection::run_javascript(String const& js_source)
}
}
+void ClientConnection::js_console_request_messages(i32)
+{
+ TODO();
+}
+
Messages::WebContentServer::GetSelectedTextResponse ClientConnection::get_selected_text()
{
return page().focused_context().selected_text();
diff --git a/Userland/Services/WebContent/ClientConnection.h b/Userland/Services/WebContent/ClientConnection.h
index f4b6494048..77232f1ba4 100644
--- a/Userland/Services/WebContent/ClientConnection.h
+++ b/Userland/Services/WebContent/ClientConnection.h
@@ -29,6 +29,8 @@ public:
virtual void die() override;
+ void initialize_js_console(Badge<PageHost>);
+
private:
Web::Page& page();
const Web::Page& page() const;
@@ -52,9 +54,12 @@ private:
virtual void inspect_dom_tree() override;
virtual Messages::WebContentServer::InspectDomNodeResponse inspect_dom_node(i32) override;
virtual Messages::WebContentServer::GetHoveredNodeIdResponse get_hovered_node_id() override;
+
virtual void js_console_initialize() override;
virtual void js_console_input(String const&) override;
virtual void run_javascript(String const&) override;
+ virtual void js_console_request_messages(i32) override;
+
virtual Messages::WebContentServer::GetSelectedTextResponse get_selected_text() override;
virtual void select_all() override;
diff --git a/Userland/Services/WebContent/WebContentClient.ipc b/Userland/Services/WebContent/WebContentClient.ipc
index d5ea58a09d..ca1edbdb36 100644
--- a/Userland/Services/WebContent/WebContentClient.ipc
+++ b/Userland/Services/WebContent/WebContentClient.ipc
@@ -33,4 +33,8 @@ endpoint WebContentClient
did_change_favicon(Gfx::ShareableBitmap favicon) =|
did_request_cookie(URL url, u8 source) => (String cookie)
did_set_cookie(URL url, Web::Cookie::ParsedCookie cookie, u8 source) =|
+
+ did_output_js_console_message(i32 message_index) =|
+ did_get_js_console_messages(i32 start_index, Vector<String> message_types, Vector<String> messages) =|
+
}
diff --git a/Userland/Services/WebContent/WebContentServer.ipc b/Userland/Services/WebContent/WebContentServer.ipc
index fd84e456c0..23da9c81c1 100644
--- a/Userland/Services/WebContent/WebContentServer.ipc
+++ b/Userland/Services/WebContent/WebContentServer.ipc
@@ -31,6 +31,7 @@ endpoint WebContentServer
get_hovered_node_id() => (i32 node_id)
js_console_initialize() =|
js_console_input(String js_source) =|
+ js_console_request_messages(i32 start_index) =|
run_javascript(String js_source) =|