mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 23:27:42 +00:00
WebContent+Friends: Add get_element_attribute IPC and plumbing
This commit is contained in:
parent
dfc3a4772b
commit
3f5a620b5d
7 changed files with 30 additions and 0 deletions
|
@ -473,6 +473,23 @@ Messages::WebContentServer::QuerySelectorAllResponse ConnectionFromClient::query
|
|||
return { return_list };
|
||||
}
|
||||
|
||||
Messages::WebContentServer::GetElementAttributeResponse ConnectionFromClient::get_element_attribute(i32 element_id, String const& name)
|
||||
{
|
||||
auto* node = Web::DOM::Node::from_id(element_id);
|
||||
if (!node)
|
||||
return Optional<String> {};
|
||||
|
||||
if (!node->is_element())
|
||||
return Optional<String> {};
|
||||
|
||||
auto& element = verify_cast<Web::DOM::Element>(*node);
|
||||
|
||||
if (!element.has_attribute(name))
|
||||
return Optional<String> {};
|
||||
|
||||
return { element.get_attribute(name) };
|
||||
}
|
||||
|
||||
Messages::WebContentServer::GetSelectedTextResponse ConnectionFromClient::get_selected_text()
|
||||
{
|
||||
return page().focused_context().selected_text();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue