Cleanup Document::handle_mouse_move_event a bit.

This commit is contained in:
Ms2ger 2015-10-31 13:25:32 +01:00
parent 521a87180a
commit e05d9d0646

View file

@ -672,14 +672,13 @@ impl Document {
prev_mouse_over_targets: &mut RootedVec<JS<Element>>) { prev_mouse_over_targets: &mut RootedVec<JS<Element>>) {
// Build a list of elements that are currently under the mouse. // Build a list of elements that are currently under the mouse.
let mouse_over_addresses = self.get_nodes_under_mouse(&point); let mouse_over_addresses = self.get_nodes_under_mouse(&point);
let mut mouse_over_targets: RootedVec<JS<Element>> = RootedVec::new(); let mut mouse_over_targets = mouse_over_addresses.iter().map(|node_address| {
for node_address in &mouse_over_addresses { node::from_untrusted_node_address(js_runtime, *node_address)
let node = node::from_untrusted_node_address(js_runtime, *node_address); .inclusive_ancestors()
mouse_over_targets.push(node.r().inclusive_ancestors() .filter_map(Root::downcast::<Element>)
.find(|node| node.is::<Element>()) .next()
.map(|node| JS::from_ref(node.downcast::<Element>().unwrap())) .unwrap()
.unwrap()); }).collect::<RootedVec<JS<Element>>>();
};
// Remove hover from any elements in the previous list that are no longer // Remove hover from any elements in the previous list that are no longer
// under the mouse. // under the mouse.