1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:27:35 +00:00

LibWeb+WebContent: Add IPC flow for Inspect DOM Tree

Add `inspect_dom_tree` to WebContentServer and 'did_get_dom_tree' to
WebContentClient.

These two async methods form a request & response for requesting a JSON
representation of the Content's DOM tree.
This commit is contained in:
Adam Hodgen 2021-06-07 16:35:10 +01:00 committed by Andreas Kling
parent 4affe052b8
commit cd6b9613c5
9 changed files with 31 additions and 0 deletions

View file

@ -335,6 +335,12 @@ void OutOfProcessWebView::notify_server_did_get_source(const URL& url, const Str
on_get_source(url, source);
}
void OutOfProcessWebView::notify_server_did_get_dom_tree(const String& dom_tree)
{
if (on_get_dom_tree)
on_get_dom_tree(dom_tree);
}
void OutOfProcessWebView::notify_server_did_js_console_output(const String& method, const String& line)
{
if (on_js_console_output)
@ -391,6 +397,11 @@ void OutOfProcessWebView::get_source()
client().async_get_source();
}
void OutOfProcessWebView::inspect_dom_tree()
{
client().async_inspect_dom_tree();
}
void OutOfProcessWebView::js_console_initialize()
{
client().async_js_console_initialize();

View file

@ -31,6 +31,7 @@ public:
void debug_request(const String& request, const String& argument = {});
void get_source();
void inspect_dom_tree();
void js_console_initialize();
void js_console_input(const String& js_source);
@ -57,6 +58,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_get_dom_tree(const String& dom_tree);
void notify_server_did_js_console_output(const String& method, const String& line);
void notify_server_did_change_favicon(const Gfx::Bitmap& favicon);
String notify_server_did_request_cookie(Badge<WebContentClient>, const URL& url, Cookie::Source source);

View file

@ -136,6 +136,11 @@ void WebContentClient::did_get_source(URL const& url, String const& source)
m_view.notify_server_did_get_source(url, source);
}
void WebContentClient::did_get_dom_tree(const String& dom_tree)
{
m_view.notify_server_did_get_dom_tree(dom_tree);
}
void WebContentClient::did_js_console_output(String const& method, String const& line)
{
m_view.notify_server_did_js_console_output(method, line);

View file

@ -49,6 +49,7 @@ private:
virtual void did_request_link_context_menu(Gfx::IntPoint const&, URL const&, String const&, unsigned) override;
virtual void did_request_image_context_menu(Gfx::IntPoint const&, URL const&, String const&, unsigned, Gfx::ShareableBitmap const&) override;
virtual void did_get_source(URL const&, String const&) override;
virtual void did_get_dom_tree(String const&) override;
virtual void did_js_console_output(String const&, String const&) override;
virtual void did_change_favicon(Gfx::ShareableBitmap const&) override;
virtual void did_request_alert(String const&) override;

View file

@ -27,6 +27,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&)> on_get_dom_tree;
Function<void(const String& method, const String& line)> on_js_console_output;
Function<String(const URL& url, Cookie::Source source)> on_get_cookie;
Function<void(const URL& url, const Cookie::ParsedCookie& cookie, Cookie::Source source)> on_set_cookie;