Trait style::dom::TElement

source ·
pub trait TElement: Eq + PartialEq + Debug + Hash + Sized + Copy + Clone + SelectorsElement<Impl = SelectorImpl> {
    type ConcreteNode: TNode<ConcreteElement = Self>;
    type TraversalChildrenIterator: Iterator<Item = Self::ConcreteNode>;

Show 71 methods // Required methods fn unopaque(opaque: OpaqueElement) -> Self; fn as_node(&self) -> Self::ConcreteNode; fn traversal_children( &self, ) -> LayoutIterator<Self::TraversalChildrenIterator> ; fn is_html_element(&self) -> bool; fn is_mathml_element(&self) -> bool; fn is_svg_element(&self) -> bool; fn style_attribute( &self, ) -> Option<ArcBorrow<'_, Locked<PropertyDeclarationBlock>>>; fn animation_rule( &self, _: &SharedStyleContext<'_>, ) -> Option<Arc<Locked<PropertyDeclarationBlock>>>; fn transition_rule( &self, context: &SharedStyleContext<'_>, ) -> Option<Arc<Locked<PropertyDeclarationBlock>>>; fn state(&self) -> ElementState; fn has_part_attr(&self) -> bool; fn exports_any_part(&self) -> bool; fn id(&self) -> Option<&WeakAtom>; fn each_class<F>(&self, callback: F) where F: FnMut(&AtomIdent); fn each_custom_state<F>(&self, callback: F) where F: FnMut(&AtomIdent); fn each_attr_name<F>(&self, callback: F) where F: FnMut(&LocalName); fn has_dirty_descendants(&self) -> bool; fn has_snapshot(&self) -> bool; fn handled_snapshot(&self) -> bool; unsafe fn set_handled_snapshot(&self); unsafe fn set_dirty_descendants(&self); unsafe fn unset_dirty_descendants(&self); fn store_children_to_process(&self, n: isize); fn did_process_child(&self) -> isize; unsafe fn ensure_data(&self) -> AtomicRefMut<'_, ElementData>; unsafe fn clear_data(&self); fn has_data(&self) -> bool; fn borrow_data(&self) -> Option<AtomicRef<'_, ElementData>>; fn mutate_data(&self) -> Option<AtomicRefMut<'_, ElementData>>; fn skip_item_display_fixup(&self) -> bool; fn may_have_animations(&self) -> bool; fn has_animations(&self, context: &SharedStyleContext<'_>) -> bool; fn has_css_animations( &self, context: &SharedStyleContext<'_>, pseudo_element: Option<PseudoElement>, ) -> bool; fn has_css_transitions( &self, context: &SharedStyleContext<'_>, pseudo_element: Option<PseudoElement>, ) -> bool; fn shadow_root( &self, ) -> Option<<Self::ConcreteNode as TNode>::ConcreteShadowRoot>; fn containing_shadow( &self, ) -> Option<<Self::ConcreteNode as TNode>::ConcreteShadowRoot>; fn lang_attr(&self) -> Option<AttrValue>; fn match_element_lang( &self, override_lang: Option<Option<AttrValue>>, value: &Lang, ) -> bool; fn is_html_document_body_element(&self) -> bool; fn synthesize_presentational_hints_for_legacy_attributes<V>( &self, visited_handling: VisitedHandlingMode, hints: &mut V, ) where V: Push<ApplicableDeclarationBlock>; fn local_name(&self) -> &<SelectorImpl as SelectorImpl>::BorrowedLocalName; fn namespace(&self) -> &<SelectorImpl as SelectorImpl>::BorrowedNamespaceUrl; fn query_container_size(&self, display: &Display) -> Size2D<Option<Au>>; fn has_selector_flags(&self, flags: ElementSelectorFlags) -> bool; fn relative_selector_search_direction(&self) -> ElementSelectorFlags; // Provided methods fn owner_doc_matches_for_testing(&self, _: &Device) -> bool { ... } fn matches_user_and_content_rules(&self) -> bool { ... } fn traversal_parent(&self) -> Option<Self> { ... } fn inheritance_parent(&self) -> Option<Self> { ... } fn before_pseudo_element(&self) -> Option<Self> { ... } fn after_pseudo_element(&self) -> Option<Self> { ... } fn marker_pseudo_element(&self) -> Option<Self> { ... } fn each_anonymous_content_child<F>(&self, _f: F) where F: FnMut(Self) { ... } fn is_xul_element(&self) -> bool { ... } fn slotted_nodes(&self) -> &[Self::ConcreteNode] { ... } fn unset_dirty_style_attribute(&self) { ... } fn smil_override( &self, ) -> Option<ArcBorrow<'_, Locked<PropertyDeclarationBlock>>> { ... } fn animation_declarations( &self, context: &SharedStyleContext<'_>, ) -> AnimationDeclarations { ... } fn each_part<F>(&self, _callback: F) where F: FnMut(&AtomIdent) { ... } fn each_exported_part<F>(&self, _name: &AtomIdent, _callback: F) where F: FnMut(&AtomIdent) { ... } fn may_generate_pseudo( &self, pseudo: &PseudoElement, _primary_style: &ComputedValues, ) -> bool { ... } fn has_current_styles(&self, data: &ElementData) -> bool { ... } fn has_animation_only_dirty_descendants(&self) -> bool { ... } unsafe fn set_animation_only_dirty_descendants(&self) { ... } unsafe fn unset_animation_only_dirty_descendants(&self) { ... } unsafe fn clear_descendant_bits(&self) { ... } fn is_visited_link(&self) -> bool { ... } fn implemented_pseudo_element(&self) -> Option<PseudoElement> { ... } fn has_animation_restyle_hints(&self) -> bool { ... } fn rule_hash_target(&self) -> Self { ... } fn each_applicable_non_document_style_rule_data<'a, F>(&self, f: F) -> bool where Self: 'a, F: FnMut(&'a CascadeData, Self) { ... }
}
Expand description

