Struct style::invalidation::stylesheets::StylesheetInvalidationSet
source · pub struct StylesheetInvalidationSet {
classes: MaybeCaseInsensitiveHashMap<Atom, InvalidationKind>,
ids: MaybeCaseInsensitiveHashMap<Atom, InvalidationKind>,
local_names: PrecomputedHashMap<SelectorLocalName, InvalidationKind>,
fully_invalid: bool,
}
Expand description
A set of invalidations due to stylesheet additions.
TODO(emilio): We might be able to do the same analysis for media query changes too (or even selector changes?).
Fields§
§classes: MaybeCaseInsensitiveHashMap<Atom, InvalidationKind>
§ids: MaybeCaseInsensitiveHashMap<Atom, InvalidationKind>
§local_names: PrecomputedHashMap<SelectorLocalName, InvalidationKind>
§fully_invalid: bool
Implementations§
source§impl StylesheetInvalidationSet
impl StylesheetInvalidationSet
sourcepub fn invalidate_fully(&mut self)
pub fn invalidate_fully(&mut self)
Mark the DOM tree styles’ as fully invalid.
fn shrink_if_needed(&mut self)
sourcepub fn collect_invalidations_for<S>(
&mut self,
device: &Device,
stylesheet: &S,
guard: &SharedRwLockReadGuard<'_>
)where
S: StylesheetInDocument,
pub fn collect_invalidations_for<S>(
&mut self,
device: &Device,
stylesheet: &S,
guard: &SharedRwLockReadGuard<'_>
)where
S: StylesheetInDocument,
Analyze the given stylesheet, and collect invalidations from their rules, in order to avoid doing a full restyle when we style the document next time.
sourcepub fn flush<E>(
&mut self,
document_element: Option<E>,
snapshots: Option<&SnapshotMap>
) -> boolwhere
E: TElement,
pub fn flush<E>(
&mut self,
document_element: Option<E>,
snapshots: Option<&SnapshotMap>
) -> boolwhere
E: TElement,
Clears the invalidation set, invalidating elements as needed if
document_element
is provided.
Returns true if any invalidations ocurred.
fn invalidation_kind_for<E>(
&self,
element: E,
snapshot: Option<&Snapshot>,
quirks_mode: QuirksMode
) -> InvalidationKindwhere
E: TElement,
fn process_invalidations<E>(
&self,
element: E,
snapshots: Option<&SnapshotMap>
) -> boolwhere
E: TElement,
sourcefn process_invalidations_in_subtree<E>(
&self,
element: E,
snapshots: Option<&SnapshotMap>,
quirks_mode: QuirksMode
) -> boolwhere
E: TElement,
fn process_invalidations_in_subtree<E>(
&self,
element: E,
snapshots: Option<&SnapshotMap>,
quirks_mode: QuirksMode
) -> boolwhere
E: TElement,
Process style invalidations in a given subtree. This traverses the subtree looking for elements that match the invalidations in our hash map members.
Returns whether it invalidated at least one element’s style.
sourcefn scan_component(
component: &Component<SelectorImpl>,
invalidation: &mut Option<Invalidation>
)
fn scan_component(
component: &Component<SelectorImpl>,
invalidation: &mut Option<Invalidation>
)
TODO(emilio): Reuse the bucket stuff from selectormap? That handles :is() / :where() etc.
sourcefn collect_invalidations(
&mut self,
selector: &Selector<SelectorImpl>,
quirks_mode: QuirksMode
)
fn collect_invalidations(
&mut self,
selector: &Selector<SelectorImpl>,
quirks_mode: QuirksMode
)
Collect invalidations for a given selector.
We look at the outermost local name, class, or ID selector to the left of an ancestor combinator, in order to restyle only a given subtree.
If the selector has no ancestor combinator, then we do the same for the only sequence it has, but record it as an element invalidation instead of a subtree invalidation.
We prefer IDs to classs, and classes to local names, on the basis that the former should be more specific than the latter. We also prefer to generate subtree invalidations for the outermost part of the selector, to reduce the amount of traversal we need to do when flushing invalidations.
fn insert_invalidation(
&mut self,
invalidation: Invalidation,
kind: InvalidationKind,
quirks_mode: QuirksMode
) -> bool
sourcepub fn rule_changed<S>(
&mut self,
stylesheet: &S,
rule: &CssRule,
guard: &SharedRwLockReadGuard<'_>,
device: &Device,
quirks_mode: QuirksMode,
change_kind: RuleChangeKind
)where
S: StylesheetInDocument,
pub fn rule_changed<S>(
&mut self,
stylesheet: &S,
rule: &CssRule,
guard: &SharedRwLockReadGuard<'_>,
device: &Device,
quirks_mode: QuirksMode,
change_kind: RuleChangeKind
)where
S: StylesheetInDocument,
Collects invalidations for a given CSS rule, if not fully invalid already.
TODO(emilio): we can’t check whether the rule is inside a non-effective subtree, we potentially could do that.
sourcefn collect_invalidations_for_rule(
&mut self,
rule: &CssRule,
guard: &SharedRwLockReadGuard<'_>,
device: &Device,
quirks_mode: QuirksMode
)
fn collect_invalidations_for_rule(
&mut self,
rule: &CssRule,
guard: &SharedRwLockReadGuard<'_>,
device: &Device,
quirks_mode: QuirksMode
)
Collects invalidations for a given CSS rule.