dymokomi/luce-browser-engine
Source of release 0.6.0
0.6.0 / src / web / html / parser / html_parser_10.lucb
#==============================================================================================
#
# html_parser_10 - HTML::HTMLParser: the frameset modes, foreign content and resetting the
# insertion mode
#
# DESCRIPTION:
# Port of LibWeb/HTML/Parser/HTMLParser.cpp (lines 4539-5057): the "in frameset",
# "after frameset" and "after after frameset" insertion modes, the rules for parsing
# tokens in foreign content (with SVG <script> handling; C++'s `ScriptEndTag:` label is
# html_parser_handle_svg_script_end_tag), "reset the insertion mode appropriately",
# insertion_mode_name (ENUMERATE_INSERTION_MODES' names) and document().
#
#==============================================================================================
# mark: The frameset insertion modes ============================================================
## Ported from HTMLParser.cpp:4540 Web::HTML::HTMLParser::handle_in_frameset.
# https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inframeset
pub func html_parser_handle_in_frameset(this: HtmlParser*, token: html_syntax.HtmlToken*):
# -> A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF),
# U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE
if html_syntax.html_token_is_character(token) and html_syntax.html_token_is_parser_whitespace(token):
# Insert the character.
html_parser_insert_character(this, html_syntax.html_token_code_point(token))
return
# -> A comment token
if html_syntax.html_token_is_comment(token):
# Insert a comment.
html_parser_insert_comment(this, token)
return
# -> A DOCTYPE token
if html_syntax.html_token_is_doctype(token):
# Parse error. Ignore the token.
html_log_parse_error()
return
# -> A start tag whose tag name is "html"
if html_syntax.html_token_is_start_tag(token) and html_parser_tag_name_is(token, html_tag_names_html):
# Process the token using the rules for the "in body" insertion mode.
html_parser_process_using_the_rules_for(this, HtmlParserInsertionMode.in_body, token)
return
# -> A start tag whose tag name is "frameset"
if html_syntax.html_token_is_start_tag(token) and html_parser_tag_name_is(token, html_tag_names_frameset):
# Insert an HTML element for the token.
_ = html_parser_insert_html_element(this, token)
return
# -> An end tag whose tag name is "frameset"
if html_syntax.html_token_is_end_tag(token) and html_parser_tag_name_is(token, html_tag_names_frameset):
# If the current node is the root html element, then this is a parse error; ignore the token. (fragment case)
if dom_element_is_document_element(html_parser_current_element(this)):
html_log_parse_error()
return
# Otherwise, pop the current node from the stack of open elements.
_ = html_stack_of_open_elements_pop(&this.m_stack_of_open_elements)
# If the parser was not created as part of the HTML fragment parsing algorithm (fragment case),
# and the current node is no longer a frameset element, then switch the insertion mode to "after frameset".
if not this.m_parsing_fragment and not html_parser_local_name_is(html_parser_current_element(this), html_tag_names_frameset):
this.m_insertion_mode = HtmlParserInsertionMode.after_frameset
return
# -> A start tag whose tag name is "frame"
if html_syntax.html_token_is_start_tag(token) and html_parser_tag_name_is(token, html_tag_names_frame):
# Insert an HTML element for the token.
_ = html_parser_insert_html_element(this, token)
# Immediately pop the current node off the stack of open elements.
_ = html_stack_of_open_elements_pop(&this.m_stack_of_open_elements)
# Acknowledge the token's self-closing flag, if it is set.
html_syntax.html_token_acknowledge_self_closing_flag_if_set(token)
return
# -> A start tag whose tag name is "noframes"
if html_syntax.html_token_is_start_tag(token) and html_parser_tag_name_is(token, html_tag_names_noframes):
# Process the token using the rules for the "in head" insertion mode.
html_parser_process_using_the_rules_for(this, HtmlParserInsertionMode.in_head, token)
return
# -> An end-of-file token
if html_syntax.html_token_is_end_of_file(token):
# If the current node is not the root html element, then this is a parse error.
if not dom_element_is_document_element(html_parser_current_element(this)):
html_log_parse_error()
# Stop parsing.
html_parser_stop_parsing(this)
return
# -> Anything else
# Parse error. Ignore the token.
html_log_parse_error()
## Ported from HTMLParser.cpp:4636 Web::HTML::HTMLParser::handle_after_frameset.
# https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-afterframeset
pub func html_parser_handle_after_frameset(this: HtmlParser*, token: html_syntax.HtmlToken*):
# -> A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF),
# U+000D CARRIAGE RETURN (CR), or U+0020 SPACE
if html_syntax.html_token_is_character(token) and html_syntax.html_token_is_parser_whitespace(token):
# Insert the character.
html_parser_insert_character(this, html_syntax.html_token_code_point(token))
return
# -> A comment token
if html_syntax.html_token_is_comment(token):
# Insert a comment.
html_parser_insert_comment(this, token)
return
# -> A DOCTYPE token
if html_syntax.html_token_is_doctype(token):
# Parse error. Ignore the token.
html_log_parse_error()
return
# -> A start tag whose tag name is "html"
if html_syntax.html_token_is_start_tag(token) and html_parser_tag_name_is(token, html_tag_names_html):
# Process the token using the rules for the "in body" insertion mode.
html_parser_process_using_the_rules_for(this, HtmlParserInsertionMode.in_body, token)
return
# -> An end tag whose tag name is "html"
if html_syntax.html_token_is_end_tag(token) and html_parser_tag_name_is(token, html_tag_names_html):
# Switch the insertion mode to "after after frameset".
this.m_insertion_mode = HtmlParserInsertionMode.after_after_frameset
return
# -> A start tag whose tag name is "noframes"
if html_syntax.html_token_is_start_tag(token) and html_parser_tag_name_is(token, html_tag_names_noframes):
# Process the token using the rules for the "in head" insertion mode.
html_parser_process_using_the_rules_for(this, HtmlParserInsertionMode.in_head, token)
return
# An end-of-file token
if html_syntax.html_token_is_end_of_file(token):
# Stop parsing.
html_parser_stop_parsing(this)
return
# -> Anything else
# Parse error. Ignore the token.
html_log_parse_error()
## Ported from HTMLParser.cpp:4694 Web::HTML::HTMLParser::handle_after_after_frameset.
# https://html.spec.whatwg.org/multipage/parsing.html#the-after-after-frameset-insertion-mode
pub func html_parser_handle_after_after_frameset(this: HtmlParser*, token: html_syntax.HtmlToken*):
# -> A comment token
if html_syntax.html_token_is_comment(token):
# Insert a comment as the last child of the Document object.
let comment = html_parser_create_comment(this, token)
_ = dom_node_append_child(html_parser_document(this).dom_node(), comment.dom_node()) else trap("MUST: append_child")
return
# -> A DOCTYPE token
# -> A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPACE
# -> A start tag whose tag name is "html"
if html_syntax.html_token_is_doctype(token) or html_syntax.html_token_is_parser_whitespace(token) or (html_syntax.html_token_is_start_tag(token) and html_parser_tag_name_is(token, html_tag_names_html)):
# Process the token using the rules for the "in body" insertion mode.
html_parser_process_using_the_rules_for(this, HtmlParserInsertionMode.in_body, token)
return
# -> An end-of-file token
if html_syntax.html_token_is_end_of_file(token):
# Stop parsing.
html_parser_stop_parsing(this)
return
# -> A start tag whose tag name is "noframes"
if html_syntax.html_token_is_start_tag(token) and html_parser_tag_name_is(token, html_tag_names_noframes):
# Process the token using the rules for the "in head" insertion mode.
html_parser_process_using_the_rules_for(this, HtmlParserInsertionMode.in_head, token)
return
# -> Anything else
# Parse error. Ignore the token.
html_log_parse_error()
# mark: Foreign content =========================================================================
## Ported from HTMLParser.cpp:4733 Web::HTML::HTMLParser::process_using_the_rules_for_foreign_content.
# https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inforeign
pub func html_parser_process_using_the_rules_for_foreign_content(this: HtmlParser*, token: html_syntax.HtmlToken*):
if html_syntax.html_token_is_character(token):
# -> A character token that is U+0000 NULL
if html_syntax.html_token_code_point(token) == 0:
# Parse error. Insert a U+FFFD REPLACEMENT CHARACTER character.
html_log_parse_error()
html_parser_insert_character(this, 0xFFFD)
return
# -> A character token that is one of U+0009 CHARACTER TABULATION, U+000A LINE FEED (LF), U+000C FORM FEED (FF), U+000D CARRIAGE RETURN (CR), or U+0020 SPAC
if html_syntax.html_token_is_parser_whitespace(token):
html_parser_insert_character(this, html_syntax.html_token_code_point(token))
return
# -> Any other character token
html_parser_insert_character(this, html_syntax.html_token_code_point(token))
this.m_frameset_ok = false
return
# -> A comment token
if html_syntax.html_token_is_comment(token):
# Insert a comment.
html_parser_insert_comment(this, token)
return
# -> A DOCTYPE token
if html_syntax.html_token_is_doctype(token):
# Parse error. Ignore the token.
html_log_parse_error()
return
# -> A start tag whose tag name is one of: "b", "big", "blockquote", "body", "br", "center", "code", "dd", "div", "dl", "dt", "em", "embed", "h1", "h2", "h3", "h4", "h5", "h6", "head", "hr", "i", "img", "li", "listing", "menu", "meta", "nobr", "ol", "p", "pre", "ruby", "s", "small", "span", "strong", "strike", "sub", "sup", "table", "tt", "u", "ul", "var"
# -> A start tag whose tag name is "font", if the token has any attributes named "color", "face", or "size"
# -> An end tag whose tag name is "br", "p"
if (html_syntax.html_token_is_start_tag(token) and html_parser_tag_name_is_one_of(token, [html_tag_names_b, html_tag_names_big, html_tag_names_blockquote, html_tag_names_body, html_tag_names_br, html_tag_names_center, html_tag_names_code, html_tag_names_dd, html_tag_names_div, html_tag_names_dl, html_tag_names_dt, html_tag_names_em, html_tag_names_embed, html_tag_names_h1, html_tag_names_h2, html_tag_names_h3, html_tag_names_h4, html_tag_names_h5, html_tag_names_h6, html_tag_names_head, html_tag_names_hr, html_tag_names_i, html_tag_names_img, html_tag_names_li, html_tag_names_listing, html_tag_names_menu, html_tag_names_meta, html_tag_names_nobr, html_tag_names_ol, html_tag_names_p, html_tag_names_pre, html_tag_names_ruby, html_tag_names_s, html_tag_names_small, html_tag_names_span, html_tag_names_strong, html_tag_names_strike, html_tag_names_sub, html_tag_names_sup, html_tag_names_table, html_tag_names_tt, html_tag_names_u, html_tag_names_ul, html_tag_names_var])) or (html_syntax.html_token_is_start_tag(token) and html_parser_tag_name_is(token, html_tag_names_font) and (html_syntax.html_token_has_attribute(token, html_attribute_names_color) or html_syntax.html_token_has_attribute(token, html_attribute_names_face) or html_syntax.html_token_has_attribute(token, html_attribute_names_size))) or (html_syntax.html_token_is_end_tag(token) and html_parser_tag_name_is_one_of(token, [html_tag_names_br, html_tag_names_p])):
# Parse error.
html_log_parse_error()
# While the current node is not a MathML text integration point, an HTML integration point, or an element in the HTML namespace, pop elements from the stack of open elements.
while not html_is_mathml_text_integration_point(html_parser_current_element(this)) and not html_is_html_integration_point(html_parser_current_element(this)) and not html_parser_element_namespace_is(html_parser_current_element(this), namespace_html):
_ = html_stack_of_open_elements_pop(&this.m_stack_of_open_elements)
# Reprocess the token according to the rules given in the section corresponding to the current insertion mode in HTML content.
html_parser_process_using_the_rules_for(this, this.m_insertion_mode, token)
return
# -> Any other start tag
if html_syntax.html_token_is_start_tag(token):
let adjusted_current_node = html_parser_adjusted_current_node(this) else trap("VERIFY: adjusted current node")
# If the adjusted current node is an element in the MathML namespace, adjust MathML attributes for the token. (This fixes the case of MathML attributes that are not all lowercase.)
if html_parser_element_namespace_is(adjusted_current_node, namespace_math_ml):
html_parser_adjust_mathml_attributes(this, token)
# If the adjusted current node is an element in the SVG namespace, and the token's tag name is one of the ones in the first column of the
# following table, change the tag name to the name given in the corresponding cell in the second column. (This fixes the case of SVG
# elements that are not all lowercase.)
elif html_parser_element_namespace_is(adjusted_current_node, namespace_svg):
html_parser_adjust_svg_tag_names(this, token)
# If the adjusted current node is an element in the SVG namespace, adjust SVG attributes for the token. (This fixes the case of SVG attributes that are not all lowercase.)
html_parser_adjust_svg_attributes(this, token)
# Adjust foreign attributes for the token. (This fixes the use of namespaced attributes, in particular XLink in SVG.)
html_parser_adjust_foreign_attributes(token)
# Insert a foreign element for the token, with the adjusted current node's namespace and false.
# AD-HOC: For SVG script elements, set the parser-inserted flag before the element is
# inserted into the DOM. Otherwise inserted()/attribute_changed() would invoke
# process_the_script_element() with the flag still unset and bypass the
# parser-blocking fetch handling.
let namespace_ = dom_element_namespace_uri(adjusted_current_node)
if html_parser_tag_name_is(token, svg_tag_names_script) and dom_node_optional_fly_string_is(namespace_, namespace_svg):
let adjusted_insertion_location = html_parser_find_appropriate_place_for_inserting_node(this)
let element = html_parser_create_element_for(this, token, namespace_, adjusted_insertion_location.parent else trap("VERIFY: adjusted insertion location"))
svg_script_element_set_parser_inserted(as_svg_script_element(element))
html_parser_insert_an_element_at_the_adjusted_insertion_location(this, element)
html_stack_of_open_elements_push(&this.m_stack_of_open_elements, element)
else:
_ = html_parser_insert_foreign_element(this, token, namespace_, HtmlParserOnlyAddToElementStack.no)
# If the token has its self-closing flag set, then run the appropriate steps from the following list:
if html_syntax.html_token_is_self_closing(token):
# -> If the token's tag name is "script", and the new current node is in the SVG namespace
if html_parser_tag_name_is(token, svg_tag_names_script) and html_parser_element_namespace_is(html_parser_current_element(this), namespace_svg):
let script_element = as_svg_script_element(html_parser_current_element(this))
svg_script_element_set_source_line_number(script_element, html_syntax.html_token_start_position(token).line + 1) # FIXME: This +1 is incorrect for script tags whose script does not start on a new line
# Acknowledge the token's self-closing flag, and then act as described in the steps for a "script" end tag below.
html_syntax.html_token_acknowledge_self_closing_flag_if_set(token)
html_parser_handle_svg_script_end_tag(this)
return
# -> Otherwise
else:
# Pop the current node off the stack of open elements and acknowledge the token's self-closing flag.
_ = html_stack_of_open_elements_pop(&this.m_stack_of_open_elements)
html_syntax.html_token_acknowledge_self_closing_flag_if_set(token)
return
# -> An end tag whose tag name is "script", if the current node is an SVG script element
if html_syntax.html_token_is_end_tag(token) and html_parser_tag_name_is(token, svg_tag_names_script) and html_parser_element_namespace_is(html_parser_current_element(this), namespace_svg) and html_parser_local_name_is(html_parser_current_element(this), svg_tag_names_script):
html_parser_handle_svg_script_end_tag(this)
return
# -> Any other end tag
if html_syntax.html_token_is_end_tag(token):
# 1. Initialize node to be the current node (the bottommost node of the stack).
var node = html_parser_current_element(this)
# 2. If node's tag name, converted to ASCII lowercase, is not the same as the tag name of the token, then this is a parse error.
let node_tag_name = dom_element_tag_name(node)
let token_tag_name = html_syntax.html_token_tag_name(token)
if ak.fly_string_equals_ignoring_ascii_case_fly_string(&node_tag_name, &token_tag_name):
html_log_parse_error()
# 3. Loop: If node is the topmost element in the stack of open elements, then return. (fragment case)
let elements = &this.m_stack_of_open_elements.m_elements
var i = (isize)ak.vector_size(elements) - 1
while i >= 0:
if node == html_stack_of_open_elements_first(&this.m_stack_of_open_elements):
assert(this.m_parsing_fragment)
return
# 4. If node's tag name, converted to ASCII lowercase, is the same as the tag name of the token, pop elements from the stack
# of open elements until node has been popped from the stack, and then return.
let tag_name = dom_element_tag_name(node)
if ak.fly_string_equals_ignoring_ascii_case_fly_string(&tag_name, &token_tag_name):
while html_parser_current_element(this) != node:
_ = html_stack_of_open_elements_pop(&this.m_stack_of_open_elements)
_ = html_stack_of_open_elements_pop(&this.m_stack_of_open_elements)
return
# 5. Set node to the previous entry in the stack of open elements.
node = *ak.vector_at(elements, (usize)(i - 1))
# 6. If node is not an element in the HTML namespace, return to the step labeled loop.
if not html_parser_element_namespace_is(node, namespace_html):
i -= 1
continue
# 7. Otherwise, process the token according to the rules given in the section corresponding to the current insertion mode in HTML content.
html_parser_process_using_the_rules_for(this, this.m_insertion_mode, token)
return
trap("VERIFY_NOT_REACHED")
## process_using_the_rules_for_foreign_content's `ScriptEndTag:` label: "An end tag whose tag name is
## "script", if the current node is an SVG script element" (HTMLParser.cpp:4850-4885).
func html_parser_handle_svg_script_end_tag(this: HtmlParser*):
# Pop the current node off the stack of open elements.
let script_element = as_svg_script_element(html_stack_of_open_elements_pop(&this.m_stack_of_open_elements))
# Let the old insertion point have the same value as the current insertion point.
html_syntax.html_tokenizer_store_old_insertion_point(&this.m_tokenizer)
# Let the insertion point be just before the next input character.
html_syntax.html_tokenizer_update_insertion_point(&this.m_tokenizer)
# Increment the parser's script nesting level by one.
html_parser_increment_script_nesting_level(this)
# Set the parser pause flag to true.
this.m_parser_pause_flag = true
# Non-standard: Make sure the <script> element has up-to-date text content before processing the script.
html_parser_flush_character_insertions(this)
# If the active speculative HTML parser is null and the user agent supports SVG, then Process the SVG script element according to the SVG rules. [SVG]
# The active speculative HTML parser is null here (see above).
svg_script_element_process_the_script_element(script_element)
# Decrement the parser's script nesting level by one.
html_parser_decrement_script_nesting_level(this)
# If the parser's script nesting level is zero, then set the parser pause flag to false.
if html_parser_script_nesting_level(this) == 0:
this.m_parser_pause_flag = false
# Let the insertion point have the value of the old insertion point.
html_syntax.html_tokenizer_restore_old_insertion_point(&this.m_tokenizer)
# If the SVG script registered itself as a pending parsing-blocking script (external fetch in flight),
# pause the parser and schedule a resume check. The parser will resume from
# resume_after_parser_blocking_script when the fetch completes.
if dom_document_pending_parsing_blocking_svg_script(html_parser_document(this)) != none:
this.m_parser_pause_flag = true
html_parser_schedule_resume_check(this)
# mark: Resetting the insertion mode ============================================================
## Ported from HTMLParser.cpp:4930 Web::HTML::HTMLParser::reset_the_insertion_mode_appropriately.
# https://html.spec.whatwg.org/multipage/parsing.html#reset-the-insertion-mode-appropriately
pub func html_parser_reset_the_insertion_mode_appropriately(this: HtmlParser*):
# 1. Let last be false.
var last = false
# 2. Let node be the last node in the stack of open elements.
let elements = &this.m_stack_of_open_elements.m_elements
var i = (isize)ak.vector_size(elements) - 1
while i >= 0:
# 3. Loop: If node is the first node in the stack of open elements, then set last to true, and, if the parser
# was created as part of the HTML fragment parsing algorithm (fragment case), set node to the context
# element passed to that algorithm.
if i == 0:
last = true
var node: DomElement* = *ak.vector_at(elements, (usize)i)
if last and this.m_parsing_fragment:
node = this.m_context_element else trap("VERIFY: context element")
# NOTE: The following steps only apply to HTML elements, so skip ones that aren't.
if html_parser_element_namespace_is(node, namespace_html):
# 4. If node is a td or th element and last is false, then switch the insertion mode to "in cell" and return.
if not last and html_parser_local_name_is_one_of(node, [html_tag_names_td, html_tag_names_th]):
this.m_insertion_mode = HtmlParserInsertionMode.in_cell
return
# 5. If node is a tr element, then switch the insertion mode to "in row" and return.
if html_parser_local_name_is(node, html_tag_names_tr):
this.m_insertion_mode = HtmlParserInsertionMode.in_row
return
# 6. If node is a tbody, thead, or tfoot element, then switch the insertion mode to "in table body" and return.
if html_parser_local_name_is_one_of(node, [html_tag_names_tbody, html_tag_names_thead, html_tag_names_tfoot]):
this.m_insertion_mode = HtmlParserInsertionMode.in_table_body
return
# 7. If node is a caption element, then switch the insertion mode to "in caption" and return.
if html_parser_local_name_is(node, html_tag_names_caption):
this.m_insertion_mode = HtmlParserInsertionMode.in_caption
return
# 8. If node is a colgroup element, then switch the insertion mode to "in column group" and return.
if html_parser_local_name_is(node, html_tag_names_colgroup):
this.m_insertion_mode = HtmlParserInsertionMode.in_column_group
return
# 9. If node is a table element, then switch the insertion mode to "in table" and return.
if html_parser_local_name_is(node, html_tag_names_table):
this.m_insertion_mode = HtmlParserInsertionMode.in_table
return
# 10. If node is a template element, then switch the insertion mode to the current template insertion mode and return.
if html_parser_local_name_is(node, html_tag_names_template):
this.m_insertion_mode = *ak.vector_last(&this.m_stack_of_template_insertion_modes)
return
# 11. If node is a head element and last is false, then switch the insertion mode to "in head" and return.
if not last and html_parser_local_name_is(node, html_tag_names_head):
this.m_insertion_mode = HtmlParserInsertionMode.in_head
return
# 12. If node is a body element, then switch the insertion mode to "in body" and return.
if html_parser_local_name_is(node, html_tag_names_body):
this.m_insertion_mode = HtmlParserInsertionMode.in_body
return
# 13. If node is a frameset element, then switch the insertion mode to "in frameset" and return. (fragment case)
if html_parser_local_name_is(node, html_tag_names_frameset):
assert(this.m_parsing_fragment)
this.m_insertion_mode = HtmlParserInsertionMode.in_frameset
return
# 14. If node is an html element, run these substeps:
if html_parser_local_name_is(node, html_tag_names_html):
# 1. If the head element pointer is null, switch the insertion mode to "before head" and return. (fragment case)
if this.m_head_element == none:
assert(this.m_parsing_fragment)
this.m_insertion_mode = HtmlParserInsertionMode.before_head
return
# 2. Otherwise, the head element pointer is not null, switch the insertion mode to "after head" and return.
this.m_insertion_mode = HtmlParserInsertionMode.after_head
return
# 15. If last is true, then switch the insertion mode to "in body" and return. (fragment case)
if last:
assert(this.m_parsing_fragment)
this.m_insertion_mode = HtmlParserInsertionMode.in_body
return
# 16. Let node now be the node before node in the stack of open elements.
# 17. Return to the step labeled loop.
i -= 1
trap("VERIFY_NOT_REACHED")
## Ported from HTMLParser.cpp:5042 Web::HTML::HTMLParser::insertion_mode_name (the names of
## ENUMERATE_INSERTION_MODES).
pub func html_parser_insertion_mode_name(this: HtmlParser*) -> str:
match this.m_insertion_mode:
.initial: return "Initial"
.before_html: return "BeforeHTML"
.before_head: return "BeforeHead"
.in_head: return "InHead"
.in_head_noscript: return "InHeadNoscript"
.after_head: return "AfterHead"
.in_body: return "InBody"
.text: return "Text"
.in_table: return "InTable"
.in_table_text: return "InTableText"
.in_caption: return "InCaption"
.in_column_group: return "InColumnGroup"
.in_table_body: return "InTableBody"
.in_row: return "InRow"
.in_cell: return "InCell"
.in_template: return "InTemplate"
.after_body: return "AfterBody"
.in_frameset: return "InFrameset"
.after_frameset: return "AfterFrameset"
.after_after_body: return "AfterAfterBody"
.after_after_frameset: return "AfterAfterFrameset"
_: trap("VERIFY_NOT_REACHED")
## Ported from HTMLParser.cpp:5054 Web::HTML::HTMLParser::document.
pub func html_parser_document(this: HtmlParser*) -> DomDocument*:
return this.m_document else trap("VERIFY: document")