summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorBrandon Scott <xeons@users.noreply.github.com>2021-02-27 21:47:14 -0600
committerAndreas Kling <kling@serenityos.org>2021-02-28 15:30:17 +0100
commit0682af7b65cdfd63425afc340860c92bb3398348 (patch)
treeda9b7e50714812238a9a6da3c71277e8e18af1d4 /Userland/Libraries
parent51f073ff396bbc36aa92bb958dd3b414d6ed4e62 (diff)
downloadserenity-0682af7b65cdfd63425afc340860c92bb3398348.zip
LibWeb: Add in all of the plumbing required to use the JS console over IPC
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/OutOfProcessWebView.cpp16
-rw-r--r--Userland/Libraries/LibWeb/OutOfProcessWebView.h3
-rw-r--r--Userland/Libraries/LibWeb/WebContentClient.cpp5
-rw-r--r--Userland/Libraries/LibWeb/WebContentClient.h3
-rw-r--r--Userland/Libraries/LibWeb/WebViewHooks.h1
5 files changed, 27 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp
index df60760b4b..477a083d9e 100644
--- a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp
+++ b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp
@@ -320,6 +320,12 @@ void OutOfProcessWebView::notify_server_did_get_source(const URL& url, const Str
on_get_source(url, source);
}
+void OutOfProcessWebView::notify_server_did_js_console_output(const String& method, const String& line)
+{
+ if (on_js_console_output)
+ on_js_console_output(method, line);
+}
+
void OutOfProcessWebView::did_scroll()
{
client().post_message(Messages::WebContentServer::SetViewportRect(visible_content_rect()));
@@ -351,4 +357,14 @@ void OutOfProcessWebView::get_source()
client().post_message(Messages::WebContentServer::GetSource());
}
+void OutOfProcessWebView::js_console_initialize()
+{
+ client().post_message(Messages::WebContentServer::JSConsoleInitialize());
+}
+
+void OutOfProcessWebView::js_console_input(const String& js_source)
+{
+ client().post_message(Messages::WebContentServer::JSConsoleInput(js_source));
+}
+
}
diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.h b/Userland/Libraries/LibWeb/OutOfProcessWebView.h
index 1c243abd5a..47b2c49547 100644
--- a/Userland/Libraries/LibWeb/OutOfProcessWebView.h
+++ b/Userland/Libraries/LibWeb/OutOfProcessWebView.h
@@ -51,6 +51,8 @@ public:
void debug_request(const String& request, const String& argument = {});
void get_source();
+ void js_console_initialize();
+ void js_console_input(const String& js_source);
void notify_server_did_layout(Badge<WebContentClient>, const Gfx::IntSize& content_size);
void notify_server_did_paint(Badge<WebContentClient>, i32 bitmap_id);
@@ -70,6 +72,7 @@ public:
bool notify_server_did_request_confirm(Badge<WebContentClient>, const String& message);
String notify_server_did_request_prompt(Badge<WebContentClient>, const String& message, const String& default_);
void notify_server_did_get_source(const URL& url, const String& source);
+ void notify_server_did_js_console_output(const String& method, const String& line);
private:
OutOfProcessWebView();
diff --git a/Userland/Libraries/LibWeb/WebContentClient.cpp b/Userland/Libraries/LibWeb/WebContentClient.cpp
index ed947be896..5be96ef663 100644
--- a/Userland/Libraries/LibWeb/WebContentClient.cpp
+++ b/Userland/Libraries/LibWeb/WebContentClient.cpp
@@ -136,6 +136,11 @@ void WebContentClient::handle(const Messages::WebContentClient::DidGetSource& me
m_view.notify_server_did_get_source(message.url(), message.source());
}
+void WebContentClient::handle(const Messages::WebContentClient::DidJSConsoleOutput& message)
+{
+ m_view.notify_server_did_js_console_output(message.method(), message.line());
+}
+
OwnPtr<Messages::WebContentClient::DidRequestAlertResponse> WebContentClient::handle(const Messages::WebContentClient::DidRequestAlert& message)
{
m_view.notify_server_did_request_alert({}, message.message());
diff --git a/Userland/Libraries/LibWeb/WebContentClient.h b/Userland/Libraries/LibWeb/WebContentClient.h
index 513c4b5afd..894e752e44 100644
--- a/Userland/Libraries/LibWeb/WebContentClient.h
+++ b/Userland/Libraries/LibWeb/WebContentClient.h
@@ -64,7 +64,8 @@ private:
virtual void handle(const Messages::WebContentClient::DidStartLoading&) override;
virtual void handle(const Messages::WebContentClient::DidRequestContextMenu&) override;
virtual void handle(const Messages::WebContentClient::DidRequestLinkContextMenu&) override;
- virtual void handle(const Messages::WebContentClient::DidGetSource& message);
+ virtual void handle(const Messages::WebContentClient::DidGetSource&) override;
+ virtual void handle(const Messages::WebContentClient::DidJSConsoleOutput&) override;
virtual OwnPtr<Messages::WebContentClient::DidRequestAlertResponse> handle(const Messages::WebContentClient::DidRequestAlert&) override;
virtual OwnPtr<Messages::WebContentClient::DidRequestConfirmResponse> handle(const Messages::WebContentClient::DidRequestConfirm&) override;
virtual OwnPtr<Messages::WebContentClient::DidRequestPromptResponse> handle(const Messages::WebContentClient::DidRequestPrompt&) override;
diff --git a/Userland/Libraries/LibWeb/WebViewHooks.h b/Userland/Libraries/LibWeb/WebViewHooks.h
index 4ab97527c3..dd5c5d57fc 100644
--- a/Userland/Libraries/LibWeb/WebViewHooks.h
+++ b/Userland/Libraries/LibWeb/WebViewHooks.h
@@ -47,6 +47,7 @@ public:
Function<void(const URL&)> on_url_drop;
Function<void(DOM::Document*)> on_set_document;
Function<void(const URL&, const String&)> on_get_source;
+ Function<void(const String& method, const String& line)> on_js_console_output;
};
}