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§

source

fn super_type(&self) -> Option<&dyn VirtualMethods>

Returns self as the superclass of the implementation for this trait, if any.

Provided Methods§

source

fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation<'_>)

source

fn attribute_affects_presentational_hints(&self, attr: &Attr) -> bool

Returns true if given attribute attr affects style of the given element.

source

fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue

Returns the right AttrValue variant for the attribute with name name on this element.

source

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.

source

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

source

fn children_changed(&self, mutation: &ChildrenMutation<'_>)

Called on the parent when its children are changed.

source

fn handle_event(&self, event: &Event)

Called during event dispatch after the bubbling phase completes.

source

fn adopting_steps(&self, old_doc: &Document)

source

fn cloning_steps( &self, copy: &Node, maybe_doc: Option<&Document>, clone_children: CloneChildrenFlag, )

source

fn pop(&self)

Called on an element when it is popped off the stack of open elements of a parser.

Implementors§

source§

impl VirtualMethods for DocumentFragment

source§

impl VirtualMethods for Element

source§

impl VirtualMethods for EventTarget

source§

impl VirtualMethods for HTMLAnchorElement

source§

impl VirtualMethods for HTMLAreaElement

source§

impl VirtualMethods for HTMLBaseElement

source§

impl VirtualMethods for HTMLBodyElement

source§

impl VirtualMethods for HTMLButtonElement

source§

impl VirtualMethods for HTMLCanvasElement

source§

impl VirtualMethods for HTMLDetailsElement

source§

impl VirtualMethods for HTMLElement

source§

impl VirtualMethods for HTMLFieldSetElement

source§

impl VirtualMethods for HTMLFontElement

source§

impl VirtualMethods for HTMLFormElement

source§

impl VirtualMethods for HTMLHeadElement

source§

impl VirtualMethods for HTMLHRElement

source§

impl VirtualMethods for HTMLIFrameElement

source§

impl VirtualMethods for HTMLImageElement

source§

impl VirtualMethods for HTMLInputElement

source§

impl VirtualMethods for HTMLLabelElement

source§

impl VirtualMethods for HTMLLegendElement

source§

impl VirtualMethods for HTMLLIElement

source§

impl VirtualMethods for HTMLLinkElement

source§

impl VirtualMethods for HTMLMediaElement

source§

impl VirtualMethods for HTMLMetaElement

source§

impl VirtualMethods for HTMLObjectElement

source§

impl VirtualMethods for HTMLOptGroupElement

source§

impl VirtualMethods for HTMLOptionElement

source§

impl VirtualMethods for HTMLOutputElement

source§

impl VirtualMethods for HTMLPreElement

source§

impl VirtualMethods for HTMLScriptElement

source§

impl VirtualMethods for HTMLSelectElement

source§

impl VirtualMethods for HTMLSourceElement

source§

impl VirtualMethods for HTMLStyleElement

source§

impl VirtualMethods for HTMLTableCellElement

source§

impl VirtualMethods for HTMLTableColElement

source§

impl VirtualMethods for HTMLTableElement

source§

impl VirtualMethods for HTMLTableRowElement

source§

impl VirtualMethods for HTMLTableSectionElement

source§

impl VirtualMethods for HTMLTemplateElement

source§

impl VirtualMethods for HTMLTextAreaElement

source§

impl VirtualMethods for HTMLTitleElement

source§

impl VirtualMethods for HTMLVideoElement

source§

impl VirtualMethods for Node

source§

impl VirtualMethods for ShadowRoot

source§

impl VirtualMethods for SVGElement

source§

impl VirtualMethods for SVGGraphicsElement

source§

impl VirtualMethods for SVGSVGElement