pub struct Stylesheet {
pub rules: Vec<Rule>,
pub at_rules: Vec<AtRule>,
}Expand description
A parsed stylesheet.
Fields§
§rules: Vec<Rule>Rules in source order. Each rule may live inside a @media
block (recorded via Rule::media).
at_rules: Vec<AtRule>At-rules the cascade does not implement, in source order. See
CARRIED_AT_RULES for which ones are kept.
Implementations§
Source§impl Stylesheet
impl Stylesheet
Sourcepub fn class_invalidation_set(&self) -> HashSet<String>
pub fn class_invalidation_set(&self) -> HashSet<String>
Returns the union of class names appearing in any selector. The runtime class-change reapply path uses this as a fast-rejection set: when none of the changed classes are in the returned set, the respawn is skipped.
Sourcepub fn uses_sibling_combinators(&self) -> bool
pub fn uses_sibling_combinators(&self) -> bool
Whether any selector steps across siblings (+ or ~), at the top
level or inside :is() / :where() / :not(). Only then does a
walk that re-resolves elements need to hand each one its siblings.
Sourcepub fn root_vars(&self) -> HashMap<String, String>
pub fn root_vars(&self) -> HashMap<String, String>
Every top-level :root { --name: value } custom-property
declaration in the stylesheet, folded in rule order (last wins).
Structural variants (:root.dark { ... }) are excluded - only the
plain, unconditional :root selector counts - so the result never
depends on runtime class state. That is what a caller resolving
var() before any element exists to run a real cascade against
needs: parse-time inline-attribute substitution, and the window’s
initial GPU clear color.
A :root rule inside @media (...) is excluded entirely, not
folded in regardless of the query: there is no live MediaContext
yet at this point (before any element, let alone a window, exists),
so the honest answer is “unknown”, under which no query matches -
matching how the rest of the pre-window initial load already treats
an unresolved MediaContext (lumen_runtime::run::app_build’s own
comment: “no real OS theme / viewport yet … apply with the
best-guess default context”). Picking whichever @media variant
happens to sort last in the source (typically the dark override,
since skins write light-first) would silently prefer dark
regardless of the real OS preference. The real per-element cascade
(apply_to_element) is what actually honours @media, once
elements exist for it to re-resolve against the live context.
Sourcepub fn resolve_root_var(&self, name: &str) -> Option<String>
pub fn resolve_root_var(&self, name: &str) -> Option<String>
Resolve a single :root custom property to its fully-substituted
value (following any nested var() chain via crate::css_vars),
or None when no rule in the stylesheet defines it. See
Self::root_vars for what counts as a defining rule.
Trait Implementations§
Source§impl Clone for Stylesheet
impl Clone for Stylesheet
Source§fn clone(&self) -> Stylesheet
fn clone(&self) -> Stylesheet
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Stylesheet
impl Debug for Stylesheet
Source§impl Default for Stylesheet
impl Default for Stylesheet
Source§fn default() -> Stylesheet
fn default() -> Stylesheet
Source§impl<'de> Deserialize<'de> for Stylesheet
impl<'de> Deserialize<'de> for Stylesheet
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Stylesheet
impl RefUnwindSafe for Stylesheet
impl Send for Stylesheet
impl Sync for Stylesheet
impl Unpin for Stylesheet
impl UnsafeUnpin for Stylesheet
impl UnwindSafe for Stylesheet
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FromTemplate for T
impl<T> FromTemplate for T
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
§impl<T> Template for T
impl<T> Template for T
§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
entity context to produce a [Template::Output].§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clone.