aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/node.rs
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <ecoal95@gmail.com>2016-02-28 18:21:08 +0100
committerEmilio Cobos Álvarez <ecoal95@gmail.com>2016-02-28 19:27:42 +0100
commit3e36739e381c99f5f10faa9bd9d31c3a4623250d (patch)
treee4d3a3eaf46367c9cc8d5e9f65e2d2575884e8e4 /components/script/dom/node.rs
parentbe6940db59a2e8bf4fac45911848edbc8cd3dd8d (diff)
downloadservo-3e36739e381c99f5f10faa9bd9d31c3a4623250d.tar.gz
servo-3e36739e381c99f5f10faa9bd9d31c3a4623250d.zip
script: Fix remaining bugs from Range.deleteContents
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>,