Struct style::data::ElementData
source · pub struct ElementData {
pub styles: ElementStyles,
pub damage: RestyleDamage,
pub hint: RestyleHint,
pub flags: ElementDataFlags,
}
Expand description
Style system data associated with an Element.
In Gecko, this hangs directly off the Element. Servo, this is embedded inside of layout data, which itself hangs directly off the Element. In both cases, it is wrapped inside an AtomicRefCell to ensure thread safety.
Fields§
§styles: ElementStyles
The styles for the element and its pseudo-elements.
damage: RestyleDamage
The restyle damage, indicating what kind of layout changes are required afte restyling.
hint: RestyleHint
The restyle hint, which indicates whether selectors need to be rematched for this element, its children, and its descendants.
flags: ElementDataFlags
Flags.
Implementations§
source§impl ElementData
impl ElementData
sourcepub fn invalidate_style_if_needed<'a, E: TElement>(
&mut self,
element: E,
shared_context: &SharedStyleContext<'_>,
stack_limit_checker: Option<&StackLimitChecker>,
selector_caches: &'a mut SelectorCaches,
) -> InvalidationResult
pub fn invalidate_style_if_needed<'a, E: TElement>( &mut self, element: E, shared_context: &SharedStyleContext<'_>, stack_limit_checker: Option<&StackLimitChecker>, selector_caches: &'a mut SelectorCaches, ) -> InvalidationResult
Invalidates style for this element, its descendants, and later siblings, based on the snapshot of the element that we took when attributes or state changed.
sourcepub fn has_styles(&self) -> bool
pub fn has_styles(&self) -> bool
Returns true if this element has styles.
Returns this element’s styles as resolved styles to use for sharing.
Returns this element’s primary style as a resolved style to use for sharing.
sourcepub fn set_styles(&mut self, new_styles: ResolvedElementStyles) -> ElementStyles
pub fn set_styles(&mut self, new_styles: ResolvedElementStyles) -> ElementStyles
Sets a new set of styles, returning the old ones.
sourcepub fn restyle_kind(
&self,
shared_context: &SharedStyleContext<'_>,
) -> Option<RestyleKind>
pub fn restyle_kind( &self, shared_context: &SharedStyleContext<'_>, ) -> Option<RestyleKind>
Returns the kind of restyling that we’re going to need to do on this element, based of the stored restyle hint.
sourcefn restyle_kind_for_animation(
&self,
shared_context: &SharedStyleContext<'_>,
) -> Option<RestyleKind>
fn restyle_kind_for_animation( &self, shared_context: &SharedStyleContext<'_>, ) -> Option<RestyleKind>
Returns the kind of restyling for animation-only restyle.
sourcepub fn clear_restyle_state(&mut self)
pub fn clear_restyle_state(&mut self)
Drops any restyle state from the element.
FIXME(bholley): The only caller of this should probably just assert that the hint is empty and call clear_flags_and_damage().
sourcepub fn clear_restyle_flags_and_damage(&mut self)
pub fn clear_restyle_flags_and_damage(&mut self)
Drops restyle flags and damage from the element.
sourcepub fn set_restyled(&mut self)
pub fn set_restyled(&mut self)
Mark this element as restyled, which is useful to know whether we need to do a post-traversal.
sourcepub fn is_restyle(&self) -> bool
pub fn is_restyle(&self) -> bool
Returns true if this element was restyled.
sourcepub fn set_traversed_without_styling(&mut self)
pub fn set_traversed_without_styling(&mut self)
Mark that we traversed this element without computing any style for it.
sourcepub fn contains_restyle_data(&self) -> bool
pub fn contains_restyle_data(&self) -> bool
Returns whether this element has been part of a restyle.
sourcepub fn safe_for_cousin_sharing(&self) -> bool
pub fn safe_for_cousin_sharing(&self) -> bool
Returns whether it is safe to perform cousin sharing based on the ComputedValues identity of the primary style in this ElementData. There are a few subtle things to check.
First, if a parent element was already styled and we traversed past it without restyling it, that may be because our clever invalidation logic was able to prove that the styles of that element would remain unchanged despite changes to the id or class attributes. However, style sharing relies on the strong guarantee that all the classes and ids up the respective parent chains are identical. As such, if we skipped styling for one (or both) of the parents on this traversal, we can’t share styles across cousins. Note that this is a somewhat conservative check. We could tighten it by having the invalidation logic explicitly flag elements for which it ellided styling.
Second, we want to only consider elements whose ComputedValues match due to a hit in the style sharing cache, rather than due to the rule-node-based reuse that happens later in the styling pipeline. The former gives us the stronger guarantees we need for style sharing, the latter does not.
sourcepub fn may_have_starting_style(&self) -> bool
pub fn may_have_starting_style(&self) -> bool
Returns true if this element data may need to compute the starting style for CSS transitions.
Trait Implementations§
source§impl Debug for ElementData
impl Debug for ElementData
source§impl Default for ElementData
impl Default for ElementData
source§fn default() -> ElementData
fn default() -> ElementData
Auto Trait Implementations§
impl Freeze for ElementData
impl !RefUnwindSafe for ElementData
impl Send for ElementData
impl Sync for ElementData
impl Unpin for ElementData
impl !UnwindSafe for ElementData
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> 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