aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/node.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/node.rs')
-rw-r--r--components/script/dom/node.rs34
1 files changed, 25 insertions, 9 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index c82fbb49e88..ec72b6eed2f 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -1051,21 +1051,18 @@ pub struct FollowingNodeIterator {
root: Root<Node>,
}
-impl Iterator for FollowingNodeIterator {
- type Item = Root<Node>;
-
- // https://dom.spec.whatwg.org/#concept-tree-following
- fn next(&mut self) -> Option<Root<Node>> {
+impl FollowingNodeIterator {
+ /// Skips iterating the children of the current 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);
- return current.GetFirstChild()
- }
+ self.next_skipping_children_impl(current)
+ }
+ fn next_skipping_children_impl(&mut self, current: Root<Node>) -> Option<Root<Node>> {
if self.root == current {
self.current = None;
return None;
@@ -1090,6 +1087,25 @@ impl Iterator for FollowingNodeIterator {
}
}
+impl Iterator for FollowingNodeIterator {
+ type Item = Root<Node>;
+
+ // https://dom.spec.whatwg.org/#concept-tree-following
+ 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);
+ return current.GetFirstChild()
+ }
+
+ self.next_skipping_children_impl(current)
+ }
+}
+
pub struct PrecedingNodeIterator {
current: Option<Root<Node>>,
root: Root<Node>,