aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGlenn Watson <gw@intuitionlibrary.com>2014-05-06 11:11:40 +1000
committerGlenn Watson <gw@intuitionlibrary.com>2014-05-07 08:46:11 +1000
commitdb81cf9bc7ceed3bf94a847ea11556de8237cea3 (patch)
tree175d392144218e38ab89db72e5286ec3cda7025f /src
parentb1d0dac50d30506f85c7711437eb4957ee59cc0b (diff)
downloadservo-db81cf9bc7ceed3bf94a847ea11556de8237cea3.tar.gz
servo-db81cf9bc7ceed3bf94a847ea11556de8237cea3.zip
Modify node traversal loop to avoid JS roots assertion. Fixes #2321.
Diffstat (limited to 'src')
-rw-r--r--src/components/script/script_task.rs37
1 files changed, 17 insertions, 20 deletions
diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs
index 09d9ee59aa6..e06439f912d 100644
--- a/src/components/script/script_task.rs
+++ b/src/components/script/script_task.rs
@@ -1148,30 +1148,27 @@ impl ScriptTask {
}
for node_address in node_address.iter() {
- let mut node =
- node::from_untrusted_node_address(
- self.js_runtime.deref().ptr, *node_address).root();
- // Traverse node generations until a node that is an element is
- // found.
- while !node.is_element() {
- match node.parent_node() {
- Some(parent) => node = parent.root(),
- None => break,
- }
- }
- if node.is_element() {
- node.set_hover_state(true);
-
- match *mouse_over_targets {
- Some(ref mouse_over_targets) => {
- if !target_compare {
- target_compare = !mouse_over_targets.contains(&node.unrooted());
+ let temp_node =
+ node::from_untrusted_node_address(
+ self.js_runtime.deref().ptr, *node_address);
+
+ let maybe_node = temp_node.root().ancestors().find(|node| node.is_element());
+ match maybe_node {
+ Some(mut node) => {
+ node.set_hover_state(true);
+
+ match *mouse_over_targets {
+ Some(ref mouse_over_targets) => {
+ if !target_compare {
+ target_compare = !mouse_over_targets.contains(&node.unrooted());
+ }
}
+ None => {}
}
- None => {}
+ target_list.push(node.unrooted());
}
- target_list.push(node.unrooted());
+ None => {}
}
}
match *mouse_over_targets {