mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
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:
parent
7ca826c6ee
commit
a3020419d9
5 changed files with 66 additions and 33 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue