diff options
author | Emilio Cobos Álvarez <ecoal95@gmail.com> | 2016-07-25 21:16:53 -0700 |
---|---|---|
committer | Emilio Cobos Álvarez <ecoal95@gmail.com> | 2016-07-27 11:14:45 -0700 |
commit | c3a727ebda5bc9a0d58c8895c7d4626790a9e45d (patch) | |
tree | d0036c9e728f24ebee9cd24520499f5331cc7e34 /components/script/dom | |
parent | 354dc660292b798bb0beafcc39a98e2519518e53 (diff) | |
download | servo-c3a727ebda5bc9a0d58c8895c7d4626790a9e45d.tar.gz servo-c3a727ebda5bc9a0d58c8895c7d4626790a9e45d.zip |
style: Remove a few more unuseful traversals now we can.
Diffstat (limited to 'components/script/dom')
-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 { |