From 2bb9da787fac2efbcd7acbc2a9fb2bc7f81c81df Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Tue, 17 Nov 2015 01:35:52 +0500 Subject: [PATCH] servo: Merge #8548 - Remove the unused arguments to hit_test and mouse_over (from Ms2ger:unused-tna); r=pcwalton I don't think this code is called when there is no document element, but I added assertions to make sure we notice in case I was wrong. Source-Repo: https://github.com/servo/servo Source-Revision: 20d26853e145e275695463662b6cee334cd27085 --- servo/components/layout/query.rs | 5 ++--- servo/components/script/dom/document.rs | 21 +++++---------------- servo/components/script/layout_interface.rs | 4 ++-- 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/servo/components/layout/query.rs b/servo/components/layout/query.rs index 562e8f93aef8..9057ac919672 100644 --- a/servo/components/layout/query.rs +++ b/servo/components/layout/query.rs @@ -57,7 +57,7 @@ impl LayoutRPC for LayoutRPCImpl { } /// Requests the node containing the point of interest. - fn hit_test(&self, _: TrustedNodeAddress, point: Point2D) -> Result { + fn hit_test(&self, point: Point2D) -> Result { let point = Point2D::new(Au::from_f32_px(point.x), Au::from_f32_px(point.y)); let resp = { let &LayoutRPCImpl(ref rw_data) = self; @@ -82,8 +82,7 @@ impl LayoutRPC for LayoutRPCImpl { Err(()) } - fn mouse_over(&self, _: TrustedNodeAddress, point: Point2D) - -> Result { + fn mouse_over(&self, point: Point2D) -> Result { let mut mouse_over_list: Vec = vec!(); let point = Point2D::new(Au::from_f32_px(point.x), Au::from_f32_px(point.y)); { diff --git a/servo/components/script/dom/document.rs b/servo/components/script/dom/document.rs index af1c265a8762..1b8b99d90ecc 100644 --- a/servo/components/script/dom/document.rs +++ b/servo/components/script/dom/document.rs @@ -483,30 +483,19 @@ impl Document { } pub fn hit_test(&self, point: &Point2D) -> Option { - let root = self.GetDocumentElement(); - let root = match root.r() { - Some(root) => root, - None => return None, - }; - let root = root.upcast::(); - let address = match self.window.layout().hit_test(root.to_trusted_node_address(), *point) { + assert!(self.GetDocumentElement().is_some()); + match self.window.layout().hit_test(*point) { Ok(HitTestResponse(node_address)) => Some(node_address), Err(()) => { debug!("layout query error"); None } - }; - address + } } pub fn get_nodes_under_mouse(&self, point: &Point2D) -> Vec { - let root = self.GetDocumentElement(); - let root = match root.r() { - Some(root) => root, - None => return vec!(), - }; - let root = root.upcast::(); - match self.window.layout().mouse_over(root.to_trusted_node_address(), *point) { + assert!(self.GetDocumentElement().is_some()); + match self.window.layout().mouse_over(*point) { Ok(MouseOverResponse(node_address)) => node_address, Err(()) => vec!(), } diff --git a/servo/components/script/layout_interface.rs b/servo/components/script/layout_interface.rs index e0ad2d550345..7c85d9c681e9 100644 --- a/servo/components/script/layout_interface.rs +++ b/servo/components/script/layout_interface.rs @@ -101,8 +101,8 @@ pub trait LayoutRPC { /// Requests the geometry of this node. Used by APIs such as `clientTop`. fn node_geometry(&self) -> NodeGeometryResponse; /// Requests the node containing the point of interest - fn hit_test(&self, node: TrustedNodeAddress, point: Point2D) -> Result; - fn mouse_over(&self, node: TrustedNodeAddress, point: Point2D) -> Result; + fn hit_test(&self, point: Point2D) -> Result; + fn mouse_over(&self, point: Point2D) -> Result; /// Query layout for the resolved value of a given CSS property fn resolved_style(&self) -> ResolvedStyleResponse; fn offset_parent(&self) -> OffsetParentResponse;