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:
Bobby Holley 2016-08-10 15:07:36 -07:00
parent 470368ecce
commit b56297f2a5
3 changed files with 42 additions and 19 deletions

View file

@ -134,6 +134,7 @@ impl<'ln> TNode for GeckoNode<'ln> {
type ConcreteDocument = GeckoDocument<'ln>;
type ConcreteElement = GeckoElement<'ln>;
type ConcreteRestyleDamage = GeckoRestyleDamage;
type ConcreteChildrenIterator = GeckoChildrenIterator<'ln>;
fn to_unsafe(&self) -> UnsafeNode {
(self.node as usize, 0)
@ -163,6 +164,12 @@ impl<'ln> TNode for GeckoNode<'ln> {
unimplemented!()
}
fn children(self) -> GeckoChildrenIterator<'ln> {
GeckoChildrenIterator {
current: self.first_child(),
}
}
fn opaque(&self) -> OpaqueNode {
let ptr: uintptr_t = self.node as uintptr_t;
OpaqueNode(ptr)
@ -341,6 +348,19 @@ impl<'ln> TNode for GeckoNode<'ln> {
unsafe fn set_dirty_on_viewport_size_changed(&self) {}
}
pub struct GeckoChildrenIterator<'a> {
current: Option<GeckoNode<'a>>,
}
impl<'a> Iterator for GeckoChildrenIterator<'a> {
type Item = GeckoNode<'a>;
fn next(&mut self) -> Option<GeckoNode<'a>> {
let node = self.current;
self.current = node.and_then(|node| node.next_sibling());
node
}
}
#[derive(Clone, Copy)]
pub struct GeckoDocument<'ld> {
document: *mut RawGeckoDocument,