diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2015-04-04 23:04:27 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2015-04-07 14:47:31 +0200 |
commit | 6a6ecb9afad5eb4ffa8d384b0545e1802adc64db (patch) | |
tree | 8b67076fc948c8d09add8995f570858d255af2ba /components/script | |
parent | fc31aef8b445047fd513037bd84cc7729c0ca8df (diff) | |
download | servo-6a6ecb9afad5eb4ffa8d384b0545e1802adc64db.tar.gz servo-6a6ecb9afad5eb4ffa8d384b0545e1802adc64db.zip |
Hold a Temporary in ReverseChildrenIterator
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/node.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 7cd01875b15..e4dcdae5ee4 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -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())) } } |