Trait html5ever::tree_builder::TreeSink [] [src]

pub trait TreeSink {
    type Handle: Clone;
    type Output;
    fn finish(self) -> Self::Output;
    fn parse_error(&mut self, msg: Cow<'static, str>);
    fn get_document(&mut self) -> Self::Handle;
    fn elem_name(&'a self, target: &'a Self::Handle) -> ExpandedName<'a>;
    fn create_element(
        &mut self,
        name: QualName,
        attrs: Vec<Attribute>,
        flags: ElementFlags
    ) -> Self::Handle; fn create_comment(&mut self, text: Tendril<UTF8, NonAtomic>) -> Self::Handle; fn create_pi(
        &mut self,
        target: Tendril<UTF8, NonAtomic>,
        data: Tendril<UTF8, NonAtomic>
    ) -> Self::Handle; fn append(&mut self, parent: &Self::Handle, child: NodeOrText<Self::Handle>); fn append_doctype_to_document(
        &mut self,
        name: Tendril<UTF8, NonAtomic>,
        public_id: Tendril<UTF8, NonAtomic>,
        system_id: Tendril<UTF8, NonAtomic>
    ); fn get_template_contents(&mut self, target: &Self::Handle) -> Self::Handle; fn same_node(&self, x: &Self::Handle, y: &Self::Handle) -> bool; fn set_quirks_mode(&mut self, mode: QuirksMode); fn has_parent_node(&self, node: &Self::Handle) -> bool; fn append_before_sibling(
        &mut self,
        sibling: &Self::Handle,
        new_node: NodeOrText<Self::Handle>
    ); fn add_attrs_if_missing(
        &mut self,
        target: &Self::Handle,
        attrs: Vec<Attribute>
    ); fn remove_from_parent(&mut self, target: &Self::Handle); fn reparent_children(
        &mut self,
        node: &Self::Handle,
        new_parent: &Self::Handle
    ); fn mark_script_already_started(&mut self, _node: &Self::Handle) { ... } fn pop(&mut self, _node: &Self::Handle) { ... } fn same_tree(&self, _x: &Self::Handle, _y: &Self::Handle) -> bool { ... } fn associate_with_form(
        &mut self,
        _target: &Self::Handle,
        _form: &Self::Handle
    ) { ... } fn is_mathml_annotation_xml_integration_point(
        _handle: &Self::Handle
    ) -> bool { ... } fn set_current_line(&mut self, _line_number: u64) { ... } fn complete_script(&mut self, _node: &Self::Handle) -> NextParserState { ... } }

Associated Types

Handle is a reference to a DOM node. The tree builder requires that a Handle implements Clone to get another reference to the same node.

The overall result of parsing.

This should default to Self, but default associated types are not stable yet. (

Required Methods

Consume this sink and return the overall result of parsing.

TODO:This should default to fn finish(self) -> Self::Output { self }, but default associated types are not stable yet. (

Signal a parse error.

Get a handle to the Document node.

What is the name of this element?

Should never be called on a non-element node; feel free to panic!.

Create an element.

When creating a template element (name.ns.expanded() == expanded_name!(html "template")), an associated document fragment called the "template contents" should also be created. Later calls to self.get_template_contents() with that given element return it.

Create a comment node.

Create a Processing Instruction node.

Append a node as the last child of the given node. If this would produce adjacent sibling text nodes, it should concatenate the text instead.

The child node will not already have a parent.

Append a DOCTYPE element to the Document node.

Get a handle to a template's template contents. The tree builder promises this will never be called with something else than a template element.

Do two handles refer to the same node?

Set the document's quirks mode.

Does the node have a parent?

Append a node as the sibling immediately before the given node. This method will only be called if has_parent_node(sibling) is true

The tree builder promises that sibling is not a text node. However its old previous sibling, which would become the new node's previous sibling, could be a text node. If the new node is also a text node, the two should be merged, as in the behavior of append.

NB: new_node may have an old parent, from which it should be removed.

Add each attribute to the given element, if no attribute with that name already exists. The tree builder promises this will never be called with something else than an element.

Detach the given node from its parent.

Remove all the children from node and append them to new_parent.

Provided Methods

Mark a HTML <script> as "already started".

Indicate that a node was popped off the stack of open elements.

Are two handles present in the same tree

Associate the given form-associatable element with the form element

Returns true if the adjusted current node is an HTML integration point and the token is a start tag.

Called whenever the line number changes.

Indicate that a script element is complete.