Trait script::dom::virtualmethods::VirtualMethods
source · pub trait VirtualMethods {
// Required method
fn super_type(&self) -> Option<&dyn VirtualMethods>;
// Provided methods
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation<'_>) { ... }
fn attribute_affects_presentational_hints(&self, attr: &Attr) -> bool { ... }
fn parse_plain_attribute(
&self,
name: &LocalName,
value: DOMString,
) -> AttrValue { ... }
fn bind_to_tree(&self, context: &BindContext) { ... }
fn unbind_from_tree(&self, context: &UnbindContext<'_>) { ... }
fn children_changed(&self, mutation: &ChildrenMutation<'_>) { ... }
fn handle_event(&self, event: &Event) { ... }
fn adopting_steps(&self, old_doc: &Document) { ... }
fn cloning_steps(
&self,
copy: &Node,
maybe_doc: Option<&Document>,
clone_children: CloneChildrenFlag,
) { ... }
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<'_>)
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation<'_>)
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 bind_to_tree(&self, context: &BindContext)
fn bind_to_tree(&self, context: &BindContext)
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<'_>)
fn unbind_from_tree(&self, context: &UnbindContext<'_>)
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)
fn handle_event(&self, event: &Event)
Called during event dispatch after the bubbling phase completes.