mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Avoid some Option::unwrap calls in page.rs.
This commit is contained in:
parent
80756a11d2
commit
205b4e3f39
1 changed files with 8 additions and 10 deletions
|
@ -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)) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue