diff options
author | Andreas Kling <kling@serenityos.org> | 2020-05-28 00:26:33 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-28 00:27:00 +0200 |
commit | 7f18c51f4c25e9fe73aba13d304a8ad118478881 (patch) | |
tree | 1cd16027f5c1db210f45d0b255fb16f02b2cf6ff /Libraries | |
parent | 2a97127faa62cffe4f61a65f215eea954fd9dacc (diff) | |
download | serenity-7f18c51f4c25e9fe73aba13d304a8ad118478881.zip |
LibWeb: Flesh out "reset the insertion mode appropriately" algorithm
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibWeb/Parser/HTMLDocumentParser.cpp | 64 |
1 files changed, 63 insertions, 1 deletions
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<Element> 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 |