mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:38:11 +00:00
LibWeb: Handle AAA situation where there's no formatting element found
In this case, we're supposed to return from the AAA and then jump to a different behavior in the "in body" insertion mode. So now we do that.
This commit is contained in:
parent
c9dd459822
commit
8c96b8174b
2 changed files with 19 additions and 14 deletions
|
@ -605,7 +605,7 @@ Create:
|
||||||
goto Advance;
|
goto Advance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HTMLDocumentParser::run_the_adoption_agency_algorithm(HTMLToken& token)
|
HTMLDocumentParser::AdoptionAgencyAlgorithmOutcome HTMLDocumentParser::run_the_adoption_agency_algorithm(HTMLToken& token)
|
||||||
{
|
{
|
||||||
auto subject = token.tag_name();
|
auto subject = token.tag_name();
|
||||||
|
|
||||||
|
@ -614,23 +614,20 @@ void HTMLDocumentParser::run_the_adoption_agency_algorithm(HTMLToken& token)
|
||||||
// then pop the current node off the stack of open elements, and return.
|
// then pop the current node off the stack of open elements, and return.
|
||||||
if (current_node().tag_name() == subject && !m_list_of_active_formatting_elements.contains(current_node())) {
|
if (current_node().tag_name() == subject && !m_list_of_active_formatting_elements.contains(current_node())) {
|
||||||
m_stack_of_open_elements.pop();
|
m_stack_of_open_elements.pop();
|
||||||
return;
|
return AdoptionAgencyAlgorithmOutcome::DoNothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t outer_loop_counter = 0;
|
size_t outer_loop_counter = 0;
|
||||||
|
|
||||||
//OuterLoop:
|
//OuterLoop:
|
||||||
if (outer_loop_counter >= 8)
|
if (outer_loop_counter >= 8)
|
||||||
return;
|
return AdoptionAgencyAlgorithmOutcome::DoNothing;
|
||||||
|
|
||||||
++outer_loop_counter;
|
++outer_loop_counter;
|
||||||
|
|
||||||
auto formatting_element = m_list_of_active_formatting_elements.last_element_with_tag_name_before_marker(subject);
|
auto formatting_element = m_list_of_active_formatting_elements.last_element_with_tag_name_before_marker(subject);
|
||||||
if (!formatting_element) {
|
if (!formatting_element)
|
||||||
// FIXME: If there is no such element, then return and instead act as
|
return AdoptionAgencyAlgorithmOutcome::RunAnyOtherEndTagSteps;
|
||||||
// described in the "any other end tag" entry above.
|
|
||||||
TODO();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_stack_of_open_elements.contains(*formatting_element)) {
|
if (!m_stack_of_open_elements.contains(*formatting_element)) {
|
||||||
PARSE_ERROR();
|
PARSE_ERROR();
|
||||||
|
@ -641,7 +638,7 @@ void HTMLDocumentParser::run_the_adoption_agency_algorithm(HTMLToken& token)
|
||||||
|
|
||||||
if (!m_stack_of_open_elements.has_in_scope(*formatting_element)) {
|
if (!m_stack_of_open_elements.has_in_scope(*formatting_element)) {
|
||||||
PARSE_ERROR();
|
PARSE_ERROR();
|
||||||
return;
|
return AdoptionAgencyAlgorithmOutcome::DoNothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formatting_element != ¤t_node()) {
|
if (formatting_element != ¤t_node()) {
|
||||||
|
@ -656,7 +653,7 @@ void HTMLDocumentParser::run_the_adoption_agency_algorithm(HTMLToken& token)
|
||||||
m_stack_of_open_elements.pop();
|
m_stack_of_open_elements.pop();
|
||||||
|
|
||||||
m_list_of_active_formatting_elements.remove(*formatting_element);
|
m_list_of_active_formatting_elements.remove(*formatting_element);
|
||||||
return;
|
return AdoptionAgencyAlgorithmOutcome::DoNothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Implement the rest of the AAA :^)
|
// FIXME: Implement the rest of the AAA :^)
|
||||||
|
@ -1052,7 +1049,8 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
|
||||||
if (token.is_start_tag() && token.tag_name() == "a") {
|
if (token.is_start_tag() && token.tag_name() == "a") {
|
||||||
if (auto* element = m_list_of_active_formatting_elements.last_element_with_tag_name_before_marker("a")) {
|
if (auto* element = m_list_of_active_formatting_elements.last_element_with_tag_name_before_marker("a")) {
|
||||||
PARSE_ERROR();
|
PARSE_ERROR();
|
||||||
run_the_adoption_agency_algorithm(token);
|
if (run_the_adoption_agency_algorithm(token) == AdoptionAgencyAlgorithmOutcome::RunAnyOtherEndTagSteps)
|
||||||
|
goto AnyOtherEndTag;
|
||||||
m_list_of_active_formatting_elements.remove(*element);
|
m_list_of_active_formatting_elements.remove(*element);
|
||||||
m_stack_of_open_elements.elements().remove_first_matching([&](auto& entry) {
|
m_stack_of_open_elements.elements().remove_first_matching([&](auto& entry) {
|
||||||
return entry.ptr() == element;
|
return entry.ptr() == element;
|
||||||
|
@ -1076,7 +1074,8 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token.is_end_tag() && token.tag_name().is_one_of("a", "b", "big", "code", "em", "font", "i", "nobr", "s", "small", "strike", "strong", "tt", "u")) {
|
if (token.is_end_tag() && token.tag_name().is_one_of("a", "b", "big", "code", "em", "font", "i", "nobr", "s", "small", "strike", "strong", "tt", "u")) {
|
||||||
run_the_adoption_agency_algorithm(token);
|
if (run_the_adoption_agency_algorithm(token) == AdoptionAgencyAlgorithmOutcome::RunAnyOtherEndTagSteps)
|
||||||
|
goto AnyOtherEndTag;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1210,8 +1209,8 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Any other end tag
|
|
||||||
if (token.is_end_tag()) {
|
if (token.is_end_tag()) {
|
||||||
|
AnyOtherEndTag:
|
||||||
RefPtr<Element> node;
|
RefPtr<Element> node;
|
||||||
for (ssize_t i = m_stack_of_open_elements.elements().size() - 1; i >= 0; --i) {
|
for (ssize_t i = m_stack_of_open_elements.elements().size() - 1; i >= 0; --i) {
|
||||||
node = m_stack_of_open_elements.elements()[i];
|
node = m_stack_of_open_elements.elements()[i];
|
||||||
|
|
|
@ -114,7 +114,13 @@ private:
|
||||||
void decrement_script_nesting_level();
|
void decrement_script_nesting_level();
|
||||||
size_t script_nesting_level() const { return m_script_nesting_level; }
|
size_t script_nesting_level() const { return m_script_nesting_level; }
|
||||||
void reset_the_insertion_mode_appropriately();
|
void reset_the_insertion_mode_appropriately();
|
||||||
void run_the_adoption_agency_algorithm(HTMLToken&);
|
|
||||||
|
enum AdoptionAgencyAlgorithmOutcome {
|
||||||
|
DoNothing,
|
||||||
|
RunAnyOtherEndTagSteps,
|
||||||
|
};
|
||||||
|
|
||||||
|
AdoptionAgencyAlgorithmOutcome run_the_adoption_agency_algorithm(HTMLToken&);
|
||||||
void clear_the_stack_back_to_a_table_context();
|
void clear_the_stack_back_to_a_table_context();
|
||||||
void clear_the_stack_back_to_a_table_body_context();
|
void clear_the_stack_back_to_a_table_body_context();
|
||||||
void clear_the_stack_back_to_a_table_row_context();
|
void clear_the_stack_back_to_a_table_row_context();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue