mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Make ChildrenIterator concrete.
This will allow us to specialize ChildrenIterator in the Gecko case to do something more interesting in some cases.
This commit is contained in:
parent
470368ecce
commit
b56297f2a5
3 changed files with 42 additions and 19 deletions
|
@ -115,6 +115,7 @@ impl<'ln> TNode for ServoLayoutNode<'ln> {
|
|||
type ConcreteElement = ServoLayoutElement<'ln>;
|
||||
type ConcreteDocument = ServoLayoutDocument<'ln>;
|
||||
type ConcreteRestyleDamage = RestyleDamage;
|
||||
type ConcreteChildrenIterator = ServoChildrenIterator<'ln>;
|
||||
|
||||
fn to_unsafe(&self) -> UnsafeNode {
|
||||
unsafe {
|
||||
|
@ -147,6 +148,12 @@ impl<'ln> TNode for ServoLayoutNode<'ln> {
|
|||
self.dump_style_indent(0);
|
||||
}
|
||||
|
||||
fn children(self) -> ServoChildrenIterator<'ln> {
|
||||
ServoChildrenIterator {
|
||||
current: self.first_child(),
|
||||
}
|
||||
}
|
||||
|
||||
fn opaque(&self) -> OpaqueNode {
|
||||
unsafe { self.get_jsmanaged().opaque() }
|
||||
}
|
||||
|
@ -280,6 +287,19 @@ impl<'ln> TNode for ServoLayoutNode<'ln> {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct ServoChildrenIterator<'a> {
|
||||
current: Option<ServoLayoutNode<'a>>,
|
||||
}
|
||||
|
||||
impl<'a> Iterator for ServoChildrenIterator<'a> {
|
||||
type Item = ServoLayoutNode<'a>;
|
||||
fn next(&mut self) -> Option<ServoLayoutNode<'a>> {
|
||||
let node = self.current;
|
||||
self.current = node.and_then(|node| node.next_sibling());
|
||||
node
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ln> LayoutNode for ServoLayoutNode<'ln> {
|
||||
type ConcreteThreadSafeLayoutNode = ServoThreadSafeLayoutNode<'ln>;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue