diff options
author | Ms2ger <ms2ger@gmail.com> | 2015-07-17 11:40:40 +0200 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2015-07-17 11:40:40 +0200 |
commit | 3e2c44114c339e77b07a303bd02365f109003677 (patch) | |
tree | 013314d41f2f8402f2765f053e69efb99d765396 /components/layout/traversal.rs | |
parent | acf47a02cf38b5c82e7c78cc1f6660a7daa9969a (diff) | |
download | servo-3e2c44114c339e77b07a303bd02365f109003677.tar.gz servo-3e2c44114c339e77b07a303bd02365f109003677.zip |
Move the traversal traits into the traversal module.
Diffstat (limited to 'components/layout/traversal.rs')
-rw-r--r-- | components/layout/traversal.rs | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs index 603245ecb88..c366d20206b 100644 --- a/components/layout/traversal.rs +++ b/components/layout/traversal.rs @@ -15,8 +15,7 @@ use flow::{PreorderFlowTraversal, PostorderFlowTraversal}; use incremental::{self, BUBBLE_ISIZES, REFLOW, REFLOW_OUT_OF_FLOW, RestyleDamage}; use script::layout_interface::ReflowGoal; use wrapper::{layout_node_to_unsafe_layout_node, LayoutNode}; -use wrapper::{PostorderNodeMutTraversal, ThreadSafeLayoutNode, UnsafeLayoutNode}; -use wrapper::{PreorderDomTraversal, PostorderDomTraversal}; +use wrapper::{ThreadSafeLayoutNode, UnsafeLayoutNode}; use selectors::bloom::BloomFilter; use selectors::Node; @@ -118,6 +117,32 @@ fn insert_ancestors_into_bloom_filter(bf: &mut Box<BloomFilter>, debug!("[{}] Inserted {} ancestors.", tid(), ancestors); } + +/// 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); +} + +/// A bottom-up, parallelizable traversal. +pub trait PostorderNodeMutTraversal { + /// The operation to perform. Return true to continue or false to stop. + fn process<'a>(&'a mut self, node: &ThreadSafeLayoutNode<'a>) -> bool; + + /// Returns true if this node should be pruned. If this returns true, we skip the operation + /// entirely and do not process any descendant nodes. This is called *before* child nodes are + /// visited. The default implementation never prunes any nodes. + fn should_prune<'a>(&'a self, _node: &ThreadSafeLayoutNode<'a>) -> bool { + false + } +} + /// The recalc-style-for-node traversal, which styles each node and must run before /// layout computation. This computes the styles applied to each node. #[derive(Copy, Clone)] |