diff options
Diffstat (limited to 'components/script/dom/node.rs')
-rw-r--r-- | components/script/dom/node.rs | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 0e5e360c6e1..2769b7503bc 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -1287,22 +1287,17 @@ impl TreeIterator { depth: 0, } } -} -impl Iterator for TreeIterator { - type Item = Root<Node>; - - // https://dom.spec.whatwg.org/#concept-tree-order - fn next(&mut self) -> Option<Root<Node>> { + pub fn next_skipping_children(&mut self) -> Option<Root<Node>> { let current = match self.current.take() { None => return None, Some(current) => current, }; - if let Some(first_child) = current.GetFirstChild() { - self.current = Some(first_child); - self.depth += 1; - return Some(current); - }; + + self.next_skipping_children_impl(current) + } + + fn next_skipping_children_impl(&mut self, current: Root<Node>) -> Option<Root<Node>> { for ancestor in current.inclusive_ancestors() { if self.depth == 0 { break; @@ -1319,6 +1314,25 @@ impl Iterator for TreeIterator { } } +impl Iterator for TreeIterator { + type Item = Root<Node>; + + // https://dom.spec.whatwg.org/#concept-tree-order + fn next(&mut self) -> Option<Root<Node>> { + let current = match self.current.take() { + None => return None, + Some(current) => current, + }; + if let Some(first_child) = current.GetFirstChild() { + self.current = Some(first_child); + self.depth += 1; + return Some(current); + }; + + self.next_skipping_children_impl(current) + } +} + /// Specifies whether children must be recursively cloned or not. #[derive(Copy, Clone, PartialEq, HeapSizeOf)] pub enum CloneChildrenFlag { |