From d215578f559e90d5593e7a0111a00ff51e21deca Mon Sep 17 00:00:00 2001 From: Luke Date: Tue, 6 Apr 2021 21:56:10 +0100 Subject: [PATCH] LibWeb: Implement "select" portion of reset_the_insertion_mode_appropriately Required by Dromaeo. With this, it no longer crashes. --- .../LibWeb/HTML/Parser/HTMLDocumentParser.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp index 0b63e9af4d..f27234d47e 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLDocumentParser.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -2890,6 +2891,7 @@ void HTMLDocumentParser::process_using_the_rules_for_foreign_content(HTMLToken& VERIFY_NOT_REACHED(); } +// https://html.spec.whatwg.org/multipage/parsing.html#reset-the-insertion-mode-appropriately void HTMLDocumentParser::reset_the_insertion_mode_appropriately() { for (ssize_t i = m_stack_of_open_elements.elements().size() - 1; i >= 0; --i) { @@ -2903,7 +2905,22 @@ void HTMLDocumentParser::reset_the_insertion_mode_appropriately() } if (node->local_name() == HTML::TagNames::select) { - TODO(); + if (!last) { + for (ssize_t j = i; j > 0; --j) { + auto& ancestor = m_stack_of_open_elements.elements().at(j - 1); + + if (is(ancestor)) + break; + + if (is(ancestor)) { + m_insertion_mode = InsertionMode::InSelectInTable; + return; + } + } + } + + m_insertion_mode = InsertionMode::InSelect; + return; } if (!last && node->local_name().is_one_of(HTML::TagNames::td, HTML::TagNames::th)) {