pub struct TreeBuilder<Handle, Sink> {
Show 17 fields opts: TreeBuilderOpts, pub sink: Sink, mode: InsertionMode, orig_mode: Option<InsertionMode>, template_modes: Vec<InsertionMode>, pending_table_text: Vec<(SplitStatus, StrTendril)>, quirks_mode: QuirksMode, doc_handle: Handle, open_elems: Vec<Handle>, active_formatting: Vec<FormatEntry<Handle>>, head_elem: Option<Handle>, form_elem: Option<Handle>, frameset_ok: bool, ignore_lf: bool, foster_parenting: bool, context_elem: Option<Handle>, current_line: u64,
}
Expand description

The HTML tree builder.

Fields§

§opts: TreeBuilderOpts

Options controlling the behavior of the tree builder.

§sink: Sink

Consumer of tree modifications.

§mode: InsertionMode

Insertion mode.

§orig_mode: Option<InsertionMode>

Original insertion mode, used by Text and InTableText modes.

§template_modes: Vec<InsertionMode>

Stack of template insertion modes.

§pending_table_text: Vec<(SplitStatus, StrTendril)>

Pending table character tokens.

§quirks_mode: QuirksMode

Quirks mode as set by the parser. FIXME: can scripts etc. change this?

§doc_handle: Handle

The document node, which is created by the sink.

§open_elems: Vec<Handle>

Stack of open elements, most recently added at end.

§active_formatting: Vec<FormatEntry<Handle>>

List of active formatting elements.

§head_elem: Option<Handle>

Head element pointer.

§form_elem: Option<Handle>

Form element pointer.

§frameset_ok: bool

Frameset-ok flag.

§ignore_lf: bool

Ignore a following U+000A LINE FEED?

§foster_parenting: bool

Is foster parenting enabled?

§context_elem: Option<Handle>

The context element for the fragment parsing algorithm.

§current_line: u64

Track current line

Implementations§

source§

impl<Handle, Sink> TreeBuilder<Handle, Sink>where Handle: Clone, Sink: TreeSink<Handle = Handle>,

source

pub fn new(sink: Sink, opts: TreeBuilderOpts) -> TreeBuilder<Handle, Sink>

Create a new tree builder which sends tree modifications to a particular TreeSink.

The tree builder is also a TokenSink.

source

pub fn new_for_fragment( sink: Sink, context_elem: Handle, form_elem: Option<Handle>, opts: TreeBuilderOpts ) -> TreeBuilder<Handle, Sink>

Create a new tree builder which sends tree modifications to a particular TreeSink. This is for parsing fragments.

The tree builder is also a TokenSink.

source

pub fn tokenizer_state_for_context_elem(&self) -> State

source

pub fn trace_handles(&self, tracer: &dyn Tracer<Handle = Handle>)

Call the Tracer’s trace_handle method on every Handle in the tree builder’s internal state. This is intended to support garbage-collected DOMs.

source

fn dump_state(&self, label: String)

source

fn debug_step(&self, mode: InsertionMode, token: &Token)

source

fn process_to_completion(&mut self, token: Token) -> TokenSinkResult<Handle>

source

pub fn is_fragment(&self) -> bool

Are we parsing a HTML fragment?

source

fn appropriate_place_for_insertion( &mut self, override_target: Option<Handle> ) -> InsertionPoint<Handle>

https://html.spec.whatwg.org/multipage/#appropriate-place-for-inserting-a-node

source

fn insert_at( &mut self, insertion_point: InsertionPoint<Handle>, child: NodeOrText<Handle> )

Trait Implementations§

source§

impl<Handle, Sink> TokenSink for TreeBuilder<Handle, Sink>where Handle: Clone, Sink: TreeSink<Handle = Handle>,

§

type Handle = Handle

source§

fn process_token( &mut self, token: Token, line_number: u64 ) -> TokenSinkResult<Handle>

Process a token.
source§

fn end(&mut self)

source§

fn adjusted_current_node_present_but_not_in_html_namespace(&self) -> bool

Used in the markup declaration open state. By default, this always returns false and thus all CDATA sections are tokenized as bogus comments. https://html.spec.whatwg.org/multipage/#markup-declaration-open-state

Auto Trait Implementations§

§

impl<Handle, Sink> !RefUnwindSafe for TreeBuilder<Handle, Sink>

§

impl<Handle, Sink> !Send for TreeBuilder<Handle, Sink>

§

impl<Handle, Sink> !Sync for TreeBuilder<Handle, Sink>

§

impl<Handle, Sink> Unpin for TreeBuilder<Handle, Sink>where Handle: Unpin, Sink: Unpin,

§

impl<Handle, Sink> UnwindSafe for TreeBuilder<Handle, Sink>where Handle: UnwindSafe, Sink: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.