Struct style::data::ElementData
[−]
[src]
pub struct ElementData { pub styles: ElementStyles, pub damage: RestyleDamage, pub hint: RestyleHint, pub flags: ElementDataFlags, }
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.
Methods
impl ElementData
[src]
pub fn invalidate_style_if_needed<'a, E: TElement>(
&mut self,
element: E,
shared_context: &SharedStyleContext,
stack_limit_checker: Option<&StackLimitChecker>,
nth_index_cache: &mut NthIndexCache
) -> InvalidationResult
[src]
&mut self,
element: E,
shared_context: &SharedStyleContext,
stack_limit_checker: Option<&StackLimitChecker>,
nth_index_cache: &mut NthIndexCache
) -> 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.
pub fn has_styles(&self) -> bool
[src]
Returns true if this element has styles.
[src]
Returns this element's styles as resolved styles to use for sharing.
[src]
Returns this element's primary style as a resolved style to use for sharing.
pub fn set_styles(&mut self, new_styles: ResolvedElementStyles) -> ElementStyles
[src]
Sets a new set of styles, returning the old ones.
pub fn restyle_kind(&self, shared_context: &SharedStyleContext) -> RestyleKind
[src]
Returns the kind of restyling that we're going to need to do on this element, based of the stored restyle hint.
pub fn important_rules_are_different(
&self,
rules: &StrongRuleNode,
guards: &StylesheetGuards
) -> bool
[src]
&self,
rules: &StrongRuleNode,
guards: &StylesheetGuards
) -> bool
Return true if important rules are different. We use this to make sure the cascade of off-main thread animations is correct. Note: Ignore custom properties for now because we only support opacity and transform properties for animations running on compositor. Actually, we only care about opacity and transform for now, but it's fine to compare all properties and let the user the check which properties do they want. If it costs too much, get_properties_overriding_animations() should return a set containing only opacity and transform properties.
pub fn clear_restyle_state(&mut self)
[src]
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().
pub fn clear_restyle_flags_and_damage(&mut self)
[src]
Drops restyle flags and damage from the element.
pub fn reconstructed_self(&self) -> bool
[src]
Returns whether this element is going to be reconstructed.
pub fn set_restyled(&mut self)
[src]
Mark this element as restyled, which is useful to know whether we need to do a post-traversal.
pub fn is_restyle(&self) -> bool
[src]
Returns true if this element was restyled.
pub fn set_traversed_without_styling(&mut self)
[src]
Mark that we traversed this element without computing any style for it.
pub fn traversed_without_styling(&self) -> bool
[src]
Returns whether the element was traversed without computing any style for it.
pub fn contains_restyle_data(&self) -> bool
[src]
Returns whether this element has been part of a restyle.
pub fn safe_for_cousin_sharing(&self) -> bool
[src]
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.
Trait Implementations
impl Debug for ElementData
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Default for ElementData
[src]
fn default() -> ElementData
[src]
Returns the "default value" for a type. Read more