mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Auto merge of #23171 - hundredeir:find_elem_elems, r=jdm
add webdriver command "Find elements from Element" --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23171) <!-- Reviewable:end -->
This commit is contained in:
commit
7e766e9189
4 changed files with 74 additions and 1 deletions
|
@ -220,6 +220,28 @@ pub fn handle_find_element_element_css(
|
|||
reply.send(node_id).unwrap();
|
||||
}
|
||||
|
||||
pub fn handle_find_element_elements_css(
|
||||
documents: &Documents,
|
||||
pipeline: PipelineId,
|
||||
element_id: String,
|
||||
selector: String,
|
||||
reply: IpcSender<Result<Option<String>, ()>>,
|
||||
) {
|
||||
let node_ids = find_node_by_unique_id(documents, pipeline, element_id)
|
||||
.ok_or(())
|
||||
.and_then(|node| {
|
||||
node.query_selector_all(DOMString::from(selector))
|
||||
.map_err(|_| ())
|
||||
})
|
||||
.map(|nodes| {
|
||||
nodes
|
||||
.iter()
|
||||
.map(|x| Some(x.upcast::<Node>().unique_id()))
|
||||
.collect()
|
||||
});
|
||||
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