mirror of
https://github.com/servo/servo.git
synced 2025-07-31 11:10:22 +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 {
|
fn rev_children(self) -> ReverseChildrenIterator {
|
||||||
ReverseChildrenIterator {
|
ReverseChildrenIterator {
|
||||||
current: self.last_child.get().root(),
|
current: self.last_child(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1132,16 +1132,19 @@ impl Iterator for NodeChildrenIterator {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ReverseChildrenIterator {
|
pub struct ReverseChildrenIterator {
|
||||||
current: Option<Root<Node>>,
|
current: Option<Temporary<Node>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Iterator for ReverseChildrenIterator {
|
impl Iterator for ReverseChildrenIterator {
|
||||||
type Item = Temporary<Node>;
|
type Item = Temporary<Node>;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Temporary<Node>> {
|
fn next(&mut self) -> Option<Temporary<Node>> {
|
||||||
let node = self.current.r().map(Temporary::from_rooted);
|
let current = match self.current.take() {
|
||||||
self.current = self.current.take().and_then(|node| node.r().prev_sibling()).root();
|
None => return None,
|
||||||
node
|
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