mirror of
https://github.com/servo/servo.git
synced 2025-07-23 23:33:43 +01:00
Implement tag name selector for FindElementsFromElement WebDriver command
This commit is contained in:
parent
616a81fb27
commit
bf6ea64e8c
5 changed files with 65 additions and 27 deletions
|
@ -284,7 +284,7 @@ pub fn handle_find_element_elements_css(
|
|||
pipeline: PipelineId,
|
||||
element_id: String,
|
||||
selector: String,
|
||||
reply: IpcSender<Result<Option<String>, ()>>,
|
||||
reply: IpcSender<Result<Vec<String>, ()>>,
|
||||
) {
|
||||
let node_ids = find_node_by_unique_id(documents, pipeline, element_id)
|
||||
.ok_or(())
|
||||
|
@ -295,12 +295,34 @@ pub fn handle_find_element_elements_css(
|
|||
.map(|nodes| {
|
||||
nodes
|
||||
.iter()
|
||||
.map(|x| Some(x.upcast::<Node>().unique_id()))
|
||||
.map(|x| x.upcast::<Node>().unique_id())
|
||||
.collect()
|
||||
});
|
||||
reply.send(node_ids).unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_find_element_elements_tag_name(
|
||||
documents: &Documents,
|
||||
pipeline: PipelineId,
|
||||
element_id: String,
|
||||
selector: String,
|
||||
reply: IpcSender<Result<Vec<String>, ()>>,
|
||||
) {
|
||||
let node_ids = find_node_by_unique_id(documents, pipeline, element_id)
|
||||
.ok_or(())
|
||||
.and_then(|node| match node.downcast::<Element>() {
|
||||
Some(elem) => Ok(elem.GetElementsByTagName(DOMString::from(selector))),
|
||||
None => Err(()),
|
||||
})
|
||||
.map(|nodes| {
|
||||
nodes
|
||||
.elements_iter()
|
||||
.map(|x| x.upcast::<Node>().unique_id())
|
||||
.collect::<Vec<String>>()
|
||||
});
|
||||
reply.send(node_ids).unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_focus_element(
|
||||
documents: &Documents,
|
||||
pipeline: PipelineId,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue