diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp index 078f8041b2..59e4ece875 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.cpp @@ -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(); diff --git a/Userland/Libraries/LibWebView/OutOfProcessWebView.h b/Userland/Libraries/LibWebView/OutOfProcessWebView.h index 8d5a379826..eb95879329 100644 --- a/Userland/Libraries/LibWebView/OutOfProcessWebView.h +++ b/Userland/Libraries/LibWebView/OutOfProcessWebView.h @@ -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 { diff --git a/Userland/Services/WebContent/ConnectionFromClient.cpp b/Userland/Services/WebContent/ConnectionFromClient.cpp index c48681b9f5..546ca2abf6 100644 --- a/Userland/Services/WebContent/ConnectionFromClient.cpp +++ b/Userland/Services/WebContent/ConnectionFromClient.cpp @@ -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()) { diff --git a/Userland/Services/WebContent/ConnectionFromClient.h b/Userland/Services/WebContent/ConnectionFromClient.h index c27294e840..3edf6cf432 100644 --- a/Userland/Services/WebContent/ConnectionFromClient.h +++ b/Userland/Services/WebContent/ConnectionFromClient.h @@ -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 const& pseudo_element) override; virtual Messages::WebContentServer::GetHoveredNodeIdResponse get_hovered_node_id() override; diff --git a/Userland/Services/WebContent/WebContentServer.ipc b/Userland/Services/WebContent/WebContentServer.ipc index cbd1830e4d..db011480a0 100644 --- a/Userland/Services/WebContent/WebContentServer.ipc +++ b/Userland/Services/WebContent/WebContentServer.ipc @@ -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 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)