Struct html5ever::tree_builder::TreeBuilder
source · pub struct TreeBuilder<Handle, Sink> {Show 17 fields
opts: TreeBuilderOpts,
pub sink: Sink,
mode: Cell<InsertionMode>,
orig_mode: Cell<Option<InsertionMode>>,
template_modes: RefCell<Vec<InsertionMode>>,
pending_table_text: RefCell<Vec<(SplitStatus, StrTendril)>>,
quirks_mode: Cell<QuirksMode>,
doc_handle: Handle,
open_elems: RefCell<Vec<Handle>>,
active_formatting: RefCell<Vec<FormatEntry<Handle>>>,
head_elem: RefCell<Option<Handle>>,
form_elem: RefCell<Option<Handle>>,
frameset_ok: Cell<bool>,
ignore_lf: Cell<bool>,
foster_parenting: Cell<bool>,
context_elem: RefCell<Option<Handle>>,
current_line: Cell<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: Cell<InsertionMode>
Insertion mode.
orig_mode: Cell<Option<InsertionMode>>
Original insertion mode, used by Text and InTableText modes.
template_modes: RefCell<Vec<InsertionMode>>
Stack of template insertion modes.
pending_table_text: RefCell<Vec<(SplitStatus, StrTendril)>>
Pending table character tokens.
quirks_mode: Cell<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: RefCell<Vec<Handle>>
Stack of open elements, most recently added at end.
active_formatting: RefCell<Vec<FormatEntry<Handle>>>
List of active formatting elements.
head_elem: RefCell<Option<Handle>>
Head element pointer.
form_elem: RefCell<Option<Handle>>
Form element pointer.
frameset_ok: Cell<bool>
Frameset-ok flag.
ignore_lf: Cell<bool>
Ignore a following U+000A LINE FEED?
foster_parenting: Cell<bool>
Is foster parenting enabled?
context_elem: RefCell<Option<Handle>>
The context element for the fragment parsing algorithm.
current_line: Cell<u64>
Track current line
Implementations§
source§impl<Handle, Sink> TreeBuilder<Handle, Sink>
impl<Handle, Sink> TreeBuilder<Handle, Sink>
sourcepub fn new(sink: Sink, opts: TreeBuilderOpts) -> TreeBuilder<Handle, Sink>
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
.
sourcepub fn new_for_fragment(
sink: Sink,
context_elem: Handle,
form_elem: Option<Handle>,
opts: TreeBuilderOpts,
) -> TreeBuilder<Handle, Sink>
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
.
pub fn tokenizer_state_for_context_elem(&self) -> State
sourcepub fn trace_handles(&self, tracer: &dyn Tracer<Handle = Handle>)
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.
fn dump_state(&self, label: String)
fn debug_step(&self, mode: InsertionMode, token: &Token)
fn process_to_completion(&self, token: Token) -> TokenSinkResult<Handle>
sourcepub fn is_fragment(&self) -> bool
pub fn is_fragment(&self) -> bool
Are we parsing a HTML fragment?
sourcefn appropriate_place_for_insertion(
&self,
override_target: Option<Handle>,
) -> InsertionPoint<Handle>
fn appropriate_place_for_insertion( &self, override_target: Option<Handle>, ) -> InsertionPoint<Handle>
https://html.spec.whatwg.org/multipage/#appropriate-place-for-inserting-a-node