#[repr(C)]pub struct DynamicSelectorContext {Show 17 fields
pub os: OsCondition,
pub os_version: OsVersion,
pub desktop_env: OptionLinuxDesktopEnv,
pub de_version: u32,
pub theme: ThemeCondition,
pub media_type: MediaType,
pub viewport_width: f32,
pub viewport_height: f32,
pub container_width: f32,
pub container_height: f32,
pub container_name: OptionString,
pub prefers_reduced_motion: BoolCondition,
pub prefers_high_contrast: BoolCondition,
pub orientation: OrientationType,
pub pseudo_state: PseudoStateFlags,
pub language: AzString,
pub window_focused: bool,
}Expand description
Context for evaluating dynamic selectors
PartialEq is IMPLEMENTED MANUALLY (not derived): container_width
/ container_height use f32::NAN as the “no container” sentinel,
and derived float equality makes NaN != NaN — so two identical
contexts never compared equal, set_dynamic_selector_context’s
early return never fired, and EVERY context set paid a full author
restyle (~2-4 ms at document scale, measured by the
media_restyle_cost workbench). The manual impl compares the f32
fields by bit pattern, which treats the NaN sentinel as equal to
itself and is exactly the “did anything change” question this
equality exists to answer.
Fields§
§os: OsConditionOperating system info
os_version: OsVersion§desktop_env: OptionLinuxDesktopEnv§de_version: u32Numeric version of the active desktop environment (0 = unknown).
Used by @os(linux:gnome > 40) style selectors. A value of 0 never
satisfies any DE-version constraint, so detection can be wired up
later without breaking parsed rules.
theme: ThemeConditionTheme info
media_type: MediaTypeMedia info (from WindowState)
viewport_width: f32§viewport_height: f32§container_width: f32Container info (from parent node) NaN = no container
container_height: f32§container_name: OptionString§prefers_reduced_motion: BoolConditionAccessibility preferences
prefers_high_contrast: BoolCondition§orientation: OrientationTypeOrientation
pseudo_state: PseudoStateFlagsNode state (hover, active, focus, disabled, checked, focus_within, visited)
language: AzStringLanguage/Locale (BCP 47 tag, e.g., “en-US”, “de-DE”)
window_focused: boolWhether the window currently has focus (for :backdrop pseudo-class) When false, :backdrop styles should be applied
Implementations§
Source§impl DynamicSelectorContext
impl DynamicSelectorContext
Sourcepub fn from_system_style(system_style: &SystemStyle) -> Self
pub fn from_system_style(system_style: &SystemStyle) -> Self
Create a context from SystemStyle
Sourcepub fn with_viewport(&self, width: f32, height: f32) -> Self
pub fn with_viewport(&self, width: f32, height: f32) -> Self
Update viewport dimensions (e.g., on window resize)
Sourcepub fn with_container(
&self,
width: f32,
height: f32,
name: Option<AzString>,
) -> Self
pub fn with_container( &self, width: f32, height: f32, name: Option<AzString>, ) -> Self
Update container dimensions (for @container queries)
Sourcepub fn with_pseudo_state(&self, state: PseudoStateFlags) -> Self
pub fn with_pseudo_state(&self, state: PseudoStateFlags) -> Self
Update pseudo-state (hover, active, focus, etc.)
Sourcepub fn viewport_breakpoint_changed(
&self,
other: &Self,
breakpoints: &[f32],
) -> bool
pub fn viewport_breakpoint_changed( &self, other: &Self, breakpoints: &[f32], ) -> bool
Check if viewport changed significantly (for breakpoint detection)
Trait Implementations§
Source§impl Clone for DynamicSelectorContext
impl Clone for DynamicSelectorContext
Source§fn clone(&self) -> DynamicSelectorContext
fn clone(&self) -> DynamicSelectorContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more