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

source

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.

source

pub fn has_styles(&self) -> bool

Returns true if this element has styles.

source

pub fn share_styles(&self) -> ResolvedElementStyles

Returns this element’s styles as resolved styles to use for sharing.

source

pub fn share_primary_style(&self) -> PrimaryStyle

Returns this element’s primary style as a resolved style to use for sharing.

source

pub fn set_styles(&mut self, new_styles: ResolvedElementStyles) -> ElementStyles

Sets a new set of styles, returning the old ones.

source

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.

source

fn restyle_kind_for_animation( &self, shared_context: &SharedStyleContext<'_>, ) -> Option<RestyleKind>

Returns the kind of restyling for animation-only restyle.

source

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().

source

pub fn clear_restyle_flags_and_damage(&mut self)

Drops restyle flags and damage from the element.

source

pub fn set_restyled(&mut self)

Mark this element as restyled, which is useful to know whether we need to do a post-traversal.

source

pub fn is_restyle(&self) -> bool

Returns true if this element was restyled.

source

pub fn set_traversed_without_styling(&mut self)

Mark that we traversed this element without computing any style for it.

source

pub fn contains_restyle_data(&self) -> bool

Returns whether this element has been part of a restyle.

source

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.

source

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

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ElementData

source§

fn default() -> ElementData

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> MaybeBoxed<Box<T>> for T

source§

fn maybe_boxed(self) -> Box<T>

Convert
source§

impl<T> MaybeBoxed<T> for T

source§

fn maybe_boxed(self) -> T

Convert
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
source§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T