mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
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:
parent
bfb81a5d10
commit
24bff2416b
5 changed files with 501 additions and 403 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue