1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:57:44 +00:00

LibWebView+WebContent: Add a WebContent IPC to remove a DOM node

The FIXME added to ConnectionFromClient::remove_dom_node is copied from
Web::EditEventHandler. The same behavior is observed here, with many
lingering Layout::TextNodes, for example.
This commit is contained in:
Timothy Flynn 2023-12-05 14:59:54 -05:00 committed by Andreas Kling
parent 86d90f324d
commit 777b4f7921
5 changed files with 26 additions and 0 deletions

View file

@ -711,6 +711,24 @@ void ConnectionFromClient::replace_dom_node_attribute(i32 node_id, String const&
element.set_attribute(attribute.name, attribute.value).release_value_but_fixme_should_propagate_errors();
}
void ConnectionFromClient::remove_dom_node(i32 node_id)
{
auto* active_document = page().page().top_level_browsing_context().active_document();
if (!active_document)
return;
auto* dom_node = Web::DOM::Node::from_unique_id(node_id);
if (!dom_node)
return;
dom_node->remove();
// FIXME: When nodes are removed from the DOM, the associated layout nodes become stale and still
// remain in the layout tree. This has to be fixed, this just causes everything to be recomputed
// which really hurts performance.
active_document->force_layout();
}
void ConnectionFromClient::initialize_js_console(Badge<PageClient>, Web::DOM::Document& document)
{
auto& realm = document.realm();