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 ). Used to avoid restyling siblings of an element when an irrelevant class changes.

§nth_of_attribute_dependencies: PrecomputedHashSet<LocalName>

The attributes that appear in the selector list of :nth-child(… of ). Used to avoid restyling siblings of an element when an irrelevant attribute changes.

§nth_of_custom_state_dependencies: PrecomputedHashSet<AtomIdent>

The custom states that appear in the selector list of :nth-child(… of ). Used to avoid restyling siblings of an element when an irrelevant custom state changes.

§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 ). Used to avoid restyling siblings of an element when an irrelevant ID changes.

§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

source

pub fn new() -> Self

Creates an empty CascadeData.

source

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.

source

pub fn invalidation_map(&self) -> &InvalidationMap

Returns the invalidation map.

source

pub fn relative_selector_invalidation_map( &self, ) -> &RelativeSelectorInvalidationMap

Returns the relative selector invalidation map.

source

pub fn has_state_dependency(&self, state: ElementState) -> bool

Returns whether the given ElementState bit is relied upon by a selector of some rule.

source

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 ).

source

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 ).

source

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.

source

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 ).

source

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 ).

source

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 ).

source

pub fn normal_rules( &self, pseudo: Option<&PseudoElement>, ) -> Option<&SelectorMap<Rule>>

Returns the normal rule map for a given pseudo-element.

source

pub fn featureless_host_rules( &self, pseudo: Option<&PseudoElement>, ) -> Option<&SelectorMap<Rule>>

Returns the featureless pseudo rule map for a given pseudo-element.

source

pub fn any_featureless_host_rules(&self) -> bool

Whether there’s any featureless rule that could match in this scope.

source

pub fn slotted_rules( &self, pseudo: Option<&PseudoElement>, ) -> Option<&SelectorMap<Rule>>

Returns the slotted rule map for a given pseudo-element.

source

pub fn any_slotted_rule(&self) -> bool

Whether there’s any ::slotted rule that could match in this scope.

source

pub fn part_rules( &self, pseudo: Option<&PseudoElement>, ) -> Option<&PrecomputedHashMap<Atom, SmallVec<[Rule; 1]>>>

Returns the parts rule map for a given pseudo-element.

source

pub fn any_part_rule(&self) -> bool

Whether there’s any ::part rule that could match in this scope.

source

fn layer_order_for(&self, id: LayerId) -> LayerOrder

source

pub(crate) fn container_condition_matches<E>( &self, id: ContainerConditionId, stylist: &Stylist, element: E, context: &mut MatchingContext<'_, E::Impl>, ) -> bool
where E: TElement,

source

pub(crate) fn find_scope_proximity_if_matching<E: TElement>( &self, rule: &Rule, stylist: &Stylist, element: E, context: &mut MatchingContext<'_, E::Impl>, ) -> ScopeProximity

source

fn scope_condition_matches<E>( &self, id: ScopeConditionId, stylist: &Stylist, element: E, override_matches_shadow_host_for_part: bool, context: &mut MatchingContext<'_, E::Impl>, ) -> ScopeRootCandidates
where E: TElement,

source

fn did_finish_rebuild(&mut self)

source

fn shrink_maps_if_needed(&mut self)

source

fn compute_layer_order(&mut self)

source

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.

source

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>

source

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,

source

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,

source

pub fn media_feature_affected_matches<S>( &self, stylesheet: &S, guard: &SharedRwLockReadGuard<'_>, device: &Device, quirks_mode: QuirksMode, ) -> bool
where S: StylesheetInDocument + 'static,

Returns whether all the media-feature affected values matched before and match now in the given stylesheet.

source

pub fn custom_property_registrations( &self, ) -> &LayerOrderedMap<Arc<PropertyRegistration>>

Returns the custom properties map.

source

fn revalidate_scopes<E: TElement>( &self, stylist: &Stylist, element: &E, matching_context: &mut MatchingContext<'_, E::Impl>, result: &mut ScopeRevalidationResult, )

source

fn clear_cascade_data(&mut self)

Clears the cascade data, but not the invalidation data.

source

fn clear(&mut self)

Trait Implementations§

source§

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,

Rebuilds the cascade data for the new stylesheet collection. The collection is guaranteed to be dirty.
source§

impl Clone for CascadeData

source§

fn clone(&self) -> CascadeData

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for CascadeData

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for CascadeData

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl MallocSizeOf for CascadeData

source§

fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize

Measure the heap usage of all descendant heap-allocated structures, but not the space taken up by the value itself.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> MaybeBoxed<Box<T>> for T

source§

fn maybe_boxed(self) -> Box<T>

Convert
source§

impl<T> MaybeBoxed<T> for T

source§

fn maybe_boxed(self) -> T

Convert
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T