LibWeb: Add in all of the plumbing required to use the JS console over IPC

This commit is contained in:
Brandon Scott 2021-02-27 21:47:14 -06:00 committed by Andreas Kling
parent 51f073ff39
commit 0682af7b65
5 changed files with 27 additions and 1 deletions

View file

@ -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));
}
}

View file

@ -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();

View file

@ -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());

View file

@ -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;

View file

@ -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;
};
}