1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 22:07:34 +00:00

LibWebView+WebContent: Add IPC to run the fragment serialization steps

This commit is contained in:
Timothy Flynn 2022-11-02 20:55:16 -04:00 committed by Linus Groh
parent 13b8eeff54
commit 82af1557dd
5 changed files with 22 additions and 0 deletions

View file

@ -447,6 +447,11 @@ void OutOfProcessWebView::get_source()
client().async_get_source();
}
String OutOfProcessWebView::serialize_source()
{
return client().serialize_source();
}
void OutOfProcessWebView::inspect_dom_tree()
{
client().async_inspect_dom_tree();

View file

@ -37,6 +37,7 @@ public:
void debug_request(String const& request, String const& argument = {});
void get_source();
String serialize_source();
void inspect_dom_tree();
struct DOMNodeProperties {

View file

@ -257,6 +257,20 @@ void ConnectionFromClient::get_source()
}
}
Messages::WebContentServer::SerializeSourceResponse ConnectionFromClient::serialize_source()
{
if (auto* doc = page().top_level_browsing_context().active_document()) {
auto result = doc->serialize_fragment(Web::DOMParsing::RequireWellFormed::Yes);
if (!result.is_error())
return { result.release_value() };
auto source = MUST(doc->serialize_fragment(Web::DOMParsing::RequireWellFormed::No));
return { move(source) };
}
return { {} };
}
void ConnectionFromClient::inspect_dom_tree()
{
if (auto* doc = page().top_level_browsing_context().active_document()) {

View file

@ -62,6 +62,7 @@ private:
virtual void remove_backing_store(i32) override;
virtual void debug_request(String const&, String const&) override;
virtual void get_source() override;
virtual Messages::WebContentServer::SerializeSourceResponse serialize_source() override;
virtual void inspect_dom_tree() override;
virtual Messages::WebContentServer::InspectDomNodeResponse inspect_dom_node(i32 node_id, Optional<Web::CSS::Selector::PseudoElement> const& pseudo_element) override;
virtual Messages::WebContentServer::GetHoveredNodeIdResponse get_hovered_node_id() override;

View file

@ -32,6 +32,7 @@ endpoint WebContentServer
debug_request(String request, String argument) =|
get_source() =|
serialize_source() => (String source)
inspect_dom_tree() =|
inspect_dom_node(i32 node_id, Optional<Web::CSS::Selector::PseudoElement> pseudo_element) => (bool has_style, String specified_style, String computed_style, String custom_properties, String node_box_sizing)
get_hovered_node_id() => (i32 node_id)