mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 04:44:58 +00:00
LibWeb: Implement the first half of the Adoption Agency Algorithm
The AAA is a somewhat daunting algorithm you have to run for certain tag when inserted inside the <body> element. The purpose of it is to resolve issues with mismatched tags. This patch implements the first half of the AAA. We also move the "list of active formatting elements" to its own class, since it kept accumulating little behaviors. "Marker" entries are now signified by null Element pointers in the list.
This commit is contained in:
parent
4c9c6b3a7b
commit
db6cf9b37d
7 changed files with 248 additions and 16 deletions
|
@ -52,6 +52,23 @@ bool StackOfOpenElements::has_in_scope(const FlyString& tag_name) const
|
|||
return has_in_scope_impl(tag_name, s_base_list);
|
||||
}
|
||||
|
||||
bool StackOfOpenElements::has_in_scope_impl(const Element& target_node, const Vector<FlyString>& list) const
|
||||
{
|
||||
for (ssize_t i = m_elements.size() - 1; i >= 0; --i) {
|
||||
auto& node = m_elements.at(i);
|
||||
if (&node == &target_node)
|
||||
return true;
|
||||
if (list.contains_slow(node.tag_name()))
|
||||
return false;
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
bool StackOfOpenElements::has_in_scope(const Element& target_node) const
|
||||
{
|
||||
return has_in_scope_impl(target_node, s_base_list);
|
||||
}
|
||||
|
||||
bool StackOfOpenElements::has_in_button_scope(const FlyString& tag_name) const
|
||||
{
|
||||
auto list = s_base_list;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue