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:
Andreas Kling 2020-05-27 23:22:42 +02:00
parent 4c9c6b3a7b
commit db6cf9b37d
Notes: sideshowbarker 2024-07-19 06:03:46 +09:00
7 changed files with 248 additions and 16 deletions

View file

@ -29,6 +29,7 @@
#include <AK/NonnullRefPtrVector.h>
#include <LibWeb/DOM/Node.h>
#include <LibWeb/Parser/HTMLTokenizer.h>
#include <LibWeb/Parser/ListOfActiveFormattingElements.h>
#include <LibWeb/Parser/StackOfOpenElements.h>
#define ENUMERATE_INSERTION_MODES \
@ -106,13 +107,13 @@ private:
void decrement_script_nesting_level();
size_t script_nesting_level() const { return m_script_nesting_level; }
void reset_the_insertion_mode_appropriately();
void run_the_adoption_agency_algorithm(HTMLToken&);
InsertionMode m_insertion_mode { InsertionMode::Initial };
InsertionMode m_original_insertion_mode { InsertionMode::Initial };
StackOfOpenElements m_stack_of_open_elements;
NonnullRefPtrVector<Element> m_list_of_active_formatting_elements;
ListOfActiveFormattingElements m_list_of_active_formatting_elements;
HTMLTokenizer m_tokenizer;