mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-21 15:14:13 +00:00
LibWeb: Factor out the "stack of open elements" into its own class
This will allow us to write more expressive parsing code. :^)
This commit is contained in:
23
Libraries/LibWeb/Parser/StackOfOpenElements.cpp
Normal file
23
Libraries/LibWeb/Parser/StackOfOpenElements.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
#include <LibWeb/Parser/StackOfOpenElements.h>
|
||||
|
||||
namespace Web {
|
||||
|
||||
StackOfOpenElements::~StackOfOpenElements()
|
||||
{
|
||||
}
|
||||
|
||||
bool StackOfOpenElements::has_in_scope(const FlyString& tag_name) const
|
||||
{
|
||||
static Vector<FlyString> list { "applet", "caption", "html", "table", "td", "th", "marquee", "object", "template" };
|
||||
for (ssize_t i = m_elements.size() - 1; i >= 0; --i) {
|
||||
auto& node = m_elements.at(i);
|
||||
if (node.tag_name() == tag_name)
|
||||
return true;
|
||||
if (list.contains_slow(node.tag_name()))
|
||||
return false;
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user