From 7f18c51f4c25e9fe73aba13d304a8ad118478881 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 28 May 2020 00:26:33 +0200 Subject: LibWeb: Flesh out "reset the insertion mode appropriately" algorithm --- Libraries/LibWeb/Parser/HTMLDocumentParser.cpp | 64 +++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) (limited to 'Libraries/LibWeb') diff --git a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp index ffa427cc7b..01b221b58f 100644 --- a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp +++ b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp @@ -902,7 +902,69 @@ void HTMLDocumentParser::handle_in_table(HTMLToken& token) void HTMLDocumentParser::reset_the_insertion_mode_appropriately() { - TODO(); + for (ssize_t i = m_stack_of_open_elements.elements().size() - 1; i >= 0; --i) { + RefPtr node = m_stack_of_open_elements.elements().at(i); + + if (node->tag_name() == "select") { + TODO(); + } + + if (node->tag_name().is_one_of("td", "th")) { + m_insertion_mode = InsertionMode::InCell; + return; + } + + if (node->tag_name() == "tr") { + m_insertion_mode = InsertionMode::InRow; + return; + } + + if (node->tag_name().is_one_of("tbody", "thead", "tfoot")) { + m_insertion_mode = InsertionMode::InTableBody; + return; + } + + if (node->tag_name() == "caption") { + m_insertion_mode = InsertionMode::InCaption; + return; + } + + if (node->tag_name() == "colgroup") { + m_insertion_mode = InsertionMode::InColumnGroup; + return; + } + + if (node->tag_name() == "table") { + m_insertion_mode = InsertionMode::InTable; + return; + } + + if (node->tag_name() == "template") { + TODO(); + } + + if (node->tag_name() == "body") { + m_insertion_mode = InsertionMode::InBody; + return; + } + + if (node->tag_name() == "frameset") { + m_insertion_mode = InsertionMode::InFrameset; + if (m_parsing_fragment) { + TODO(); + } + return; + } + + if (node->tag_name() == "html") { + TODO(); + } + } + + m_insertion_mode = InsertionMode::InBody; + if (m_parsing_fragment) { + TODO(); + } } const char* HTMLDocumentParser::insertion_mode_name() const -- cgit v1.2.3