1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 04:58:13 +00:00

LibWeb: Improve support for "a" and "li" during "in body" insertion

We can now parse welcome.html once again, without resorting to hacks
or fallbacks during "in body" :^)
This commit is contained in:
Andreas Kling 2020-05-29 22:06:05 +02:00
parent 30d64fccde
commit 6854f726ce
4 changed files with 47 additions and 7 deletions

View file

@ -25,6 +25,7 @@
*/
#include <LibWeb/DOM/Element.h>
#include <LibWeb/Parser/HTMLDocumentParser.h>
#include <LibWeb/Parser/StackOfOpenElements.h>
namespace Web {
@ -85,6 +86,14 @@ bool StackOfOpenElements::has_in_table_scope(const FlyString& tag_name) const
return has_in_scope_impl(tag_name, list);
}
bool StackOfOpenElements::has_in_list_item_scope(const FlyString& tag_name) const
{
auto list = s_base_list;
list.append("ol");
list.append("ul");
return has_in_scope_impl(tag_name, list);
}
bool StackOfOpenElements::contains(const Element& element) const
{
for (auto& element_on_stack : m_elements) {
@ -101,4 +110,17 @@ void StackOfOpenElements::pop_until_an_element_with_tag_name_has_been_popped(con
pop();
}
Element* StackOfOpenElements::topmost_special_node_below(const Element& formatting_element)
{
Element* found_element = nullptr;
for (ssize_t i = m_elements.size() - 1; i >= 0; ++i) {
auto& element = m_elements[i];
if (&element == &formatting_element)
break;
if (HTMLDocumentParser::is_special_tag(element.tag_name()))
found_element = &element;
}
return found_element;
}
}