The element trait, the main abstraction the style crate acts over.

Required Associated Types§

source

type ConcreteNode: TNode<ConcreteElement = Self>

The concrete node type.

source

type TraversalChildrenIterator: Iterator<Item = Self::ConcreteNode>

A concrete children iterator type in order to iterate over the Nodes.

TODO(emilio): We should eventually replace this with the impl Trait syntax.

Required Methods§

source

fn unopaque(opaque: OpaqueElement) -> Self

Convert an opaque element back into the element.

source

fn as_node(&self) -> Self::ConcreteNode

Get this element as a node.

source

fn traversal_children(&self) -> LayoutIterator<Self::TraversalChildrenIterator>

Get this node’s children from the perspective of a restyle traversal.

source

fn is_html_element(&self) -> bool

Return whether this element is an element in the HTML namespace.

source

fn is_mathml_element(&self) -> bool

Return whether this element is an element in the MathML namespace.

source

fn is_svg_element(&self) -> bool

Return whether this element is an element in the SVG namespace.

source

fn style_attribute( &self, ) -> Option<ArcBorrow<'_, Locked<PropertyDeclarationBlock>>>

Get this element’s style attribute.

source

fn animation_rule( &self, _: &SharedStyleContext<'_>, ) -> Option<Arc<Locked<PropertyDeclarationBlock>>>

Get this element’s animation rule.

source

fn transition_rule( &self, context: &SharedStyleContext<'_>, ) -> Option<Arc<Locked<PropertyDeclarationBlock>>>

Get this element’s transition rule.

source

fn state(&self) -> ElementState

Get this element’s state, for non-tree-structural pseudos.

source

fn has_part_attr(&self) -> bool

Returns whether this element has a part attribute.

source

fn exports_any_part(&self) -> bool

Returns whether this element exports any part from its shadow tree.

source

fn id(&self) -> Option<&WeakAtom>

The ID for this element.

source

fn each_class<F>(&self, callback: F)
where F: FnMut(&AtomIdent),

Internal iterator for the classes of this element.

source

fn each_custom_state<F>(&self, callback: F)
where F: FnMut(&AtomIdent),

Internal iterator for the classes of this element.

source

fn each_attr_name<F>(&self, callback: F)
where F: FnMut(&LocalName),

Internal iterator for the attribute names of this element.

source

fn has_dirty_descendants(&self) -> bool

Returns true if this element may have a descendant needing style processing.

Note that we cannot guarantee the existence of such an element, because it may have been removed from the DOM between marking it for restyle and the actual restyle traversal.

source

fn has_snapshot(&self) -> bool

Returns whether state or attributes that may change style have changed on the element, and thus whether the element has been snapshotted to do restyle hint computation.

source

fn handled_snapshot(&self) -> bool

Returns whether the current snapshot if present has been handled.

source

unsafe fn set_handled_snapshot(&self)

Flags this element as having handled already its snapshot.

source

unsafe fn set_dirty_descendants(&self)

Flag that this element has a descendant for style processing.

Only safe to call with exclusive access to the element.

source

unsafe fn unset_dirty_descendants(&self)

Flag that this element has no descendant for style processing.

Only safe to call with exclusive access to the element.

source

fn store_children_to_process(&self, n: isize)

Atomically stores the number of children of this node that we will need to process during bottom-up traversal.

source

fn did_process_child(&self) -> isize

Atomically notes that a child has been processed during bottom-up traversal. Returns the number of children left to process.

source

unsafe fn ensure_data(&self) -> AtomicRefMut<'_, ElementData>

Gets a reference to the ElementData container, or creates one.

Unsafe because it can race to allocate and leak if not used with exclusive access to the element.

source

unsafe fn clear_data(&self)

Clears the element data reference, if any.

Unsafe following the same reasoning as ensure_data.

source

fn has_data(&self) -> bool

Whether there is an ElementData container.

source

fn borrow_data(&self) -> Option<AtomicRef<'_, ElementData>>

Immutably borrows the ElementData.

source

fn mutate_data(&self) -> Option<AtomicRefMut<'_, ElementData>>

Mutably borrows the ElementData.

source

fn skip_item_display_fixup(&self) -> bool

Whether we should skip any root- or item-based display property blockification on this element. (This function exists so that Gecko native anonymous content can opt out of this style fixup.)

source

fn may_have_animations(&self) -> bool

In Gecko, element has a flag that represents the element may have any type of animations or not to bail out animation stuff early. Whereas Servo doesn’t have such flag.

source

fn has_animations(&self, context: &SharedStyleContext<'_>) -> bool

Returns true if the element has relevant animations. Relevant animations are those animations that are affecting the element’s style or are scheduled to do so in the future.

source

fn has_css_animations( &self, context: &SharedStyleContext<'_>, pseudo_element: Option<PseudoElement>, ) -> bool

Returns true if the element has a CSS animation. The context and pseudo_element arguments are only used by Servo, since it stores animations globally and pseudo-elements are not in the DOM.

source

fn has_css_transitions( &self, context: &SharedStyleContext<'_>, pseudo_element: Option<PseudoElement>, ) -> bool

Returns true if the element has a CSS transition (including running transitions and completed transitions). The context and pseudo_element arguments are only used by Servo, since it stores animations globally and pseudo-elements are not in the DOM.

source

fn shadow_root( &self, ) -> Option<<Self::ConcreteNode as TNode>::ConcreteShadowRoot>

The shadow root this element is a host of.

source

fn containing_shadow( &self, ) -> Option<<Self::ConcreteNode as TNode>::ConcreteShadowRoot>

The shadow root which roots the subtree this element is contained in.

source

fn lang_attr(&self) -> Option<AttrValue>

Returns the value of the xml:lang="" attribute (or, if appropriate, the lang="" attribute) on this element.

source

fn match_element_lang( &self, override_lang: Option<Option<AttrValue>>, value: &Lang, ) -> bool

Returns whether this element’s language matches the language tag value. If override_lang is not None, it specifies the value of the xml:lang="" or lang="" attribute to use in place of looking at the element and its ancestors. (This argument is used to implement matching of :lang() against snapshots.)

source

fn is_html_document_body_element(&self) -> bool

Returns whether this element is the main body element of the HTML document it is on.

source

fn synthesize_presentational_hints_for_legacy_attributes<V>( &self, visited_handling: VisitedHandlingMode, hints: &mut V, )

Generate the proper applicable declarations due to presentational hints, and insert them into hints.

source

fn local_name(&self) -> &<SelectorImpl as SelectorImpl>::BorrowedLocalName

Returns element’s local name.

source

fn namespace(&self) -> &<SelectorImpl as SelectorImpl>::BorrowedNamespaceUrl

Returns element’s namespace.

source

fn query_container_size(&self, display: &Display) -> Size2D<Option<Au>>

Returns the size of the element to be used in container size queries. This will usually be the size of the content area of the primary box, but can be None if there is no box or if some axis lacks size containment.

source

fn has_selector_flags(&self, flags: ElementSelectorFlags) -> bool

Returns true if the element has all of specified selector flags.

source

fn relative_selector_search_direction(&self) -> ElementSelectorFlags

Returns the search direction for relative selector invalidation, if it is on the search path.

Provided Methods§

source

fn owner_doc_matches_for_testing(&self, _: &Device) -> bool

A debug-only check that the device’s owner doc matches the actual doc we’re the root of.

Otherwise we may set document-level state incorrectly, like the root font-size used for rem units.

source

fn matches_user_and_content_rules(&self) -> bool

Whether this element should match user and content rules.

We use this for Native Anonymous Content in Gecko.

source

fn traversal_parent(&self) -> Option<Self>

Get this node’s parent element from the perspective of a restyle traversal.

source

fn inheritance_parent(&self) -> Option<Self>

Returns the parent element we should inherit from.

This is pretty much always the parent element itself, except in the case of Gecko’s Native Anonymous Content, which uses the traversal parent (i.e. the flattened tree parent) and which also may need to find the closest non-NAC ancestor.

source

fn before_pseudo_element(&self) -> Option<Self>

The ::before pseudo-element of this element, if it exists.

source

fn after_pseudo_element(&self) -> Option<Self>

The ::after pseudo-element of this element, if it exists.

source

fn marker_pseudo_element(&self) -> Option<Self>

The ::marker pseudo-element of this element, if it exists.

source

fn each_anonymous_content_child<F>(&self, _f: F)
where F: FnMut(Self),

Execute f for each anonymous content child (apart from ::before and ::after) whose originating element is self.

source

fn is_xul_element(&self) -> bool

Return whether this element is an element in the XUL namespace.

source

fn slotted_nodes(&self) -> &[Self::ConcreteNode]

Return the list of slotted nodes of this node.

source

fn unset_dirty_style_attribute(&self)

Unset the style attribute’s dirty bit. Servo doesn’t need to manage ditry bit for style attribute.

source

fn smil_override( &self, ) -> Option<ArcBorrow<'_, Locked<PropertyDeclarationBlock>>>

Get this element’s SMIL override declarations.

source

fn animation_declarations( &self, context: &SharedStyleContext<'_>, ) -> AnimationDeclarations

Get the combined animation and transition rules.

FIXME(emilio): Is this really useful?

source

fn each_part<F>(&self, _callback: F)
where F: FnMut(&AtomIdent),

Internal iterator for the part names of this element.

source

fn each_exported_part<F>(&self, _name: &AtomIdent, _callback: F)
where F: FnMut(&AtomIdent),

Internal iterator for the part names that this element exports for a given part name.

source

fn may_generate_pseudo( &self, pseudo: &PseudoElement, _primary_style: &ComputedValues, ) -> bool

Whether a given element may generate a pseudo-element.

This is useful to avoid computing, for example, pseudo styles for ::-first-line or ::-first-letter, when we know it won’t affect us.

TODO(emilio, bz): actually implement the logic for it.

source

fn has_current_styles(&self, data: &ElementData) -> bool

Returns whether the element’s styles are up-to-date after traversal (i.e. in post traversal).

source

fn has_animation_only_dirty_descendants(&self) -> bool

Similar to the dirty_descendants but for representing a descendant of the element needs to be updated in animation-only traversal.

source

unsafe fn set_animation_only_dirty_descendants(&self)

Flag that this element has a descendant for animation-only restyle processing.

Only safe to call with exclusive access to the element.

source

unsafe fn unset_animation_only_dirty_descendants(&self)

Flag that this element has no descendant for animation-only restyle processing.

Only safe to call with exclusive access to the element.

source

unsafe fn clear_descendant_bits(&self)

Clear all bits related describing the dirtiness of descendants.

In Gecko, this corresponds to the regular dirty descendants bit, the animation-only dirty descendants bit, and the lazy frame construction descendants bit.

Returns true if this element is a visited link.

Servo doesn’t support visited styles yet.

source

fn implemented_pseudo_element(&self) -> Option<PseudoElement>

Returns the pseudo-element implemented by this element, if any.

Gecko traverses pseudo-elements during the style traversal, and we need to know this so we can properly grab the pseudo-element style from the parent element.

Note that we still need to compute the pseudo-elements before-hand, given otherwise we don’t know if we need to create an element or not.

Servo doesn’t have to deal with this.

source

fn has_animation_restyle_hints(&self) -> bool

Returns true if the element has animation restyle hints.

source

fn rule_hash_target(&self) -> Self

Return the element which we can use to look up rules in the selector maps.

This is always the element itself, except in the case where we are an element-backed pseudo-element, in which case we return the originating element.

source

fn each_applicable_non_document_style_rule_data<'a, F>(&self, f: F) -> bool
where Self: 'a, F: FnMut(&'a CascadeData, Self),

Executes the callback for each applicable style rule data which isn’t the main document’s data (which stores UA / author rules).

The element passed to the callback is the containing shadow host for the data if it comes from Shadow DOM.

Returns whether normal document author rules should apply.

TODO(emilio): We could separate the invalidation data for elements matching in other scopes to avoid over-invalidation.

Object Safety§

This trait is not object safe.

Implementors§