mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Cleanup Page::remove.
This commit is contained in:
parent
d8a5199ba8
commit
6fa39497b8
1 changed files with 7 additions and 15 deletions
|
@ -228,26 +228,18 @@ impl Page {
|
|||
self.children
|
||||
.borrow_mut()
|
||||
.iter_mut()
|
||||
.enumerate()
|
||||
.find(|&(_idx, ref page_tree)| {
|
||||
// FIXME: page_tree has a lifetime such that it's unusable for anything.
|
||||
let page_tree_id = page_tree.id;
|
||||
page_tree_id == id
|
||||
})
|
||||
.map(|(idx, _)| idx)
|
||||
.position(|page_tree| page_tree.id == id)
|
||||
};
|
||||
match remove_idx {
|
||||
Some(idx) => return Some(self.children.borrow_mut().remove(idx).unwrap()),
|
||||
Some(idx) => Some(self.children.borrow_mut().remove(idx).unwrap()),
|
||||
None => {
|
||||
for page_tree in self.children.borrow_mut().iter_mut() {
|
||||
match page_tree.remove(id) {
|
||||
found @ Some(_) => return found,
|
||||
None => (), // keep going...
|
||||
}
|
||||
}
|
||||
self.children
|
||||
.borrow_mut()
|
||||
.iter_mut()
|
||||
.filter_map(|page_tree| page_tree.remove(id))
|
||||
.next()
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn set_page_clip_rect_with_new_viewport(&self, viewport: Rect<f32>) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue