mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
script: Fix remaining bugs from Range.deleteContents
This commit is contained in:
parent
be6940db59
commit
3e36739e38
3 changed files with 42 additions and 43 deletions
|
@ -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>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue