Skip to main content

CompiledStyleSheet

Struct CompiledStyleSheet 

Source
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: u64

Generation counter — incremented when compiled from a new stylesheet.

Implementations§

Source§

impl CompiledStyleSheet

Source

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.

Source

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:

  1. Candidate rules are collected from the relevant buckets (type, each class, id, and universal).
  2. Rule indices are deduplicated.
  3. For each unique rule, the first matching selector’s specificity is used (mirroring the break in StyleSheet::matching_rules).
  4. Rules are sorted by (specificity, source_order) ascending and applied in that order (last-writer-wins per property).

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.