Trait style::dom::TElement
[−]
[src]
pub trait TElement: Eq + PartialEq + Debug + Hash + Sized + Copy + Clone + SelectorsElement<Impl = SelectorImpl> { type ConcreteNode: TNode<ConcreteElement = Self>; type TraversalChildrenIterator: Iterator<Item = Self::ConcreteNode>; type FontMetricsProvider: FontMetricsProvider + Send; fn as_node(&self) -> Self::ConcreteNode; fn traversal_children(
&self
) -> LayoutIterator<Self::TraversalChildrenIterator>; fn style_attribute(
&self
) -> Option<ArcBorrow<Locked<PropertyDeclarationBlock>>>; fn get_state(&self) -> ElementState; fn has_attr(&self, namespace: &Namespace, attr: &LocalName) -> bool; fn get_id(&self) -> Option<Atom>; fn each_class<F>(&self, callback: F)
where
F: FnMut(&Atom); 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 get_data(&self) -> Option<&AtomicRefCell<ElementData>>; fn skip_root_and_item_based_display_fixup(&self) -> bool; unsafe fn set_selector_flags(&self, flags: ElementSelectorFlags); fn has_selector_flags(&self, flags: ElementSelectorFlags) -> bool; fn has_animations(&self) -> bool; fn has_css_animations(&self) -> bool; fn has_css_transitions(&self) -> bool; fn lang_attr(&self) -> Option<AttrValue>; fn match_element_lang(
&self,
override_lang: Option<Option<AttrValue>>,
value: &PseudoClassStringArg
) -> 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 owner_doc_matches_for_testing(&self, _: &Device) -> bool { ... } fn matches_user_and_author_rules(&self) -> bool { ... } fn depth(&self) -> usize { ... } fn style_scope(&self) -> Self::ConcreteNode { ... } 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 each_anonymous_content_child<F>(&self, _f: F)
where
F: FnMut(Self), { ... } fn closest_non_native_anonymous_ancestor(&self) -> Option<Self> { ... } fn unset_dirty_style_attribute(&self) { ... } fn get_smil_override(
&self
) -> Option<ArcBorrow<Locked<PropertyDeclarationBlock>>> { ... } fn get_animation_rule_by_cascade(
&self,
_cascade_level: CascadeLevel
) -> Option<Arc<Locked<PropertyDeclarationBlock>>> { ... } fn get_animation_rules(&self) -> AnimationRules { ... } fn get_animation_rule(
&self
) -> Option<Arc<Locked<PropertyDeclarationBlock>>> { ... } fn get_transition_rule(
&self
) -> Option<Arc<Locked<PropertyDeclarationBlock>>> { ... } fn may_generate_pseudo(
&self,
pseudo: &PseudoElement,
_primary_style: &ComputedValues
) -> bool { ... } fn has_current_styles_for_traversal(
&self,
data: &ElementData,
traversal_flags: TraversalFlags
) -> 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) { ... } unsafe fn clear_dirty_bits(&self) { ... } fn is_visited_link(&self) -> bool { ... } fn is_native_anonymous(&self) -> bool { ... } fn implemented_pseudo_element(&self) -> Option<PseudoElement> { ... } fn borrow_data(&self) -> Option<AtomicRef<ElementData>> { ... } fn mutate_data(&self) -> Option<AtomicRefMut<ElementData>> { ... } fn may_have_animations(&self) -> bool { ... } fn has_animation_restyle_hints(&self) -> bool { ... } fn xbl_binding_anonymous_content(&self) -> Option<Self::ConcreteNode> { ... } fn rule_hash_target(&self) -> Self { ... } fn each_xbl_stylist<'a, F>(&self, _: F) -> bool
where
Self: 'a,
F: FnMut(AtomicRef<'a, Stylist>), { ... } }
The element trait, the main abstraction the style crate acts over.
Associated Types
type ConcreteNode: TNode<ConcreteElement = Self>
The concrete node type.
type TraversalChildrenIterator: Iterator<Item = Self::ConcreteNode>
A concrete children iterator type in order to iterate over the Node
s.
TODO(emilio): We should eventually replace this with the impl Trait
syntax.
type FontMetricsProvider: FontMetricsProvider + Send
Type of the font metrics provider
XXXManishearth It would be better to make this a type parameter on ThreadLocalStyleContext and StyleContext
Required Methods
fn as_node(&self) -> Self::ConcreteNode
Get this element as a node.
fn traversal_children(&self) -> LayoutIterator<Self::TraversalChildrenIterator>
Get this node's children from the perspective of a restyle traversal.
fn style_attribute(&self) -> Option<ArcBorrow<Locked<PropertyDeclarationBlock>>>
Get this element's style attribute.
fn get_state(&self) -> ElementState
Get this element's state, for non-tree-structural pseudos.
fn has_attr(&self, namespace: &Namespace, attr: &LocalName) -> bool
Whether this element has an attribute with a given namespace.
fn get_id(&self) -> Option<Atom>
The ID for this element.
fn each_class<F>(&self, callback: F) where
F: FnMut(&Atom),
F: FnMut(&Atom),
Internal iterator for the classes of this element.
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.
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.
fn handled_snapshot(&self) -> bool
Returns whether the current snapshot if present has been handled.
unsafe fn set_handled_snapshot(&self)
Flags this element as having handled already its snapshot.
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.
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.
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.
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.
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.
unsafe fn clear_data(&self)
Clears the element data reference, if any.
Unsafe following the same reasoning as ensure_data.
fn get_data(&self) -> Option<&AtomicRefCell<ElementData>>
Gets a reference to the ElementData container.
fn skip_root_and_item_based_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.)
unsafe fn set_selector_flags(&self, flags: ElementSelectorFlags)
Sets selector flags, which indicate what kinds of selectors may have matched on this element and therefore what kind of work may need to be performed when DOM state changes.
This is unsafe, like all the flag-setting methods, because it's only safe to call with exclusive access to the element. When setting flags on the parent during parallel traversal, we use SequentialTask to queue up the set to run after the threads join.
fn has_selector_flags(&self, flags: ElementSelectorFlags) -> bool
Returns true if the element has all the specified selector flags.
fn has_animations(&self) -> 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.
fn has_css_animations(&self) -> bool
Returns true if the element has a CSS animation.
fn has_css_transitions(&self) -> bool
Returns true if the element has a CSS transition (including running transitions and completed transitions).
fn lang_attr(&self) -> Option<AttrValue>
Returns the value of the xml:lang=""
attribute (or, if appropriate,
the lang=""
attribute) on this element.
fn match_element_lang(
&self,
override_lang: Option<Option<AttrValue>>,
value: &PseudoClassStringArg
) -> bool
&self,
override_lang: Option<Option<AttrValue>>,
value: &PseudoClassStringArg
) -> 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.)
fn is_html_document_body_element(&self) -> bool
Returns whether this element is the main body element of the HTML document it is on.
fn synthesize_presentational_hints_for_legacy_attributes<V>(
&self,
visited_handling: VisitedHandlingMode,
hints: &mut V
) where
V: Push<ApplicableDeclarationBlock>,
&self,
visited_handling: VisitedHandlingMode,
hints: &mut V
) where
V: Push<ApplicableDeclarationBlock>,
Generate the proper applicable declarations due to presentational hints,
and insert them into hints
.
Provided Methods
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.
Whether this element should match user and author rules.
We use this for Native Anonymous Content in Gecko.
fn depth(&self) -> usize
Returns the depth of this element in the DOM.
fn style_scope(&self) -> Self::ConcreteNode
The style scope of this element is a node that represents which rules apply to the element.
In Servo, where we don't know about Shadow DOM or XBL, the style scope is always the document.
fn traversal_parent(&self) -> Option<Self>
Get this node's parent element from the perspective of a restyle traversal.
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.
fn before_pseudo_element(&self) -> Option<Self>
The ::before pseudo-element of this element, if it exists.
fn after_pseudo_element(&self) -> Option<Self>
The ::after pseudo-element of this element, if it exists.
fn each_anonymous_content_child<F>(&self, _f: F) where
F: FnMut(Self),
F: FnMut(Self),
Execute f
for each anonymous content child (apart from ::before and
::after) whose originating element is self
.
fn closest_non_native_anonymous_ancestor(&self) -> Option<Self>
For a given NAC element, return the closest non-NAC ancestor, which is guaranteed to exist.
fn unset_dirty_style_attribute(&self)
Unset the style attribute's dirty bit. Servo doesn't need to manage ditry bit for style attribute.
fn get_smil_override(
&self
) -> Option<ArcBorrow<Locked<PropertyDeclarationBlock>>>
&self
) -> Option<ArcBorrow<Locked<PropertyDeclarationBlock>>>
Get this element's SMIL override declarations.
fn get_animation_rule_by_cascade(
&self,
_cascade_level: CascadeLevel
) -> Option<Arc<Locked<PropertyDeclarationBlock>>>
&self,
_cascade_level: CascadeLevel
) -> Option<Arc<Locked<PropertyDeclarationBlock>>>
Get this element's animation rule by the cascade level.
fn get_animation_rules(&self) -> AnimationRules
Get the combined animation and transition rules.
fn get_animation_rule(&self) -> Option<Arc<Locked<PropertyDeclarationBlock>>>
Get this element's animation rule.
fn get_transition_rule(&self) -> Option<Arc<Locked<PropertyDeclarationBlock>>>
Get this element's transition rule.
fn may_generate_pseudo(
&self,
pseudo: &PseudoElement,
_primary_style: &ComputedValues
) -> bool
&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.
fn has_current_styles_for_traversal(
&self,
data: &ElementData,
traversal_flags: TraversalFlags
) -> bool
&self,
data: &ElementData,
traversal_flags: TraversalFlags
) -> bool
Returns whether the element's styles are up-to-date for |traversal_flags|.
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).
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.
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.
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.
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.
unsafe fn clear_dirty_bits(&self)
Clear all element flags related to dirtiness.
In Gecko, this corresponds to the regular dirty descendants bit, the animation-only dirty descendants bit, the lazy frame construction bit, and the lazy frame construction descendants bit.
fn is_visited_link(&self) -> bool
Returns true if this element is a visited link.
Servo doesn't support visited styles yet.
fn is_native_anonymous(&self) -> bool
Returns true if this element is native anonymous (only Gecko has native anonymous content).
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.
fn borrow_data(&self) -> Option<AtomicRef<ElementData>>
Immutably borrows the ElementData.
fn mutate_data(&self) -> Option<AtomicRefMut<ElementData>>
Mutably borrows the ElementData.
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.
fn has_animation_restyle_hints(&self) -> bool
Returns true if the element has animation restyle hints.
fn xbl_binding_anonymous_content(&self) -> Option<Self::ConcreteNode>
Returns the anonymous content for the current element's XBL binding, given if any.
This is used in Gecko for XBL and shadow DOM.
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.
fn each_xbl_stylist<'a, F>(&self, _: F) -> bool where
Self: 'a,
F: FnMut(AtomicRef<'a, Stylist>),
Self: 'a,
F: FnMut(AtomicRef<'a, Stylist>),
Implements Gecko's nsBindingManager::WalkRules
.
Returns whether to cut off the inheritance.