1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +00:00

LibWebView+WebContent: Add a WebContent IPC to get a DOM node's HTML

This commit is contained in:
Timothy Flynn 2023-12-06 10:36:27 -05:00 committed by Andreas Kling
parent 8162dc5ee6
commit bea11f6d99
5 changed files with 22 additions and 0 deletions

View file

@ -38,6 +38,7 @@
#include <LibWeb/Loader/ContentFilter.h>
#include <LibWeb/Loader/ProxyMappings.h>
#include <LibWeb/Loader/ResourceLoader.h>
#include <LibWeb/Namespace.h>
#include <LibWeb/Painting/StackingContext.h>
#include <LibWeb/Painting/ViewportPaintable.h>
#include <LibWeb/PermissionsPolicy/AutoplayAllowlist.h>
@ -737,6 +738,19 @@ void ConnectionFromClient::remove_dom_node(i32 node_id)
active_document->force_layout();
}
Messages::WebContentServer::GetDomNodeHtmlResponse ConnectionFromClient::get_dom_node_html(i32 node_id)
{
auto* dom_node = Web::DOM::Node::from_unique_id(node_id);
if (!dom_node)
return OptionalNone {};
// FIXME: Implement Element's outerHTML attribute.
auto container = Web::DOM::create_element(dom_node->document(), Web::HTML::TagNames::div, Web::Namespace::HTML).release_value_but_fixme_should_propagate_errors();
container->append_child(dom_node->clone_node(nullptr, true)).release_value_but_fixme_should_propagate_errors();
return container->inner_html().release_value_but_fixme_should_propagate_errors();
}
void ConnectionFromClient::initialize_js_console(Badge<PageClient>, Web::DOM::Document& document)
{
auto& realm = document.realm();