Trait style::traversal::DomTraversal [] [src]

pub trait DomTraversal<E: TElement>: Sync {
    fn process_preorder<F>(
        &self,
        data: &PerLevelTraversalData,
        context: &mut StyleContext<E>,
        node: E::ConcreteNode,
        note_child: F
    )
    where
        F: FnMut(E::ConcreteNode)
;
fn process_postorder(
        &self,
        contect: &mut StyleContext<E>,
        node: E::ConcreteNode
    );
fn shared_context(&self) -> &SharedStyleContext; fn needs_postorder_traversal() -> bool { ... }
fn handle_postorder_traversal(
        &self,
        context: &mut StyleContext<E>,
        root: OpaqueNode,
        node: E::ConcreteNode,
        children_to_process: isize
    ) { ... }
fn pre_traverse(
        root: E,
        shared_context: &SharedStyleContext
    ) -> PreTraverseToken<E> { ... }
fn text_node_needs_traversal(
        node: E::ConcreteNode,
        _parent_data: &ElementData
    ) -> bool { ... }
fn element_needs_traversal(
        el: E,
        traversal_flags: TraversalFlags,
        data: Option<&ElementData>
    ) -> bool { ... }
fn should_cull_subtree(
        &self,
        context: &mut StyleContext<E>,
        parent: E,
        parent_data: &ElementData,
        is_initial_style: bool
    ) -> bool { ... } }

A DOM Traversal trait, that is used to generically implement styling for Gecko and Servo.

Required Methods

Process node on the way down, before its children have been processed.

The callback is invoked for each child node that should be processed by the traversal.

Process node on the way up, after its children have been processed.

This is only executed if needs_postorder_traversal returns true.

Return the shared style context common to all worker threads.

Provided Methods

Boolean that specifies whether a bottom up traversal should be performed.

If it's false, then process_postorder has no effect at all.

Handles the postorder step of the traversal, if it exists, by bubbling up the parent chain.

If we are the last child that finished processing, recursively process our parent. Else, stop. Also, stop at the root.

Thus, if we start with all the leaves of a tree, we end up traversing the whole tree bottom-up because each parent will be processed exactly once (by the last child that finishes processing).

The only communication between siblings is that they both fetch-and-subtract the parent's children count. This makes it safe to call durign the parallel traversal.

Style invalidations happen when traversing from a parent to its children. However, this mechanism can't handle style invalidations on the root. As such, we have a pre-traversal step to handle that part and determine whether a full traversal is needed.

Returns true if traversal should visit a text node. The style system never processes text nodes, but Servo overrides this to visit them for flow construction when necessary.

Returns true if traversal is needed for the given element and subtree.

Returns true if we want to cull this subtree from the travesal.

Implementors