Simplify the code setting hit_test_response.

This commit is contained in:
Ms2ger 2016-06-28 16:38:41 +02:00
parent aefa941626
commit ae064dc7c1

View file

@ -1156,17 +1156,11 @@ impl LayoutThread {
}, },
ReflowQueryType::HitTestQuery(point, update_cursor) => { ReflowQueryType::HitTestQuery(point, update_cursor) => {
let point = Point2D::new(Au::from_f32_px(point.x), Au::from_f32_px(point.y)); let point = Point2D::new(Au::from_f32_px(point.x), Au::from_f32_px(point.y));
let result = match rw_data.display_list { let result = rw_data.display_list
None => panic!("Tried to hit test with no display list"), .as_ref()
Some(ref display_list) => { .expect("Tried to hit test with no display list")
display_list.hit_test(&point, &rw_data.stacking_context_scroll_offsets) .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 = if result.len() > 0 {
(Some(result[0]), update_cursor)
} else {
(None, update_cursor)
};
}, },
ReflowQueryType::NodeGeometryQuery(node) => { ReflowQueryType::NodeGeometryQuery(node) => {
let node = unsafe { ServoLayoutNode::new(&node) }; let node = unsafe { ServoLayoutNode::new(&node) };