pub(crate) trait VirtualMethods {
// Required method
fn super_type(&self) -> Option<&dyn VirtualMethods>;
// Provided methods
fn attribute_mutated(
&self,
attr: &Attr,
mutation: AttributeMutation<'_>,
can_gc: CanGc,
) { ... }
fn attribute_affects_presentational_hints(&self, attr: &Attr) -> bool { ... }
fn parse_plain_attribute(
&self,
name: &LocalName,
value: DOMString,
) -> AttrValue { ... }
fn post_connection_steps(&self) { ... }
fn bind_to_tree(&self, context: &BindContext, can_gc: CanGc) { ... }
fn unbind_from_tree(&self, context: &UnbindContext<'_>, can_gc: CanGc) { ... }
fn children_changed(&self, mutation: &ChildrenMutation<'_>) { ... }
fn handle_event(&self, event: &Event, can_gc: CanGc) { ... }
fn adopting_steps(&self, old_doc: &Document, can_gc: CanGc) { ... }
fn cloning_steps(
&self,
copy: &Node,
maybe_doc: Option<&Document>,
clone_children: CloneChildrenFlag,
can_gc: CanGc,
) { ... }
fn pop(&self) { ... }
}
Expand description
Trait to allow DOM nodes to opt-in to overriding (or adding to) common behaviours. Replicates the effect of C++ virtual methods.
Required Methods§
Sourcefn super_type(&self) -> Option<&dyn VirtualMethods>
fn super_type(&self) -> Option<&dyn VirtualMethods>
Returns self as the superclass of the implementation for this trait, if any.
Provided Methods§
Sourcefn attribute_mutated(
&self,
attr: &Attr,
mutation: AttributeMutation<'_>,
can_gc: CanGc,
)
fn attribute_mutated( &self, attr: &Attr, mutation: AttributeMutation<'_>, can_gc: CanGc, )
Called when attributes of a node are mutated. https://dom.spec.whatwg.org/#attribute-is-set https://dom.spec.whatwg.org/#attribute-is-removed
Sourcefn attribute_affects_presentational_hints(&self, attr: &Attr) -> bool
fn attribute_affects_presentational_hints(&self, attr: &Attr) -> bool
Returns true
if given attribute attr
affects style of the
given element.
Sourcefn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue
fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue
Returns the right AttrValue variant for the attribute with name name
on this element.
Sourcefn post_connection_steps(&self)
fn post_connection_steps(&self)
Invoked during a DOM tree mutation after a node becomes connected, once all related DOM tree mutations have been applied. https://dom.spec.whatwg.org/#concept-node-post-connection-ext
Sourcefn bind_to_tree(&self, context: &BindContext, can_gc: CanGc)
fn bind_to_tree(&self, context: &BindContext, can_gc: CanGc)
Called when a Node is appended to a tree, where ‘tree_connected’ indicates whether the tree is part of a Document.
Sourcefn unbind_from_tree(&self, context: &UnbindContext<'_>, can_gc: CanGc)
fn unbind_from_tree(&self, context: &UnbindContext<'_>, can_gc: CanGc)
Called when a Node is removed from a tree, where ‘tree_connected’ indicates whether the tree is part of a Document. Implements removing steps: https://dom.spec.whatwg.org/#concept-node-remove-ext
Sourcefn children_changed(&self, mutation: &ChildrenMutation<'_>)
fn children_changed(&self, mutation: &ChildrenMutation<'_>)
Called on the parent when its children are changed.
Sourcefn handle_event(&self, event: &Event, can_gc: CanGc)
fn handle_event(&self, event: &Event, can_gc: CanGc)
Called during event dispatch after the bubbling phase completes.