From 0682af7b65cdfd63425afc340860c92bb3398348 Mon Sep 17 00:00:00 2001 From: Brandon Scott Date: Sat, 27 Feb 2021 21:47:14 -0600 Subject: LibWeb: Add in all of the plumbing required to use the JS console over IPC --- Userland/Libraries/LibWeb/OutOfProcessWebView.cpp | 16 ++++++++++++++++ Userland/Libraries/LibWeb/OutOfProcessWebView.h | 3 +++ Userland/Libraries/LibWeb/WebContentClient.cpp | 5 +++++ Userland/Libraries/LibWeb/WebContentClient.h | 3 ++- Userland/Libraries/LibWeb/WebViewHooks.h | 1 + 5 files changed, 27 insertions(+), 1 deletion(-) 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, const Gfx::IntSize& content_size); void notify_server_did_paint(Badge, i32 bitmap_id); @@ -70,6 +72,7 @@ public: bool notify_server_did_request_confirm(Badge, const String& message); String notify_server_did_request_prompt(Badge, 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 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 handle(const Messages::WebContentClient::DidRequestAlert&) override; virtual OwnPtr handle(const Messages::WebContentClient::DidRequestConfirm&) override; virtual OwnPtr 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 on_url_drop; Function on_set_document; Function on_get_source; + Function on_js_console_output; }; } -- cgit v1.2.3