aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/sequential.rs
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <ecoal95@gmail.com>2016-07-22 16:48:08 -0700
committerEmilio Cobos Álvarez <ecoal95@gmail.com>2016-07-24 12:51:58 -0700
commita3020419d9eace898727f5b778e661b61a1bb8df (patch)
treed121309409520eb6e55e5b28af84c24b24b97739 /components/style/sequential.rs
parent7ca826c6eec21b7f8c8ad9377f04a4816d94eff3 (diff)
downloadservo-a3020419d9eace898727f5b778e661b61a1bb8df.tar.gz
servo-a3020419d9eace898727f5b778e661b61a1bb8df.zip
stylo: Don't traverse the whole dom every restyle, propagate the dirty flag down the DOM.
This commit adds hooks to the Servo style traversal to avoid traversing all the DOM for every restyle. Additionally it changes the behavior of the dirty flag to be propagated top down, to prevent extra overhead when an element is dirtied. This commit doesn't aim to change the behavior on Servo just yet, since Servo might rely on a full bottom up reconstruction of the flows. I'll need to double check and implement that separately.
Diffstat (limited to 'components/style/sequential.rs')
-rw-r--r--components/style/sequential.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/components/style/sequential.rs b/components/style/sequential.rs
index a5a9b519e57..56b8a563d27 100644
--- a/components/style/sequential.rs
+++ b/components/style/sequential.rs
@@ -9,20 +9,29 @@ use traversal::DomTraversalContext;
pub fn traverse_dom<N, C>(root: N,
shared: &C::SharedContext)
- where N: TNode,
- C: DomTraversalContext<N> {
+ where N: TNode,
+ C: DomTraversalContext<N>
+{
fn doit<'a, N, C>(context: &'a C, node: N)
- where N: TNode, C: DomTraversalContext<N> {
+ where N: TNode,
+ C: DomTraversalContext<N>
+ {
+ debug_assert!(context.should_process(node));
context.process_preorder(node);
for kid in node.children() {
- doit::<N, C>(context, kid);
+ context.pre_process_child_hook(node, kid);
+ if context.should_process(node) {
+ doit::<N, C>(context, kid);
+ }
}
context.process_postorder(node);
}
let context = C::new(shared, root.opaque());
- doit::<N, C>(&context, root);
+ if context.should_process(root) {
+ doit::<N, C>(&context, root);
+ }
}