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.
This commit is contained in:
Emilio Cobos Álvarez 2016-07-22 16:48:08 -07:00
parent 7ca826c6ee
commit a3020419d9
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
5 changed files with 66 additions and 33 deletions

View file

@ -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);
}
}