#[repr(C)]pub struct Css {
pub rules: CssRuleBlockVec,
}Expand description
Css stylesheet - contains a parsed CSS stylesheet in “rule blocks”, i.e. blocks of key-value pairs associated with a selector path.
Layer separation (UA / system / author / inline / runtime) is encoded
per-rule via CssRuleBlock::priority; see rule_priority for the
slot allocation. There is no separate Stylesheet wrapper — to merge
two CSS sources, concatenate their rules and re-sort.
Fields§
§rules: CssRuleBlockVecAll rule blocks, in source order. Sort by (priority, specificity)
via sort_by_specificity to put them in cascade order.
Implementations§
Source§impl Css
impl Css
pub fn is_empty(&self) -> bool
pub fn new(rules: Vec<CssRuleBlock>) -> Self
pub fn from_string(s: AzString) -> Self
Sourcepub fn parse_inline(style: &str) -> Self
pub fn parse_inline(style: &str) -> Self
Parse inline-style CSS (bare properties, pseudo blocks, @-rule blocks)
and return a Css whose rules carry rule_priority::INLINE.
Wraps the input in * { ... } so the main CSS parser can handle bare
properties at the top level. Pseudo and at-rule blocks like
:hover { color: red; } or @os(linux) { font-size: 14px; } work
directly via CSS nesting.
pub fn from_string_with_warnings( s: AzString, ) -> (Self, Vec<CssParseWarnMsgOwned>)
Source§impl Css
impl Css
Sourcepub fn sort_by_specificity(&mut self)
pub fn sort_by_specificity(&mut self)
Sort the rules by (priority, specificity) so they apply in cascade order.
Lower-priority rules sort first; ties break by selector specificity.
This preserves layer identity (UA / SYSTEM / AUTHOR / INLINE / RUNTIME)
without needing a separate Stylesheet boundary.
pub fn rules<'a>(&'a self) -> Iter<'a, CssRuleBlock>
Sourcepub fn iter_inline_properties<'a>(
&'a self,
) -> impl Iterator<Item = (&'a CssProperty, &'a DynamicSelectorVec)> + 'a
pub fn iter_inline_properties<'a>( &'a self, ) -> impl Iterator<Item = (&'a CssProperty, &'a DynamicSelectorVec)> + 'a
Iterate (property, conditions) pairs as if this were a flat list of
CssPropertyWithConditions. Each Static declaration yields one item,
sharing the conditions of its enclosing rule. Dynamic declarations
are skipped (matching the previous inline-CSS behaviour).
Used by cascade and diff code that walks per-property to keep the flat-iteration shape after the inline-vs-component unification.
Trait Implementations§
Source§impl Extend<Css> for CssVec
impl Extend<Css> for CssVec
Source§fn extend<T: IntoIterator<Item = Css>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Css>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl From<CssPropertyWithConditionsVec> for Css
Convert a flat list of CssPropertyWithConditions (the legacy inline-CSS form)
into a Css. Each property becomes a single-declaration CssRuleBlock with
priority = INLINE, an empty path (implicitly :scope — applies to the node it
lives on), and the original conditions intact.
impl From<CssPropertyWithConditionsVec> for Css
Convert a flat list of CssPropertyWithConditions (the legacy inline-CSS form)
into a Css. Each property becomes a single-declaration CssRuleBlock with
priority = INLINE, an empty path (implicitly :scope — applies to the node it
lives on), and the original conditions intact.
This bridge lets widget code that built &[CssPropertyWithConditions] arrays
keep working through .into() while the storage on NodeData is the unified
Css type.