Factors out DOM traversal, keeping the code in parallel free of traversal-specific logic.

DOM traversals and Flow traversals look very similar. This patch unifies them
with the preorder/postorder pattern. Hopefully, it also opens the door for writing
the traversal code only once, instead of the duplication we have today.
This commit is contained in:
Clark Gaebel 2014-10-10 14:27:38 -04:00
parent bfb81a5d10
commit 24bff2416b
5 changed files with 501 additions and 403 deletions

View file

@ -888,3 +888,15 @@ pub unsafe fn layout_node_from_unsafe_layout_node(node: &UnsafeLayoutNode) -> La
let (node, _) = *node;
mem::transmute(node)
}
/// A top-down traversal.
pub trait PreorderDOMTraversal {
/// The operation to perform. Return true to continue or false to stop.
fn process(&self, _node: LayoutNode);
}
/// A bottom-up traversal, with a optional in-order pass.
pub trait PostorderDOMTraversal {
/// The operation to perform. Return true to continue or false to stop.
fn process(&self, _node: LayoutNode);
}