summaryrefslogtreecommitdiff
path: root/Userland/Services
diff options
context:
space:
mode:
authorTobias Christiansen <tobyase@serenityos.org>2022-10-20 22:39:41 +0200
committerLinus Groh <mail@linusgroh.de>2022-10-22 13:44:49 +0200
commitbe6bbdaa3b73e0517b206f7e3583f7bb03650839 (patch)
tree9f0368506100c62a161d75a2060925c5c34c3419 /Userland/Services
parentf1f6c4c0b6202b0ea8c2b05b04d69077ce3f7f83 (diff)
downloadserenity-be6bbdaa3b73e0517b206f7e3583f7bb03650839.zip
WebContent+Friends: Add get_element_tag_name IPC and plumbing
Diffstat (limited to 'Userland/Services')
-rw-r--r--Userland/Services/WebContent/ConnectionFromClient.cpp14
-rw-r--r--Userland/Services/WebContent/ConnectionFromClient.h1
-rw-r--r--Userland/Services/WebContent/WebContentServer.ipc1
3 files changed, 16 insertions, 0 deletions
diff --git a/Userland/Services/WebContent/ConnectionFromClient.cpp b/Userland/Services/WebContent/ConnectionFromClient.cpp
index c97d52c99f..5d228d2a7a 100644
--- a/Userland/Services/WebContent/ConnectionFromClient.cpp
+++ b/Userland/Services/WebContent/ConnectionFromClient.cpp
@@ -561,6 +561,20 @@ Messages::WebContentServer::GetComputedValueForElementResponse ConnectionFromCli
return { style_value->to_string() };
}
+Messages::WebContentServer::GetElementTagNameResponse ConnectionFromClient::get_element_tag_name(i32 element_id)
+{
+ auto* node = Web::DOM::Node::from_id(element_id);
+ if (!node)
+ return { "" };
+
+ if (!node->is_element())
+ return { "" };
+
+ auto& element = verify_cast<Web::DOM::Element>(*node);
+
+ return { element.tag_name() };
+}
+
Messages::WebContentServer::GetSelectedTextResponse ConnectionFromClient::get_selected_text()
{
return page().focused_context().selected_text();
diff --git a/Userland/Services/WebContent/ConnectionFromClient.h b/Userland/Services/WebContent/ConnectionFromClient.h
index c9942b42f5..13ae9f6dbe 100644
--- a/Userland/Services/WebContent/ConnectionFromClient.h
+++ b/Userland/Services/WebContent/ConnectionFromClient.h
@@ -85,6 +85,7 @@ private:
virtual Messages::WebContentServer::GetElementPropertyResponse get_element_property(i32 element_id, String const& name) override;
virtual Messages::WebContentServer::GetActiveDocumentsTypeResponse get_active_documents_type() override;
virtual Messages::WebContentServer::GetComputedValueForElementResponse get_computed_value_for_element(i32 element_id, String const& property_name) override;
+ virtual Messages::WebContentServer::GetElementTagNameResponse get_element_tag_name(i32 element_id) override;
virtual Messages::WebContentServer::GetLocalStorageEntriesResponse get_local_storage_entries() override;
virtual Messages::WebContentServer::GetSessionStorageEntriesResponse get_session_storage_entries() override;
diff --git a/Userland/Services/WebContent/WebContentServer.ipc b/Userland/Services/WebContent/WebContentServer.ipc
index b8bd3c7952..b22ff042db 100644
--- a/Userland/Services/WebContent/WebContentServer.ipc
+++ b/Userland/Services/WebContent/WebContentServer.ipc
@@ -43,6 +43,7 @@ endpoint WebContentServer
get_element_property(i32 element_id, String name) => (Optional<String> property)
get_active_documents_type() => (String type)
get_computed_value_for_element(i32 element_id, String property_name) => (String computed_value)
+ get_element_tag_name(i32 element_id) => (String tag_name)
run_javascript(String js_source) =|