aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/layout_wrapper.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/layout_wrapper.rs')
-rw-r--r--components/script/layout_wrapper.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/components/script/layout_wrapper.rs b/components/script/layout_wrapper.rs
index b4e54fe5bd9..47ecc910345 100644
--- a/components/script/layout_wrapper.rs
+++ b/components/script/layout_wrapper.rs
@@ -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>;