mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Fix JS roots assertion when clicking on an element
This commit is contained in:
parent
b14b2eca37
commit
87e6921d46
1 changed files with 10 additions and 16 deletions
|
@ -1100,25 +1100,19 @@ impl ScriptTask {
|
||||||
match page.hit_test(&point) {
|
match page.hit_test(&point) {
|
||||||
Some(node_address) => {
|
Some(node_address) => {
|
||||||
debug!("node address is {:?}", node_address);
|
debug!("node address is {:?}", node_address);
|
||||||
let mut node =
|
|
||||||
node::from_untrusted_node_address(self.js_runtime.deref().ptr,
|
|
||||||
node_address).root();
|
|
||||||
debug!("clicked on {:s}", node.deref().debug_str());
|
|
||||||
|
|
||||||
// Traverse node generations until a node that is an element is
|
let temp_node =
|
||||||
// found.
|
node::from_untrusted_node_address(
|
||||||
while !node.deref().is_element() {
|
self.js_runtime.deref().ptr, node_address);
|
||||||
match node.deref().parent_node() {
|
|
||||||
Some(parent) => node = parent.root(),
|
|
||||||
None => break,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if node.deref().is_element() {
|
let maybe_node = temp_node.root().ancestors().find(|node| node.is_anchor_element());
|
||||||
let element: &JSRef<Element> = ElementCast::to_ref(&*node).unwrap();
|
match maybe_node {
|
||||||
if "a" == element.deref().local_name {
|
Some(node) => {
|
||||||
self.load_url_from_element(page, element)
|
debug!("clicked on {:s}", node.debug_str());
|
||||||
|
let element: &JSRef<Element> = ElementCast::to_ref(&node).unwrap();
|
||||||
|
self.load_url_from_element(page, element);
|
||||||
}
|
}
|
||||||
|
None => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue