Struct style::stylist::CascadeData
source · pub struct CascadeData {Show 28 fields
normal_rules: GenericElementAndPseudoRules<SelectorMap<Rule>>,
featureless_host_rules: Option<Box<GenericElementAndPseudoRules<SelectorMap<Rule>>>>,
slotted_rules: Option<Box<GenericElementAndPseudoRules<SelectorMap<Rule>>>>,
part_rules: Option<Box<GenericElementAndPseudoRules<PrecomputedHashMap<Atom, SmallVec<[Rule; 1]>>>>>,
invalidation_map: InvalidationMap,
relative_selector_invalidation_map: RelativeSelectorInvalidationMap,
attribute_dependencies: PrecomputedHashSet<LocalName>,
nth_of_class_dependencies: PrecomputedHashSet<Atom>,
nth_of_attribute_dependencies: PrecomputedHashSet<LocalName>,
nth_of_custom_state_dependencies: PrecomputedHashSet<AtomIdent>,
state_dependencies: ElementState,
nth_of_state_dependencies: ElementState,
document_state_dependencies: DocumentState,
mapped_ids: PrecomputedHashSet<Atom>,
nth_of_mapped_ids: PrecomputedHashSet<Atom>,
selectors_for_cache_revalidation: SelectorMap<RevalidationSelectorAndHashes>,
animations: LayerOrderedMap<KeyframesAnimation>,
custom_property_registrations: LayerOrderedMap<Arc<PropertyRegistration>>,
layer_id: FxHashMap<LayerName, LayerId>,
layers: SmallVec<[CascadeLayer; 1]>,
container_conditions: SmallVec<[ContainerConditionReference; 1]>,
scope_conditions: SmallVec<[ScopeConditionReference; 1]>,
scope_subject_map: ScopeSubjectMap,
effective_media_query_results: EffectiveMediaQueryResults,
extra_data: ExtraStyleData,
rules_source_order: u32,
num_selectors: usize,
num_declarations: usize,
}
Expand description
Data resulting from performing the CSS cascade that is specific to a given origin.
FIXME(emilio): Consider renaming and splitting in CascadeData
and
InvalidationData
? That’d make clear_cascade_data()
clearer.
Fields§
§normal_rules: GenericElementAndPseudoRules<SelectorMap<Rule>>
The data coming from normal style rules that apply to elements at this cascade level.
featureless_host_rules: Option<Box<GenericElementAndPseudoRules<SelectorMap<Rule>>>>
The :host
pseudo rules that are the rightmost selector (without
accounting for pseudo-elements), or :scope
rules that may match
the featureless host.
slotted_rules: Option<Box<GenericElementAndPseudoRules<SelectorMap<Rule>>>>
The data coming from ::slotted() pseudo-element rules.
We need to store them separately because an element needs to match ::slotted() pseudo-element rules in different shadow roots.
In particular, we need to go through all the style data in all the containing style scopes starting from the closest assigned slot.
part_rules: Option<Box<GenericElementAndPseudoRules<PrecomputedHashMap<Atom, SmallVec<[Rule; 1]>>>>>
The data coming from ::part() pseudo-element rules.
We need to store them separately because an element needs to match ::part() pseudo-element rules in different shadow roots.
invalidation_map: InvalidationMap
The invalidation map for these rules.
relative_selector_invalidation_map: RelativeSelectorInvalidationMap
The relative selector equivalent of the invalidation map.
attribute_dependencies: PrecomputedHashSet<LocalName>
The attribute local names that appear in attribute selectors. Used to avoid taking element snapshots when an irrelevant attribute changes. (We don’t bother storing the namespace, since namespaced attributes are rare.)
nth_of_class_dependencies: PrecomputedHashSet<Atom>
The classes that appear in the selector list of
:nth-child(… of
nth_of_attribute_dependencies: PrecomputedHashSet<LocalName>
The attributes that appear in the selector list of
:nth-child(… of
nth_of_custom_state_dependencies: PrecomputedHashSet<AtomIdent>
The custom states that appear in the selector list of
:nth-child(… of
state_dependencies: ElementState
The element state bits that are relied on by selectors. Like
attribute_dependencies
, this is used to avoid taking element snapshots
when an irrelevant element state bit changes.
nth_of_state_dependencies: ElementState
The element state bits that are relied on by selectors that appear in
the selector list of :nth-child(… of
document_state_dependencies: DocumentState
The document state bits that are relied on by selectors. This is used to tell whether we need to restyle the entire document when a document state bit changes.
mapped_ids: PrecomputedHashSet<Atom>
The ids that appear in the rightmost complex selector of selectors (and hence in our selector maps). Used to determine when sharing styles is safe: we disallow style sharing for elements whose id matches this filter, and hence might be in one of our selector maps.
nth_of_mapped_ids: PrecomputedHashSet<Atom>
The IDs that appear in the selector list of
:nth-child(… of
selectors_for_cache_revalidation: SelectorMap<RevalidationSelectorAndHashes>
Selectors that require explicit cache revalidation (i.e. which depend on state that is not otherwise visible to the cache, like attributes or tree-structural state like child index and pseudos).
animations: LayerOrderedMap<KeyframesAnimation>
A map with all the animations at this CascadeData
’s origin, indexed
by name.
custom_property_registrations: LayerOrderedMap<Arc<PropertyRegistration>>
A map with all the layer-ordered registrations from style at this CascadeData
’s origin,
indexed by name.
layer_id: FxHashMap<LayerName, LayerId>
A map from cascade layer name to layer order.
layers: SmallVec<[CascadeLayer; 1]>
The list of cascade layers, indexed by their layer id.
container_conditions: SmallVec<[ContainerConditionReference; 1]>
The list of container conditions, indexed by their id.
scope_conditions: SmallVec<[ScopeConditionReference; 1]>
The list of scope conditions, indexed by their id.
scope_subject_map: ScopeSubjectMap
Map of unique selectors on scope start selectors’ subjects.
effective_media_query_results: EffectiveMediaQueryResults
Effective media query results cached from the last rebuild.
extra_data: ExtraStyleData
Extra data, like different kinds of rules, etc.
rules_source_order: u32
A monotonically increasing counter to represent the order on which a style rule appears in a stylesheet, needed to sort them by source order.
num_selectors: usize
The total number of selectors.
num_declarations: usize
The total number of declarations.
Implementations§
source§impl CascadeData
impl CascadeData
sourcepub fn rebuild<'a, S>(
&mut self,
device: &Device,
quirks_mode: QuirksMode,
collection: SheetCollectionFlusher<'_, S>,
guard: &SharedRwLockReadGuard<'_>,
) -> Result<(), AllocErr>where
S: StylesheetInDocument + PartialEq + 'static,
pub fn rebuild<'a, S>(
&mut self,
device: &Device,
quirks_mode: QuirksMode,
collection: SheetCollectionFlusher<'_, S>,
guard: &SharedRwLockReadGuard<'_>,
) -> Result<(), AllocErr>where
S: StylesheetInDocument + PartialEq + 'static,
Rebuild the cascade data from a given SheetCollection, incrementally if possible.
sourcepub fn invalidation_map(&self) -> &InvalidationMap
pub fn invalidation_map(&self) -> &InvalidationMap
Returns the invalidation map.
sourcepub fn relative_selector_invalidation_map(
&self,
) -> &RelativeSelectorInvalidationMap
pub fn relative_selector_invalidation_map( &self, ) -> &RelativeSelectorInvalidationMap
Returns the relative selector invalidation map.
sourcepub fn has_state_dependency(&self, state: ElementState) -> bool
pub fn has_state_dependency(&self, state: ElementState) -> bool
Returns whether the given ElementState bit is relied upon by a selector of some rule.
sourcepub fn has_nth_of_custom_state_dependency(&self, state: &AtomIdent) -> bool
pub fn has_nth_of_custom_state_dependency(&self, state: &AtomIdent) -> bool
Returns whether the given Custom State is relied upon by a selector
of some rule in the selector list of :nth-child(… of
sourcepub fn has_nth_of_state_dependency(&self, state: ElementState) -> bool
pub fn has_nth_of_state_dependency(&self, state: ElementState) -> bool
Returns whether the given ElementState bit is relied upon by a selector
of some rule in the selector list of :nth-child(… of
sourcepub fn might_have_attribute_dependency(&self, local_name: &LocalName) -> bool
pub fn might_have_attribute_dependency(&self, local_name: &LocalName) -> bool
Returns whether the given attribute might appear in an attribute selector of some rule.
sourcepub fn might_have_nth_of_id_dependency(&self, id: &Atom) -> bool
pub fn might_have_nth_of_id_dependency(&self, id: &Atom) -> bool
Returns whether the given ID might appear in an ID selector in the
selector list of :nth-child(… of
sourcepub fn might_have_nth_of_class_dependency(&self, class: &Atom) -> bool
pub fn might_have_nth_of_class_dependency(&self, class: &Atom) -> bool
Returns whether the given class might appear in a class selector in the
selector list of :nth-child(… of
sourcepub fn might_have_nth_of_attribute_dependency(
&self,
local_name: &LocalName,
) -> bool
pub fn might_have_nth_of_attribute_dependency( &self, local_name: &LocalName, ) -> bool
Returns whether the given attribute might appear in an attribute
selector in the selector list of :nth-child(… of
sourcepub fn normal_rules(
&self,
pseudo: Option<&PseudoElement>,
) -> Option<&SelectorMap<Rule>>
pub fn normal_rules( &self, pseudo: Option<&PseudoElement>, ) -> Option<&SelectorMap<Rule>>
Returns the normal rule map for a given pseudo-element.
sourcepub fn featureless_host_rules(
&self,
pseudo: Option<&PseudoElement>,
) -> Option<&SelectorMap<Rule>>
pub fn featureless_host_rules( &self, pseudo: Option<&PseudoElement>, ) -> Option<&SelectorMap<Rule>>
Returns the featureless pseudo rule map for a given pseudo-element.
sourcepub fn any_featureless_host_rules(&self) -> bool
pub fn any_featureless_host_rules(&self) -> bool
Whether there’s any featureless rule that could match in this scope.
sourcepub fn slotted_rules(
&self,
pseudo: Option<&PseudoElement>,
) -> Option<&SelectorMap<Rule>>
pub fn slotted_rules( &self, pseudo: Option<&PseudoElement>, ) -> Option<&SelectorMap<Rule>>
Returns the slotted rule map for a given pseudo-element.
sourcepub fn any_slotted_rule(&self) -> bool
pub fn any_slotted_rule(&self) -> bool
Whether there’s any ::slotted rule that could match in this scope.
sourcepub fn part_rules(
&self,
pseudo: Option<&PseudoElement>,
) -> Option<&PrecomputedHashMap<Atom, SmallVec<[Rule; 1]>>>
pub fn part_rules( &self, pseudo: Option<&PseudoElement>, ) -> Option<&PrecomputedHashMap<Atom, SmallVec<[Rule; 1]>>>
Returns the parts rule map for a given pseudo-element.
sourcepub fn any_part_rule(&self) -> bool
pub fn any_part_rule(&self) -> bool
Whether there’s any ::part rule that could match in this scope.
fn layer_order_for(&self, id: LayerId) -> LayerOrder
pub(crate) fn container_condition_matches<E>(
&self,
id: ContainerConditionId,
stylist: &Stylist,
element: E,
context: &mut MatchingContext<'_, E::Impl>,
) -> boolwhere
E: TElement,
pub(crate) fn find_scope_proximity_if_matching<E: TElement>( &self, rule: &Rule, stylist: &Stylist, element: E, context: &mut MatchingContext<'_, E::Impl>, ) -> ScopeProximity
fn scope_condition_matches<E>(
&self,
id: ScopeConditionId,
stylist: &Stylist,
element: E,
override_matches_shadow_host_for_part: bool,
context: &mut MatchingContext<'_, E::Impl>,
) -> ScopeRootCandidateswhere
E: TElement,
fn did_finish_rebuild(&mut self)
fn shrink_maps_if_needed(&mut self)
fn compute_layer_order(&mut self)
sourcefn collect_applicable_media_query_results_into<S>(
device: &Device,
stylesheet: &S,
guard: &SharedRwLockReadGuard<'_>,
results: &mut Vec<MediaListKey>,
contents_list: &mut Vec<StylesheetContentsPtr>,
)where
S: StylesheetInDocument + 'static,
fn collect_applicable_media_query_results_into<S>(
device: &Device,
stylesheet: &S,
guard: &SharedRwLockReadGuard<'_>,
results: &mut Vec<MediaListKey>,
contents_list: &mut Vec<StylesheetContentsPtr>,
)where
S: StylesheetInDocument + 'static,
Collects all the applicable media query results into results
.
This duplicates part of the logic in add_stylesheet
, which is
a bit unfortunate.
FIXME(emilio): With a bit of smartness in
media_feature_affected_matches
, we could convert
EffectiveMediaQueryResults
into a vector without too much effort.
fn add_styles( &mut self, selectors: &SelectorList<SelectorImpl>, declarations: &Arc<Locked<PropertyDeclarationBlock>>, ancestor_selectors: Option<&SelectorList<SelectorImpl>>, containing_rule_state: &ContainingRuleState, replaced_selectors: Option<&mut SmallVec<[Selector<SelectorImpl>; 4]>>, guard: &SharedRwLockReadGuard<'_>, rebuild_kind: SheetRebuildKind, precomputed_pseudo_element_decls: Option<&mut PerPseudoElementMap<Vec<ApplicableDeclarationBlock>>>, quirks_mode: QuirksMode, ) -> Result<(), AllocErr>
fn add_rule_list<S>(
&mut self,
rules: Iter<'_, CssRule>,
device: &Device,
quirks_mode: QuirksMode,
stylesheet: &S,
sheet_index: usize,
guard: &SharedRwLockReadGuard<'_>,
rebuild_kind: SheetRebuildKind,
containing_rule_state: &mut ContainingRuleState,
precomputed_pseudo_element_decls: Option<&mut PerPseudoElementMap<Vec<ApplicableDeclarationBlock>>>,
) -> Result<(), AllocErr>where
S: StylesheetInDocument + 'static,
fn add_stylesheet<S>(
&mut self,
device: &Device,
quirks_mode: QuirksMode,
stylesheet: &S,
sheet_index: usize,
guard: &SharedRwLockReadGuard<'_>,
rebuild_kind: SheetRebuildKind,
precomputed_pseudo_element_decls: Option<&mut PerPseudoElementMap<Vec<ApplicableDeclarationBlock>>>,
) -> Result<(), AllocErr>where
S: StylesheetInDocument + 'static,
sourcepub fn media_feature_affected_matches<S>(
&self,
stylesheet: &S,
guard: &SharedRwLockReadGuard<'_>,
device: &Device,
quirks_mode: QuirksMode,
) -> boolwhere
S: StylesheetInDocument + 'static,
pub fn media_feature_affected_matches<S>(
&self,
stylesheet: &S,
guard: &SharedRwLockReadGuard<'_>,
device: &Device,
quirks_mode: QuirksMode,
) -> boolwhere
S: StylesheetInDocument + 'static,
Returns whether all the media-feature affected values matched before and match now in the given stylesheet.
sourcepub fn custom_property_registrations(
&self,
) -> &LayerOrderedMap<Arc<PropertyRegistration>>
pub fn custom_property_registrations( &self, ) -> &LayerOrderedMap<Arc<PropertyRegistration>>
Returns the custom properties map.
fn revalidate_scopes<E: TElement>( &self, stylist: &Stylist, element: &E, matching_context: &mut MatchingContext<'_, E::Impl>, result: &mut ScopeRevalidationResult, )
sourcefn clear_cascade_data(&mut self)
fn clear_cascade_data(&mut self)
Clears the cascade data, but not the invalidation data.
fn clear(&mut self)
Trait Implementations§
source§impl CascadeDataCacheEntry for CascadeData
impl CascadeDataCacheEntry for CascadeData
source§fn rebuild<S>(
device: &Device,
quirks_mode: QuirksMode,
collection: SheetCollectionFlusher<'_, S>,
guard: &SharedRwLockReadGuard<'_>,
old: &Self,
) -> Result<Arc<Self>, AllocErr>where
S: StylesheetInDocument + PartialEq + 'static,
fn rebuild<S>(
device: &Device,
quirks_mode: QuirksMode,
collection: SheetCollectionFlusher<'_, S>,
guard: &SharedRwLockReadGuard<'_>,
old: &Self,
) -> Result<Arc<Self>, AllocErr>where
S: StylesheetInDocument + PartialEq + 'static,
source§impl Clone for CascadeData
impl Clone for CascadeData
source§fn clone(&self) -> CascadeData
fn clone(&self) -> CascadeData
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for CascadeData
impl Debug for CascadeData
source§impl Default for CascadeData
impl Default for CascadeData
source§impl MallocSizeOf for CascadeData
impl MallocSizeOf for CascadeData
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Auto Trait Implementations§
impl Freeze for CascadeData
impl !RefUnwindSafe for CascadeData
impl Send for CascadeData
impl Sync for CascadeData
impl Unpin for CascadeData
impl !UnwindSafe for CascadeData
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more