mirror of
https://github.com/servo/servo.git
synced 2025-06-21 15:49:04 +01:00
Scope ThreadSafeLayoutNode::first_child to ThreadSafeLayoutNodeChildrenIterator::new.
It is only used there.
This commit is contained in:
parent
b3892b74f7
commit
930e111713
1 changed files with 27 additions and 18 deletions
|
@ -656,26 +656,9 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
|
||||||
self.node.flow_debug_id()
|
self.node.flow_debug_id()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn first_child(&self) -> Option<ThreadSafeLayoutNode<'ln>> {
|
|
||||||
if self.pseudo != PseudoElementType::Normal {
|
|
||||||
return None
|
|
||||||
}
|
|
||||||
|
|
||||||
if self.has_before_pseudo() {
|
|
||||||
return Some(self.with_pseudo(PseudoElementType::Before(self.get_before_display())));
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
self.get_jsmanaged().first_child_ref().map(|node| self.new_with_this_lifetime(&node))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns an iterator over this node's children.
|
/// Returns an iterator over this node's children.
|
||||||
pub fn children(&self) -> ThreadSafeLayoutNodeChildrenIterator<'ln> {
|
pub fn children(&self) -> ThreadSafeLayoutNodeChildrenIterator<'ln> {
|
||||||
ThreadSafeLayoutNodeChildrenIterator {
|
ThreadSafeLayoutNodeChildrenIterator::new(*self)
|
||||||
current_node: self.first_child(),
|
|
||||||
parent_node: self.clone(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// If this is an element, accesses the element data. Fails if this is not an element node.
|
/// If this is an element, accesses the element data. Fails if this is not an element node.
|
||||||
|
@ -961,6 +944,32 @@ pub struct ThreadSafeLayoutNodeChildrenIterator<'a> {
|
||||||
parent_node: ThreadSafeLayoutNode<'a>,
|
parent_node: ThreadSafeLayoutNode<'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> ThreadSafeLayoutNodeChildrenIterator<'a> {
|
||||||
|
fn new(parent: ThreadSafeLayoutNode<'a>) -> ThreadSafeLayoutNodeChildrenIterator<'a> {
|
||||||
|
fn first_child<'a>(parent: ThreadSafeLayoutNode<'a>)
|
||||||
|
-> Option<ThreadSafeLayoutNode<'a>> {
|
||||||
|
if parent.pseudo != PseudoElementType::Normal {
|
||||||
|
return None
|
||||||
|
}
|
||||||
|
|
||||||
|
if parent.has_before_pseudo() {
|
||||||
|
let pseudo = PseudoElementType::Before(parent.get_before_display());
|
||||||
|
return Some(parent.with_pseudo(pseudo));
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
parent.get_jsmanaged().first_child_ref()
|
||||||
|
.map(|node| parent.new_with_this_lifetime(&node))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ThreadSafeLayoutNodeChildrenIterator {
|
||||||
|
current_node: first_child(parent),
|
||||||
|
parent_node: parent,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> Iterator for ThreadSafeLayoutNodeChildrenIterator<'a> {
|
impl<'a> Iterator for ThreadSafeLayoutNodeChildrenIterator<'a> {
|
||||||
type Item = ThreadSafeLayoutNode<'a>;
|
type Item = ThreadSafeLayoutNode<'a>;
|
||||||
fn next(&mut self) -> Option<ThreadSafeLayoutNode<'a>> {
|
fn next(&mut self) -> Option<ThreadSafeLayoutNode<'a>> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue