Avoid some Option::unwrap calls in page.rs.

This commit is contained in:
Ms2ger 2014-12-11 11:26:23 +01:00
parent 80756a11d2
commit 205b4e3f39

View file

@ -434,11 +434,10 @@ impl Page {
pub fn hit_test(&self, point: &Point2D<f32>) -> Option<UntrustedNodeAddress> {
let frame = self.frame();
let document = frame.as_ref().unwrap().document.root();
let root = document.GetDocumentElement().root();
if root.is_none() {
return None;
}
let root = root.unwrap();
let root = match document.GetDocumentElement().root() {
None => return None,
Some(root) => root,
};
let root: JSRef<Node> = NodeCast::from_ref(*root);
let address = match self.layout().hit_test(root.to_trusted_node_address(), *point) {
Ok(HitTestResponse(node_address)) => {
@ -455,11 +454,10 @@ impl Page {
pub fn get_nodes_under_mouse(&self, point: &Point2D<f32>) -> Option<Vec<UntrustedNodeAddress>> {
let frame = self.frame();
let document = frame.as_ref().unwrap().document.root();
let root = document.GetDocumentElement().root();
if root.is_none() {
return None;
}
let root = root.unwrap();
let root = match document.GetDocumentElement().root() {
None => return None,
Some(root) => root,
};
let root: JSRef<Node> = NodeCast::from_ref(*root);
let address = match self.layout().mouse_over(root.to_trusted_node_address(), *point) {
Ok(MouseOverResponse(node_address)) => {