#[repr(C)]pub struct DynamicSelectorContext {Show 22 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,
pub safe_area_top: f32,
pub safe_area_right: f32,
pub safe_area_bottom: f32,
pub safe_area_left: f32,
pub keyboard_inset_height: f32,
}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
safe_area_top: f32The safe-area insets env(safe-area-inset-*) resolves against, in
logical px. NaN = the platform reported NO inset for that edge, so
an env() on it takes its fallback (or 0px without one) - the same
“absent” sentinel container_width uses, compared by bit pattern in
PartialEq below so an unchanged context still short-circuits the
restyle. Fed from LayoutWindow::safe_area_insets (the shells’
single authority) via Self::with_safe_area; a rotation or a
keyboard changes these, the context stops comparing equal, and the
author cascade re-runs - which is how every env() value follows
the live inset without any per-property invalidation.
safe_area_right: f32§safe_area_bottom: f32§safe_area_left: f32§keyboard_inset_height: f32env(keyboard-inset-height): how much of the window the on-screen
keyboard covers from the bottom (SafeAreaInsets::keyboard). NaN
when no keyboard is up.
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_safe_area(&self, insets: &SafeAreaInsets) -> Self
pub fn with_safe_area(&self, insets: &SafeAreaInsets) -> Self
Carry the window’s live safe-area insets, so env(safe-area-inset-*)
and env(keyboard-inset-height) resolve against them.
Each edge becomes its absolute pixel value; an edge the platform did
not report (None) - or one carrying a relative unit, which no shell
writes - becomes the NaN “absent” sentinel, so env() falls back.
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