pub struct StyleReason {
pub flags: StyleReasonFlags,
pub selectors: Option<StyleSelectors>,
pub classes_changed: Option<SmallVec<[StyleClassRef; 4]>>,
pub targets: Vec<(ElementId, StyleReason)>,
}Expand description
Describes why a view has been marked style-dirty. Combines a cheap bitmap of reason categories with optional payloads for the reasons that carry associated data.
The flags are the primary signal used to decide how much work style_view needs
to do. The payload fields provide the details needed to actually do that work.
Invariants:
selectors.is_some()iffflags.contains(SELECTOR)targets.is_empty()iff!flags.contains(TARGET)
Fields§
§flags: StyleReasonFlags§selectors: Option<StyleSelectors>The selector set that caused this view to be dirty. Present when SELECTOR is set.
Stored so that the style pass can skip resolve_nested_maps if the selectors that
changed don’t actually affect any properties (e.g. a :hover selector exists but
none of the now-hovered selectors match any style rules on this view).
classes_changed: Option<SmallVec<[StyleClassRef; 4]>>§targets: Vec<(ElementId, StyleReason)>Sub-element rectangles owned by this view that need targeted restyling.
Each entry is (element_id, reason) where element_id identifies a specific
box-tree rectangle (e.g. the vertical scrollbar of a scroll view) and reason
describes why that rectangle is dirty (typically SELECTOR due to hover/press
state change on that specific hit region).
Present when TARGET is set. SmallVec<2> because most views with sub-elements
have only a small fixed number of them (e.g. scroll view has 3 total, rarely more
than 2 dirty simultaneously).
Implementations§
Source§impl StyleReason
impl StyleReason
pub fn empty() -> Self
pub fn with_selectors(selectors: StyleSelectors) -> Self
pub fn with_selector(selector: StyleSelector) -> Self
pub fn is_empty(&self) -> bool
pub fn set_inherited(&mut self)
pub fn set_class_cx(&mut self)
pub fn set_animation(&mut self)
pub fn set_transition(&mut self)
pub fn set_style_pass(&mut self)
pub fn set_view_style(&mut self)
pub fn set_visibility(&mut self)
pub fn set_selectors(&mut self, selectors: StyleSelectors)
pub fn add_target(&mut self, id: ElementId, reason: StyleReason)
pub fn animation() -> Self
pub fn style_pass() -> Self
pub fn view_style() -> Self
pub fn visibility() -> Self
pub fn transition() -> Self
pub fn inherited() -> Self
pub fn class_cx(classes: SmallVec<[StyleClassRef; 4]>) -> Self
Sourcepub fn needs_resolve_nested_maps(&self) -> bool
pub fn needs_resolve_nested_maps(&self) -> bool
Returns true if this reason set requires a full cascade recomputation
(i.e. resolve_nested_maps must run). False means only animation/transition
stepping is needed and the cached combined_style can be reused.
pub fn needs_animation(&self) -> bool
pub fn needs_property_extraction(&self) -> bool
pub fn has_animation(&self) -> bool
pub fn has_visiblity(&self) -> bool
pub fn has_transition(&self) -> bool
pub fn has_selector(&self) -> bool
pub fn has_target(&self) -> bool
pub fn has_target_id(&self, id: ElementId) -> bool
pub fn target_reason(&self, id: ElementId) -> Option<&StyleReason>
Sourcepub fn merge(&mut self, other: StyleReason)
pub fn merge(&mut self, other: StyleReason)
Merge another set into self, unioning all reasons.
Sourcepub fn filter(&self, flags: StyleReasonFlags) -> StyleReason
pub fn filter(&self, flags: StyleReasonFlags) -> StyleReason
Returns a new set containing only the reasons that match the given flags.
Sourcepub fn clear_flag(&mut self, flag: StyleReasonFlags)
pub fn clear_flag(&mut self, flag: StyleReasonFlags)
Remove a specific flag and its associated data.
pub fn clear_target(&mut self, id: ElementId)
pub fn for_children(&self) -> StyleReason
pub fn with_target(element_id: ElementId, reason: StyleReason) -> Self
pub fn with_selectors_and_target( element_id: ElementId, selectors: StyleSelectors, ) -> Self
Sourcepub fn full_recalc() -> Self
pub fn full_recalc() -> Self
All flags set — forces a full recalc with no fast paths possible. Use as a fallback when the specific reason is unknown.
Trait Implementations§
Source§impl Clone for StyleReason
impl Clone for StyleReason
Auto Trait Implementations§
impl !Send for StyleReason
impl !Sync for StyleReason
impl Freeze for StyleReason
impl RefUnwindSafe for StyleReason
impl Unpin for StyleReason
impl UnsafeUnpin for StyleReason
impl UnwindSafe for StyleReason
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more