Switch ChildrenIterator to be an associated type.

If we use ThreadsafeLayoutNodeChildrenIterator directly as the return type of children(),
we need to export the DangerousThreadSafeLayoutNode which the iterator implementation
relies upon.
This commit is contained in:
Bobby Holley 2015-11-24 15:02:15 -08:00
parent 2cfe4de09b
commit 3aeaff35de

View file

@ -806,6 +806,7 @@ impl<T> PseudoElementType<T> {
pub trait ThreadSafeLayoutNode<'ln> : Clone + Copy + Sized {
type ConcreteThreadSafeLayoutElement: ThreadSafeLayoutElement<'ln, ConcreteThreadSafeLayoutNode = Self>;
type ChildrenIterator: Iterator<Item = Self> + Sized;
/// Converts self into an `OpaqueNode`.
fn opaque(&self) -> OpaqueNode;
@ -819,7 +820,7 @@ pub trait ThreadSafeLayoutNode<'ln> : Clone + Copy + Sized {
fn flow_debug_id(self) -> usize;
/// Returns an iterator over this node's children.
fn children(&self) -> ThreadSafeLayoutNodeChildrenIterator<'ln, Self>;
fn children(&self) -> Self::ChildrenIterator;
/// If this is an element, accesses the element data. Fails if this is not an element node.
#[inline]
@ -1022,6 +1023,7 @@ impl<'ln> ServoThreadSafeLayoutNode<'ln> {
impl<'ln> ThreadSafeLayoutNode<'ln> for ServoThreadSafeLayoutNode<'ln> {
type ConcreteThreadSafeLayoutElement = ServoThreadSafeLayoutElement<'ln>;
type ChildrenIterator = ThreadSafeLayoutNodeChildrenIterator<'ln, Self>;
fn opaque(&self) -> OpaqueNode {
OpaqueNodeMethods::from_jsmanaged(unsafe { self.get_jsmanaged() })
@ -1043,7 +1045,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> for ServoThreadSafeLayoutNode<'ln> {
self.node.flow_debug_id()
}
fn children(&self) -> ThreadSafeLayoutNodeChildrenIterator<'ln, Self> {
fn children(&self) -> Self::ChildrenIterator {
ThreadSafeLayoutNodeChildrenIterator::new(*self)
}