From 6b981039d083e66445c1f8df65f6025febdb8238 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 29 Jun 2016 09:46:45 +0200 Subject: [PATCH] Avoid the Vec reversal in DisplayList::hit_test. --- components/gfx/display_list/mod.rs | 6 ++---- components/layout/query.rs | 1 + components/layout_thread/lib.rs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index 988bfa5af96..25b7c46075f 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -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, scroll_offsets: &ScrollOffsetMap) -> Vec { 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 } } diff --git a/components/layout/query.rs b/components/layout/query.rs index f5735c97877..ea22bd966d5 100644 --- a/components/layout/query.rs +++ b/components/layout/query.rs @@ -150,6 +150,7 @@ impl LayoutRPC for LayoutRPCImpl { }; nodes_from_point_list.iter() + .rev() .map(|metadata| metadata.node.to_untrusted_node_address()) .collect() } diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index 6d46500621b..b33a5c56eb1 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -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) };