mirror of
https://github.com/servo/servo.git
synced 2025-07-30 18:50:36 +01:00
Hold a Temporary in ReverseChildrenIterator
This commit is contained in:
parent
fc31aef8b4
commit
6a6ecb9afa
1 changed files with 8 additions and 5 deletions
|
@ -862,7 +862,7 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> {
|
|||
|
||||
fn rev_children(self) -> ReverseChildrenIterator {
|
||||
ReverseChildrenIterator {
|
||||
current: self.last_child.get().root(),
|
||||
current: self.last_child(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1132,16 +1132,19 @@ impl Iterator for NodeChildrenIterator {
|
|||
}
|
||||
|
||||
pub struct ReverseChildrenIterator {
|
||||
current: Option<Root<Node>>,
|
||||
current: Option<Temporary<Node>>,
|
||||
}
|
||||
|
||||
impl Iterator for ReverseChildrenIterator {
|
||||
type Item = Temporary<Node>;
|
||||
|
||||
fn next(&mut self) -> Option<Temporary<Node>> {
|
||||
let node = self.current.r().map(Temporary::from_rooted);
|
||||
self.current = self.current.take().and_then(|node| node.r().prev_sibling()).root();
|
||||
node
|
||||
let current = match self.current.take() {
|
||||
None => return None,
|
||||
Some(current) => current,
|
||||
}.root();
|
||||
self.current = current.r().prev_sibling();
|
||||
Some(Temporary::from_rooted(current.r()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue