script: Fix remaining bugs from Range.deleteContents

This commit is contained in:
Emilio Cobos Álvarez 2016-02-28 18:21:08 +01:00
parent be6940db59
commit 3e36739e38
3 changed files with 42 additions and 43 deletions

View file

@ -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>,