mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
LibWebView+WebContent: Add a WebContent IPC to clone a DOM node
This commit is contained in:
parent
111e53a2f6
commit
c6a11a77b5
5 changed files with 20 additions and 0 deletions
|
@ -211,6 +211,11 @@ Optional<i32> ViewImplementation::create_child_text_node(i32 node_id)
|
|||
return client().create_child_text_node(node_id);
|
||||
}
|
||||
|
||||
Optional<i32> ViewImplementation::clone_dom_node(i32 node_id)
|
||||
{
|
||||
return client().clone_dom_node(node_id);
|
||||
}
|
||||
|
||||
void ViewImplementation::remove_dom_node(i32 node_id)
|
||||
{
|
||||
client().async_remove_dom_node(node_id);
|
||||
|
|
|
@ -69,6 +69,7 @@ public:
|
|||
void replace_dom_node_attribute(i32 node_id, String name, Vector<Attribute> replacement_attributes);
|
||||
Optional<i32> create_child_element(i32 node_id);
|
||||
Optional<i32> create_child_text_node(i32 node_id);
|
||||
Optional<i32> clone_dom_node(i32 node_id);
|
||||
void remove_dom_node(i32 node_id);
|
||||
Optional<String> get_dom_node_html(i32 node_id);
|
||||
|
||||
|
|
|
@ -745,6 +745,18 @@ Messages::WebContentServer::CreateChildTextNodeResponse ConnectionFromClient::cr
|
|||
return text_node->unique_id();
|
||||
}
|
||||
|
||||
Messages::WebContentServer::CloneDomNodeResponse ConnectionFromClient::clone_dom_node(i32 node_id)
|
||||
{
|
||||
auto* dom_node = Web::DOM::Node::from_unique_id(node_id);
|
||||
if (!dom_node || !dom_node->parent_node())
|
||||
return OptionalNone {};
|
||||
|
||||
auto dom_node_clone = dom_node->clone_node(nullptr, true);
|
||||
dom_node->parent_node()->insert_before(dom_node_clone, dom_node->next_sibling());
|
||||
|
||||
return dom_node_clone->unique_id();
|
||||
}
|
||||
|
||||
void ConnectionFromClient::remove_dom_node(i32 node_id)
|
||||
{
|
||||
auto* active_document = page().page().top_level_browsing_context().active_document();
|
||||
|
|
|
@ -82,6 +82,7 @@ private:
|
|||
virtual void replace_dom_node_attribute(i32 node_id, String const& name, Vector<WebView::Attribute> const& replacement_attributes) override;
|
||||
virtual Messages::WebContentServer::CreateChildElementResponse create_child_element(i32 node_id) override;
|
||||
virtual Messages::WebContentServer::CreateChildTextNodeResponse create_child_text_node(i32 node_id) override;
|
||||
virtual Messages::WebContentServer::CloneDomNodeResponse clone_dom_node(i32 node_id) override;
|
||||
virtual void remove_dom_node(i32 node_id) override;
|
||||
virtual Messages::WebContentServer::GetDomNodeHtmlResponse get_dom_node_html(i32 node_id) override;
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ endpoint WebContentServer
|
|||
replace_dom_node_attribute(i32 node_id, String name, Vector<WebView::Attribute> replacement_attributes) =|
|
||||
create_child_element(i32 node_id) => (Optional<i32> node_id)
|
||||
create_child_text_node(i32 node_id) => (Optional<i32> node_id)
|
||||
clone_dom_node(i32 node_id) => (Optional<i32> node_id)
|
||||
remove_dom_node(i32 node_id) =|
|
||||
get_dom_node_html(i32 node_id) => (Optional<String> html)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue