Make Restyle tracking more granular.

The primary idea of this patch is to ditch the rigid enum of Previous/Current
styles, and replace it with a series of indicators for the various types of
work that needs to be performed (expanding snapshots, rematching, recascading,
and damage processing). This loses us a little bit of sanity checking (since
the up-to-date-ness of our style is no longer baked into the type system), but
gives us a lot more flexibility that we'll need going forward (especially when
we separate matching from cascading). We also eliminate get_styling_mode in
favor of a method on the traversal.

This patch does a few other things as ridealongs:
* Temporarily eliminates the handling for transfering ownership of styles to the
  frame. We'll need this again at some point, but for now it's causing too much
  complexity for a half-implemented feature.
* Ditches TRestyleDamage, which is no longer necessary post-crate-merge, and is
  a constant source of compilation failures from either needing to be imported
  or being unnecessarily imported (which varies between gecko and servo).
* Expands Snapshots for the traversal root, which was missing before.
* Fixes up the skip_root stuff to avoid visiting the skipped root.
* Unifies parallel traversal and avoids spawning for a single work item.
* Adds an explicit pre_traverse step do any pre-processing and determine whether
  we need to traverse at all.

MozReview-Commit-ID: IKhLAkAigXE
This commit is contained in:
Bobby Holley 2016-11-30 19:36:08 -08:00
parent 4cb3404c09
commit 80460cc549
27 changed files with 502 additions and 474 deletions

View file

@ -4,14 +4,17 @@
//! Implements sequential traversal over the DOM tree.
use dom::TNode;
use traversal::{DomTraversalContext, PerLevelTraversalData};
use dom::{TElement, TNode};
use traversal::{DomTraversalContext, PerLevelTraversalData, PreTraverseToken};
pub fn traverse_dom<N, C>(root: N,
shared: &C::SharedContext)
pub fn traverse_dom<N, C>(root: N::ConcreteElement,
shared: &C::SharedContext,
token: PreTraverseToken)
where N: TNode,
C: DomTraversalContext<N>
{
debug_assert!(token.should_traverse());
fn doit<'a, N, C>(context: &'a C, node: N, data: &mut PerLevelTraversalData)
where N: TNode,
C: DomTraversalContext<N>
@ -29,7 +32,7 @@ pub fn traverse_dom<N, C>(root: N,
}
}
if context.needs_postorder_traversal() {
if C::needs_postorder_traversal() {
context.process_postorder(node);
}
}
@ -37,8 +40,13 @@ pub fn traverse_dom<N, C>(root: N,
let mut data = PerLevelTraversalData {
current_dom_depth: None,
};
let context = C::new(shared, root.opaque());
doit::<N, C>(&context, root, &mut data);
let context = C::new(shared, root.as_node().opaque());
if token.should_skip_root() {
C::traverse_children(root, |kid| doit::<N, C>(&context, kid, &mut data));
} else {
doit::<N, C>(&context, root.as_node(), &mut data);
}
// Clear the local LRU cache since we store stateful elements inside.
context.local_context().style_sharing_candidate_cache.borrow_mut().clear();