Trait style::invalidation::element::element_wrapper::ElementSnapshot [] [src]

pub trait ElementSnapshot: Sized {
    fn state(&self) -> Option<ElementState>;
fn has_attrs(&self) -> bool;
fn id_attr(&self) -> Option<Atom>;
fn has_class(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool;
fn each_class<F>(&self, _: F)
    where
        F: FnMut(&Atom)
;
fn lang_attr(&self) -> Option<AttrValue>; }

In order to compute restyle hints, we perform a selector match against a list of partial selectors whose rightmost simple selector may be sensitive to the thing being changed. We do this matching twice, once for the element as it exists now and once for the element as it existed at the time of the last restyle. If the results of the selector match differ, that means that the given partial selector is sensitive to the change, and we compute a restyle hint based on its combinator.

In order to run selector matching against the old element state, we generate a wrapper for the element which claims to have the old state. This is the ElementWrapper logic below.

Gecko does this differently for element states, and passes a mask called mStateMask, which indicates the states that need to be ignored during selector matching. This saves an ElementWrapper allocation and an additional selector match call at the expense of additional complexity inside the selector matching logic. This only works for boolean states though, so we still need to take the ElementWrapper approach for attribute-dependent style. So we do it the same both ways for now to reduce complexity, but it's worth measuring the performance impact (if any) of the mStateMask approach.

Required Methods

The state of the snapshot, if any.

If this snapshot contains attribute information.

The ID attribute per this snapshot. Should only be called if has_attrs() returns true.

Whether this snapshot contains the class name. Should only be called if has_attrs() returns true.

A callback that should be called for each class of the snapshot. Should only be called if has_attrs() returns true.

The xml:lang="" or lang="" attribute value per this snapshot.

Implementors