diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index ff42af63ee5..6d46500621b 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -1156,17 +1156,11 @@ impl LayoutThread { }, ReflowQueryType::HitTestQuery(point, update_cursor) => { let point = Point2D::new(Au::from_f32_px(point.x), Au::from_f32_px(point.y)); - let result = match rw_data.display_list { - None => panic!("Tried to hit test with no display list"), - Some(ref display_list) => { - display_list.hit_test(&point, &rw_data.stacking_context_scroll_offsets) - } - }; - rw_data.hit_test_response = if result.len() > 0 { - (Some(result[0]), update_cursor) - } else { - (None, update_cursor) - }; + let result = rw_data.display_list + .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); }, ReflowQueryType::NodeGeometryQuery(node) => { let node = unsafe { ServoLayoutNode::new(&node) };