aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorBobby Holley <bobbyholley@gmail.com>2016-08-10 15:07:36 -0700
committerBobby Holley <bobbyholley@gmail.com>2016-08-26 09:36:53 -0700
commitb56297f2a57eb79ed47b3aa3a1daf82f29d36b4b (patch)
tree9f989a6db04c42acd2adda601410f2276884d30c /components/script
parent470368ecce2308938c4270d1d892ddc1e8f73d28 (diff)
downloadservo-b56297f2a57eb79ed47b3aa3a1daf82f29d36b4b.tar.gz
servo-b56297f2a57eb79ed47b3aa3a1daf82f29d36b4b.zip
Make ChildrenIterator concrete.
This will allow us to specialize ChildrenIterator in the Gecko case to do something more interesting in some cases.
Diffstat (limited to 'components/script')
-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>;