mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Introduce the LayoutIterator newtype and return it for all children() methods in style and layout.
This commit is contained in:
parent
e6bbff110a
commit
4aa3e589c0
4 changed files with 25 additions and 16 deletions
|
@ -73,6 +73,14 @@ pub trait NodeInfo {
|
|||
fn is_text_node(&self) -> bool;
|
||||
}
|
||||
|
||||
pub struct LayoutIterator<T>(pub T);
|
||||
impl<T, I> Iterator for LayoutIterator<T> where T: Iterator<Item=I>, I: NodeInfo {
|
||||
type Item = I;
|
||||
fn next(&mut self) -> Option<I> {
|
||||
self.0.next()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait TNode : Sized + Copy + Clone + NodeInfo {
|
||||
type ConcreteElement: TElement<ConcreteNode = Self, ConcreteDocument = Self::ConcreteDocument>;
|
||||
type ConcreteDocument: TDocument<ConcreteNode = Self, ConcreteElement = Self::ConcreteElement>;
|
||||
|
@ -87,7 +95,7 @@ pub trait TNode : Sized + Copy + Clone + NodeInfo {
|
|||
fn dump_style(self);
|
||||
|
||||
/// Returns an iterator over this node's children.
|
||||
fn children(self) -> Self::ConcreteChildrenIterator;
|
||||
fn children(self) -> LayoutIterator<Self::ConcreteChildrenIterator>;
|
||||
|
||||
/// Converts self into an `OpaqueNode`.
|
||||
fn opaque(&self) -> OpaqueNode;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue