pub struct CompiledStyleSheet {
pub generation: u64,
/* private fields */
}Expand description
A compiled stylesheet: rules indexed into buckets keyed by their primary selector part so that widget→style resolution is ~O(1) for common cases.
Rules are stored by-index in the rules vec; each bucket holds a sorted
list of rule indices. Dedup is applied during lookup so a rule whose
selector list covers multiple buckets is only counted once.
Construct via CompiledStyleSheet::compile.
Fields§
§generation: u64Generation counter — incremented when compiled from a new stylesheet.
Implementations§
Source§impl CompiledStyleSheet
impl CompiledStyleSheet
Sourcepub fn compile(sheet: &StyleSheet, generation: u64) -> Self
pub fn compile(sheet: &StyleSheet, generation: u64) -> Self
Compile a parsed StyleSheet into a CompiledStyleSheet.
generation is stored on the struct and used by StyleCache
to detect when a compiled stylesheet has changed.
Sourcepub fn compute_style(
&self,
widget_type: &str,
classes: &[&str],
id: Option<&str>,
) -> ComputedStyle
pub fn compute_style( &self, widget_type: &str, classes: &[&str], id: Option<&str>, ) -> ComputedStyle
Compute the final ComputedStyle for a widget.
The result is semantically identical to StyleSheet::compute_style:
- Candidate rules are collected from the relevant buckets (type, each class, id, and universal).
- Rule indices are deduplicated.
- For each unique rule, the first matching selector’s specificity is used
(mirroring the
breakinStyleSheet::matching_rules). - Rules are sorted by
(specificity, source_order)ascending and applied in that order (last-writer-wins per property).
Auto Trait Implementations§
impl Freeze for CompiledStyleSheet
impl RefUnwindSafe for CompiledStyleSheet
impl Send for CompiledStyleSheet
impl Sync for CompiledStyleSheet
impl Unpin for CompiledStyleSheet
impl UnsafeUnpin for CompiledStyleSheet
impl UnwindSafe for CompiledStyleSheet
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
Mutably borrows from an owned value. Read more