8#ifndef hubbub_treebuilder_internal_h_
9#define hubbub_treebuilder_internal_h_
18 DIALOG,
DIR,
DIV,
DL,
DT,
EMBED,
FIELDSET,
FIGCAPTION,
FIGURE,
FOOTER,
19 FORM,
FRAME,
FRAMESET,
H1,
H2,
H3,
H4,
H5,
H6,
HEAD,
HEADER,
HR,
IFRAME,
20 IMAGE,
IMG,
INPUT,
ISINDEX,
LI,
LINK,
LISTING,
MAIN,
MENU,
META,
NAV,
27 A,
B,
BIG,
CODE,
EM,
FONT,
I,
NOBR,
S,
SMALL,
STRIKE,
STRONG,
TT,
U,
30 LABEL,
OUTPUT,
RP,
RT,
RUBY,
SPAN,
SUB,
SUP,
VAR,
XMP,
78#define ELEMENT_STACK_CHUNK 128
133 bool insert_into_current_node);
179 uint32_t stack_index);
183 uint32_t stack_index);
187 uint32_t *stack_index);
191 uint32_t stack_index,
193 uint32_t *ostack_index);
206 void *node,
void **inserted);
hubbub_error
Definition errors.h:18
void(* hubbub_error_handler)(uint32_t line, uint32_t col, const char *message, void *pw)
Type of parse error handling function.
Definition functypes.h:40
bool is_phrasing_element(element_type type)
Determine if a node is a phrasing element.
Definition treebuilder.c:1107
void element_stack_dump(hubbub_treebuilder *treebuilder, FILE *fp)
Dump an element stack to the given file pointer.
Definition treebuilder.c:1520
hubbub_error element_stack_push(hubbub_treebuilder *treebuilder, hubbub_ns ns, element_type type, void *node)
Push an element onto the stack of open elements.
Definition treebuilder.c:1134
hubbub_error insert_element(hubbub_treebuilder *treebuilder, const hubbub_tag *tag_name, bool push)
Create element and insert it into the DOM, potentially pushing it on the stack.
Definition treebuilder.c:810
void reset_insertion_mode(hubbub_treebuilder *treebuilder)
Reset the insertion mode.
Definition treebuilder.c:921
element_type
Definition internal.h:14
@ XMP
Definition internal.h:30
@ FORM
Definition internal.h:19
@ TITLE
Definition internal.h:23
@ HEAD
Definition internal.h:19
@ RP
Definition internal.h:30
@ NOEMBED
Definition internal.h:21
@ SPACER
Definition internal.h:22
@ LABEL
Definition internal.h:30
@ SUB
Definition internal.h:30
@ IFRAME
Definition internal.h:19
@ SELECT
Definition internal.h:22
@ TR
Definition internal.h:23
@ ISINDEX
Definition internal.h:20
@ IMG
Definition internal.h:20
@ FRAME
Definition internal.h:19
@ CENTER
Definition internal.h:17
@ UL
Definition internal.h:23
@ OUTPUT
Definition internal.h:30
@ H4
Definition internal.h:19
@ TBODY
Definition internal.h:22
@ MGLYPH
Definition internal.h:32
@ TABLE
Definition internal.h:25
@ HEADER
Definition internal.h:19
@ DATAGRID
Definition internal.h:17
@ STRONG
Definition internal.h:27
@ PLAINTEXT
Definition internal.h:21
@ IMAGE
Definition internal.h:20
@ CAPTION
Definition internal.h:25
@ NOFRAMES
Definition internal.h:21
@ MTEXT
Definition internal.h:32
@ COL
Definition internal.h:17
@ B
Definition internal.h:27
@ BODY
Definition internal.h:17
@ MAIN
Definition internal.h:20
@ A
Definition internal.h:27
@ STRIKE
Definition internal.h:27
@ FIGCAPTION
Definition internal.h:18
@ SPAN
Definition internal.h:30
@ MENU
Definition internal.h:20
@ DIALOG
Definition internal.h:18
@ BIG
Definition internal.h:27
@ DL
Definition internal.h:18
@ ADDRESS
Definition internal.h:16
@ SUP
Definition internal.h:30
@ H5
Definition internal.h:19
@ LI
Definition internal.h:20
@ CODE
Definition internal.h:27
@ EMBED
Definition internal.h:18
@ FOOTER
Definition internal.h:18
@ BR
Definition internal.h:17
@ TEXTAREA
Definition internal.h:22
@ AREA
Definition internal.h:16
@ NOBR
Definition internal.h:27
@ SCRIPT
Definition internal.h:22
@ SVG
Definition internal.h:34
@ DT
Definition internal.h:18
@ DIR
Definition internal.h:18
@ UNKNOWN
Definition internal.h:36
@ WBR
Definition internal.h:23
@ OBJECT
Definition internal.h:25
@ FIGURE
Definition internal.h:18
@ TD
Definition internal.h:25
@ PARAM
Definition internal.h:21
@ SUMMARY
Definition internal.h:22
@ BUTTON
Definition internal.h:25
@ ANNOTATION_XML
Definition internal.h:32
@ H1
Definition internal.h:19
@ BASEFONT
Definition internal.h:16
@ MN
Definition internal.h:32
@ BGSOUND
Definition internal.h:16
@ P
Definition internal.h:21
@ DIV
Definition internal.h:18
@ ARTICLE
Definition internal.h:16
@ META
Definition internal.h:20
@ MI
Definition internal.h:32
@ APPLET
Definition internal.h:25
@ OL
Definition internal.h:21
@ FONT
Definition internal.h:27
@ ASIDE
Definition internal.h:16
@ TH
Definition internal.h:25
@ MS
Definition internal.h:32
@ MO
Definition internal.h:32
@ BASE
Definition internal.h:16
@ OPTION
Definition internal.h:21
@ H6
Definition internal.h:19
@ TFOOT
Definition internal.h:23
@ OPTGROUP
Definition internal.h:21
@ EM
Definition internal.h:27
@ H3
Definition internal.h:19
@ NAV
Definition internal.h:20
@ H2
Definition internal.h:19
@ MALIGNMARK
Definition internal.h:32
@ PRE
Definition internal.h:22
@ DESC
Definition internal.h:35
@ U
Definition internal.h:27
@ DETAILS
Definition internal.h:17
@ NOSCRIPT
Definition internal.h:21
@ STYLE
Definition internal.h:22
@ SECTION
Definition internal.h:22
@ HTML
Definition internal.h:25
@ MARQUEE
Definition internal.h:25
@ FOREIGNOBJECT
Definition internal.h:34
@ I
Definition internal.h:27
@ LISTING
Definition internal.h:20
@ DD
Definition internal.h:17
@ INPUT
Definition internal.h:20
@ FRAMESET
Definition internal.h:19
@ TT
Definition internal.h:27
@ COMMAND
Definition internal.h:17
@ FIELDSET
Definition internal.h:18
@ BLOCKQUOTE
Definition internal.h:16
@ SMALL
Definition internal.h:27
@ MATH
Definition internal.h:32
@ S
Definition internal.h:27
@ LINK
Definition internal.h:20
@ RT
Definition internal.h:30
@ THEAD
Definition internal.h:23
@ VAR
Definition internal.h:30
@ HR
Definition internal.h:19
@ COLGROUP
Definition internal.h:17
@ RUBY
Definition internal.h:30
element_type element_type_from_name(hubbub_treebuilder *treebuilder, const hubbub_string *tag_name)
Convert an element name into an element type.
Definition treebuilder.c:1045
hubbub_error process_comment_append(hubbub_treebuilder *treebuilder, const hubbub_token *token, void *parent)
Process a comment token, appending it to the given parent.
Definition treebuilder.c:479
hubbub_error formatting_list_replace(hubbub_treebuilder *treebuilder, formatting_list_entry *entry, hubbub_ns ns, element_type type, void *node, uint32_t stack_index, hubbub_ns *ons, element_type *otype, void **onode, uint32_t *ostack_index)
Remove an element from the list of active formatting elements.
Definition treebuilder.c:1488
hubbub_error remove_node_from_dom(hubbub_treebuilder *treebuilder, void *node)
Remove a node from the DOM.
Definition treebuilder.c:739
hubbub_error element_stack_remove(hubbub_treebuilder *treebuilder, uint32_t index, hubbub_ns *ns, element_type *type, void **removed)
Remove a node from the stack of open elements.
Definition treebuilder.c:1249
hubbub_error aa_insert_into_foster_parent(hubbub_treebuilder *treebuilder, void *node, void **inserted)
Adoption agency: locate foster parent and insert node into it.
Definition in_body.c:2225
void clear_active_formatting_list_to_marker(hubbub_treebuilder *treebuilder)
Clear the list of active formatting elements up to the last marker.
Definition treebuilder.c:775
void adjust_svg_attributes(hubbub_treebuilder *treebuilder, hubbub_tag *tag)
Adjust SVG attributes.
Definition in_foreign_content.c:169
element_type prev_node(hubbub_treebuilder *treebuilder)
Peek at the element below the top of the element stack.
Definition treebuilder.c:1329
hubbub_error formatting_list_append(hubbub_treebuilder *treebuilder, hubbub_ns ns, element_type type, void *node, uint32_t stack_index)
Append an element to the end of the list of active formatting elements.
Definition treebuilder.c:1350
hubbub_error append_text(hubbub_treebuilder *treebuilder, const hubbub_string *string)
Append text to the current node, inserting into the last child of the current node,...
Definition treebuilder.c:1002
void adjust_foreign_attributes(hubbub_treebuilder *treebuilder, hubbub_tag *tag)
Adjust foreign attributes.
Definition in_foreign_content.c:227
void formatting_list_dump(hubbub_treebuilder *treebuilder, FILE *fp)
Dump a formatting list to the given file pointer.
Definition treebuilder.c:1539
hubbub_error element_stack_pop_until(hubbub_treebuilder *treebuilder, element_type type)
Pop elements until an element of type "element" has been popped.
Definition treebuilder.c:1220
bool is_formatting_element(element_type type)
Determine if a node is a formatting element.
Definition treebuilder.c:1096
hubbub_error hubbub_treebuilder_token_handler(const hubbub_token *token, void *pw)
Handle tokeniser emitting a token.
Definition treebuilder.c:323
uint32_t current_table(hubbub_treebuilder *treebuilder)
Find the stack index of the current table.
Definition treebuilder.c:1297
bool is_special_element(element_type type)
Determine if a node is a special element.
Definition treebuilder.c:1074
hubbub_error formatting_list_insert(hubbub_treebuilder *treebuilder, formatting_list_entry *prev, formatting_list_entry *next, hubbub_ns ns, element_type type, void *node, uint32_t stack_index)
Insert an element into the list of active formatting elements.
Definition treebuilder.c:1390
hubbub_error reconstruct_active_formatting_list(hubbub_treebuilder *treebuilder)
Reconstruct the list of active formatting elements.
Definition treebuilder.c:601
uint32_t element_in_scope(hubbub_treebuilder *treebuilder, element_type type, bool in_table)
Determine if an element is in (table) scope.
Definition treebuilder.c:558
void close_implied_end_tags(hubbub_treebuilder *treebuilder, element_type except)
Close implied end tags.
Definition treebuilder.c:887
hubbub_error element_stack_pop(hubbub_treebuilder *treebuilder, hubbub_ns *ns, element_type *type, void **node)
Pop an element off the stack of open elements.
Definition treebuilder.c:1171
bool is_scoping_element(element_type type)
Determine if a node is a scoping element.
Definition treebuilder.c:1085
void adjust_svg_tagname(hubbub_treebuilder *treebuilder, hubbub_tag *tag)
Adjust SVG tagnmes.
Definition in_foreign_content.c:199
hubbub_error parse_generic_rcdata(hubbub_treebuilder *treebuilder, const hubbub_token *token, bool rcdata)
Trigger parsing of generic (R)CDATA.
Definition treebuilder.c:522
void adjust_mathml_attributes(hubbub_treebuilder *treebuilder, hubbub_tag *tag)
Adjust MathML attributes.
Definition in_foreign_content.c:144
hubbub_error formatting_list_remove(hubbub_treebuilder *treebuilder, formatting_list_entry *entry, hubbub_ns *ns, element_type *type, void **node, uint32_t *stack_index)
Remove an element from the list of active formatting elements.
Definition treebuilder.c:1442
const char * element_type_to_name(element_type type)
Convert an element type to a name.
Definition treebuilder.c:1557
element_type current_node(hubbub_treebuilder *treebuilder)
Peek at the top element of the element stack.
Definition treebuilder.c:1317
hubbub_error process_characters_expect_whitespace(hubbub_treebuilder *treebuilder, const hubbub_token *token, bool insert_into_current_node)
Process a character token in cases where we expect only whitespace.
Definition treebuilder.c:433
hubbub_error complete_script(hubbub_treebuilder *treebuilder)
Script processing and execution.
Definition treebuilder.c:984
insertion_mode
The various treebuilder insertion modes.
Definition modes.h:15
Item on the element stack.
Definition internal.h:43
hubbub_ns ns
Element namespace.
Definition internal.h:44
void * node
Node pointer.
Definition internal.h:54
bool tainted
Only for tables.
Definition internal.h:48
uint8_t * name
Element name (interned)
Definition internal.h:46
element_type type
Element type.
Definition internal.h:45
Entry in a formatting list.
Definition internal.h:61
element_context details
Entry details.
Definition internal.h:62
struct formatting_list_entry * prev
Previous in list.
Definition internal.h:66
struct formatting_list_entry * next
Next in list.
Definition internal.h:67
uint32_t stack_index
Index into element stack.
Definition internal.h:64
Tokeniser string type.
Definition types.h:76
Data for a tag.
Definition types.h:108
Token data.
Definition types.h:119
Tokeniser data structure.
Definition tokeniser.c:165
Hubbub tree handler.
Definition tree.h:273
Context for a tree builder.
Definition internal.h:74
struct hubbub_treebuilder_context::@9 collect
Context for character collecting.
void * document
Pointer to the document node.
Definition internal.h:93
element_context * element_stack
Stack of open elements.
Definition internal.h:79
bool strip_leading_lr
Whether to strip a LR from the start of the next character sequence received.
Definition internal.h:102
insertion_mode mode
The current insertion mode.
Definition internal.h:75
uint32_t stack_alloc
Number of stack slots allocated.
Definition internal.h:80
void * head_element
Pointer to HEAD element.
Definition internal.h:88
bool frameset_ok
Whether to process a frameset.
Definition internal.h:110
insertion_mode second_mode
The secondary insertion mode.
Definition internal.h:76
formatting_list_entry * formatting_list
List of active formatting elements.
Definition internal.h:83
element_type type
Type of node.
Definition internal.h:99
bool enable_scripting
Whether scripting is enabled.
Definition internal.h:95
void * form_element
Pointer to most recently opened FORM element.
Definition internal.h:90
bool in_table_foster
Whether nodes that would be inserted into the current node should be foster parented.
Definition internal.h:106
formatting_list_entry * formatting_list_end
End of active formatting list.
Definition internal.h:85
uint32_t current_node
Index of current node in stack.
Definition internal.h:81
Treebuilder object.
Definition internal.h:117
hubbub_error_handler error_handler
Error handler.
Definition internal.h:124
void * error_pw
Error handler data.
Definition internal.h:125
hubbub_treebuilder_context context
Our context.
Definition internal.h:120
hubbub_tree_handler * tree_handler
Callback table.
Definition internal.h:122
hubbub_tokeniser * tokeniser
Underlying tokeniser.
Definition internal.h:118
element_type type
Definition treebuilder.c:26
hubbub_ns
Possible namespaces.
Definition types.h:63