LibWeb: Implement "select" portion of reset_the_insertion_mode_appropriately

Required by Dromaeo. With this, it no longer crashes.
This commit is contained in:
Luke 2021-04-06 21:56:10 +01:00 committed by Andreas Kling
parent a9fa3fb095
commit d215578f55
Notes: sideshowbarker 2024-07-18 20:40:18 +09:00

View file

@ -38,6 +38,7 @@
#include <LibWeb/HTML/HTMLFormElement.h>
#include <LibWeb/HTML/HTMLHeadElement.h>
#include <LibWeb/HTML/HTMLScriptElement.h>
#include <LibWeb/HTML/HTMLTableElement.h>
#include <LibWeb/HTML/HTMLTemplateElement.h>
#include <LibWeb/HTML/Parser/HTMLDocumentParser.h>
#include <LibWeb/HTML/Parser/HTMLToken.h>
@ -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<HTMLTemplateElement>(ancestor))
break;
if (is<HTMLTableElement>(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)) {