Avoid the Vec reversal in DisplayList::hit_test.

This commit is contained in:
Ms2ger 2016-06-29 09:46:45 +02:00
parent 4e8ff4f9bc
commit 6b981039d0
3 changed files with 4 additions and 5 deletions

View file

@ -480,9 +480,8 @@ impl DisplayList {
&draw_target, &stacking_context.filters, stacking_context.blend_mode);
}
/// Places all nodes containing the point of interest into `result`, topmost first. Respects
/// the `pointer-events` CSS property If `topmost_only` is true, stops after placing one node
/// into the list. `result` must be empty upon entry to this function.
/// Return all nodes containing the point of interest, bottommost first,
/// and respecting the `pointer-events` CSS property.
pub fn hit_test(&self, point: &Point2D<Au>, scroll_offsets: &ScrollOffsetMap)
-> Vec<DisplayItemMetadata> {
let mut traversal = DisplayListTraversal {
@ -492,7 +491,6 @@ impl DisplayList {
};
let mut result = Vec::new();
self.root_stacking_context.hit_test(&mut traversal, point, scroll_offsets, &mut result);
result.reverse();
result
}
}

View file

@ -150,6 +150,7 @@ impl LayoutRPC for LayoutRPCImpl {
};
nodes_from_point_list.iter()
.rev()
.map(|metadata| metadata.node.to_untrusted_node_address())
.collect()
}

View file

@ -1160,7 +1160,7 @@ impl LayoutThread {
.as_ref()
.expect("Tried to hit test with no display list")
.hit_test(&point, &rw_data.stacking_context_scroll_offsets);
rw_data.hit_test_response = (result.get(0).cloned(), update_cursor);
rw_data.hit_test_response = (result.last().cloned(), update_cursor);
},
ReflowQueryType::NodeGeometryQuery(node) => {
let node = unsafe { ServoLayoutNode::new(&node) };