LibWeb: Parse "form" tags during the "in body" insertion mode

This commit is contained in:
Andreas Kling 2020-05-30 11:13:57 +02:00
parent 851a0f983a
commit fbd52047bb
Notes: sideshowbarker 2024-07-19 05:57:41 +09:00
3 changed files with 36 additions and 2 deletions

View file

@ -817,7 +817,16 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
}
if (token.is_start_tag() && token.tag_name() == "form") {
TODO();
if (m_form_element && m_stack_of_open_elements.contains("template")) {
PARSE_ERROR();
return;
}
if (m_stack_of_open_elements.has_in_button_scope("p"))
close_a_p_element();
auto element = insert_html_element(token);
if (!m_stack_of_open_elements.contains("template"))
m_form_element = to<HTMLFormElement>(*element);
return;
}
if (token.is_start_tag() && token.tag_name() == "li") {
@ -887,7 +896,22 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
}
if (token.is_end_tag() && token.tag_name() == "form") {
TODO();
if (!m_stack_of_open_elements.contains("template")) {
auto node = m_form_element;
m_form_element = nullptr;
if (!node || m_stack_of_open_elements.has_in_scope(*node)) {
PARSE_ERROR();
return;
}
generate_implied_end_tags();
if (&current_node() != node) {
PARSE_ERROR();
}
m_stack_of_open_elements.elements().remove_first_matching([&](auto& entry) { return entry.ptr() == node.ptr(); });
} else {
TODO();
}
return;
}
if (token.is_end_tag() && token.tag_name() == "p") {