diff options
author | martinfalisse <martinmotteditfalisse@gmail.com> | 2022-11-01 10:10:51 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-11-01 10:55:34 +0000 |
commit | 5ffff09e05043a6e3c831e863d3d6815fcef8462 (patch) | |
tree | a8b55b150ff69d92b19153dc3bad801601a8c3c1 /Userland/Services | |
parent | 67236d957338519d3fbdacfb954bc024230cba47 (diff) | |
download | serenity-5ffff09e05043a6e3c831e863d3d6815fcef8462.zip |
WebContent+Friends: Add get_element_text IPC and plumbing
Diffstat (limited to 'Userland/Services')
-rw-r--r-- | Userland/Services/WebContent/ConnectionFromClient.cpp | 14 | ||||
-rw-r--r-- | Userland/Services/WebContent/ConnectionFromClient.h | 1 | ||||
-rw-r--r-- | Userland/Services/WebContent/WebContentServer.ipc | 1 |
3 files changed, 16 insertions, 0 deletions
diff --git a/Userland/Services/WebContent/ConnectionFromClient.cpp b/Userland/Services/WebContent/ConnectionFromClient.cpp index a3c4cf811c..92512b0b26 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::GetElementTextResponse ConnectionFromClient::get_element_text(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.layout_node()->dom_node()->text_content() }; +} + Messages::WebContentServer::GetElementTagNameResponse ConnectionFromClient::get_element_tag_name(i32 element_id) { auto* node = Web::DOM::Node::from_id(element_id); diff --git a/Userland/Services/WebContent/ConnectionFromClient.h b/Userland/Services/WebContent/ConnectionFromClient.h index 13ae9f6dbe..4916ee8460 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::GetElementTextResponse get_element_text(i32 element_id) override; virtual Messages::WebContentServer::GetElementTagNameResponse get_element_tag_name(i32 element_id) override; virtual Messages::WebContentServer::GetLocalStorageEntriesResponse get_local_storage_entries() override; diff --git a/Userland/Services/WebContent/WebContentServer.ipc b/Userland/Services/WebContent/WebContentServer.ipc index b22ff042db..125be1ba68 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_text(i32 element_id) => (String text) get_element_tag_name(i32 element_id) => (String tag_name) run_javascript(String js_source) =| |