WebContent: Use outerHTML to copy a DOM node's HTML in the Inspector

We can use outerHTML now instead of cloning the node into a temporary
container and invoking the container's innerHTML.
This commit is contained in:
Timothy Flynn 2024-04-09 18:25:46 -04:00 committed by Andreas Kling
commit 12b3332d3c
Notes: sideshowbarker 2024-07-17 03:27:40 +09:00

View file

@ -745,11 +745,18 @@ void ConnectionFromClient::get_dom_node_html(u64 page_id, i32 node_id)
if (!dom_node) if (!dom_node)
return; return;
// FIXME: Implement Element's outerHTML attribute. String html;
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(); if (dom_node->is_element()) {
auto const& element = static_cast<Web::DOM::Element const&>(*dom_node);
html = element.outer_html().release_value_but_fixme_should_propagate_errors();
} else if (dom_node->is_text() || dom_node->is_comment()) {
auto const& character_data = static_cast<Web::DOM::CharacterData const&>(*dom_node);
html = character_data.data();
} else {
return;
}
auto html = container->inner_html().release_value_but_fixme_should_propagate_errors();
async_did_get_dom_node_html(page_id, move(html)); async_did_get_dom_node_html(page_id, move(html));
} }