LibWeb: Utilize SourceLocation for HTMLDocumentParser logging

This commit is contained in:
Brian Gianforcaro 2021-04-24 20:23:27 -07:00 committed by Andreas Kling
parent 6d69c97b99
commit f8fffe4613
Notes: sideshowbarker 2024-07-18 19:08:14 +09:00

View file

@ -5,6 +5,7 @@
*/
#include <AK/Debug.h>
#include <AK/SourceLocation.h>
#include <AK/Utf32View.h>
#include <LibTextCodec/Decoder.h>
#include <LibWeb/DOM/Comment.h>
@ -27,10 +28,10 @@
namespace Web::HTML {
#define PARSE_ERROR() \
do { \
dbgln("Parse error! {} @ {}", __PRETTY_FUNCTION__, __LINE__); \
} while (0)
static inline void log_parse_error(const SourceLocation& location = SourceLocation::current())
{
dbgln("Parse error! {}", location);
}
static Vector<FlyString> s_quirks_public_ids = {
"+//Silmaril//dtd html Pro v0r11 19970101//",
@ -329,7 +330,7 @@ void HTMLDocumentParser::handle_initial(HTMLToken& token)
return;
}
PARSE_ERROR();
log_parse_error();
document().set_quirks_mode(DOM::QuirksMode::Yes);
m_insertion_mode = InsertionMode::BeforeHTML;
process_using_the_rules_for(InsertionMode::BeforeHTML, token);
@ -338,7 +339,7 @@ void HTMLDocumentParser::handle_initial(HTMLToken& token)
void HTMLDocumentParser::handle_before_html(HTMLToken& token)
{
if (token.is_doctype()) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -365,7 +366,7 @@ void HTMLDocumentParser::handle_before_html(HTMLToken& token)
}
if (token.is_end_tag()) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -482,7 +483,7 @@ void HTMLDocumentParser::handle_before_head(HTMLToken& token)
}
if (token.is_doctype()) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -503,7 +504,7 @@ void HTMLDocumentParser::handle_before_head(HTMLToken& token)
}
if (token.is_end_tag()) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -534,7 +535,7 @@ void HTMLDocumentParser::handle_in_head(HTMLToken& token)
}
if (token.is_doctype()) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -619,14 +620,14 @@ void HTMLDocumentParser::handle_in_head(HTMLToken& token)
if (token.is_end_tag() && token.tag_name() == HTML::TagNames::template_) {
if (!m_stack_of_open_elements.contains(HTML::TagNames::template_)) {
PARSE_ERROR();
log_parse_error();
return;
}
generate_all_implied_end_tags_thoroughly();
if (current_node().local_name() != HTML::TagNames::template_)
PARSE_ERROR();
log_parse_error();
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::template_);
m_list_of_active_formatting_elements.clear_up_to_the_last_marker();
@ -636,7 +637,7 @@ void HTMLDocumentParser::handle_in_head(HTMLToken& token)
}
if ((token.is_start_tag() && token.tag_name() == HTML::TagNames::head) || token.is_end_tag()) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -649,7 +650,7 @@ AnythingElse:
void HTMLDocumentParser::handle_in_head_noscript(HTMLToken& token)
{
if (token.is_doctype()) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -674,12 +675,12 @@ void HTMLDocumentParser::handle_in_head_noscript(HTMLToken& token)
}
if (token.is_start_tag() && token.tag_name().is_one_of(HTML::TagNames::head, HTML::TagNames::noscript)) {
PARSE_ERROR();
log_parse_error();
return;
}
AnythingElse:
PARSE_ERROR();
log_parse_error();
m_stack_of_open_elements.pop();
m_insertion_mode = InsertionMode::InHead;
process_using_the_rules_for(m_insertion_mode, token);
@ -747,7 +748,7 @@ void HTMLDocumentParser::handle_after_head(HTMLToken& token)
}
if (token.is_doctype()) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -770,7 +771,7 @@ void HTMLDocumentParser::handle_after_head(HTMLToken& token)
}
if (token.is_start_tag() && token.tag_name().is_one_of(HTML::TagNames::base, HTML::TagNames::basefont, HTML::TagNames::bgsound, HTML::TagNames::link, HTML::TagNames::meta, HTML::TagNames::noframes, HTML::TagNames::script, HTML::TagNames::style, HTML::TagNames::template_, HTML::TagNames::title)) {
PARSE_ERROR();
log_parse_error();
m_stack_of_open_elements.push(*m_head_element);
process_using_the_rules_for(InsertionMode::InHead, token);
m_stack_of_open_elements.elements().remove_first_matching([&](auto& entry) {
@ -789,7 +790,7 @@ void HTMLDocumentParser::handle_after_head(HTMLToken& token)
}
if ((token.is_start_tag() && token.tag_name() == HTML::TagNames::head) || token.is_end_tag()) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -815,7 +816,7 @@ void HTMLDocumentParser::close_a_p_element()
{
generate_implied_end_tags(HTML::TagNames::p);
if (current_node().local_name() != HTML::TagNames::p) {
PARSE_ERROR();
log_parse_error();
}
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::p);
}
@ -835,7 +836,7 @@ void HTMLDocumentParser::handle_after_body(HTMLToken& token)
}
if (token.is_doctype()) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -846,7 +847,7 @@ void HTMLDocumentParser::handle_after_body(HTMLToken& token)
if (token.is_end_tag() && token.tag_name() == HTML::TagNames::html) {
if (m_parsing_fragment) {
PARSE_ERROR();
log_parse_error();
return;
}
m_insertion_mode = InsertionMode::AfterAfterBody;
@ -858,7 +859,7 @@ void HTMLDocumentParser::handle_after_body(HTMLToken& token)
return;
}
PARSE_ERROR();
log_parse_error();
m_insertion_mode = InsertionMode::InBody;
process_using_the_rules_for(InsertionMode::InBody, token);
}
@ -881,7 +882,7 @@ void HTMLDocumentParser::handle_after_after_body(HTMLToken& token)
return;
}
PARSE_ERROR();
log_parse_error();
m_insertion_mode = InsertionMode::InBody;
process_using_the_rules_for(m_insertion_mode, token);
}
@ -955,18 +956,18 @@ HTMLDocumentParser::AdoptionAgencyAlgorithmOutcome HTMLDocumentParser::run_the_a
return AdoptionAgencyAlgorithmOutcome::RunAnyOtherEndTagSteps;
if (!m_stack_of_open_elements.contains(*formatting_element)) {
PARSE_ERROR();
log_parse_error();
m_list_of_active_formatting_elements.remove(*formatting_element);
return AdoptionAgencyAlgorithmOutcome::DoNothing;
}
if (!m_stack_of_open_elements.has_in_scope(*formatting_element)) {
PARSE_ERROR();
log_parse_error();
return AdoptionAgencyAlgorithmOutcome::DoNothing;
}
if (formatting_element != &current_node()) {
PARSE_ERROR();
log_parse_error();
}
RefPtr<DOM::Element> furthest_block = m_stack_of_open_elements.topmost_special_node_below(*formatting_element);
@ -1087,7 +1088,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
{
if (token.is_character()) {
if (token.code_point() == 0) {
PARSE_ERROR();
log_parse_error();
return;
}
if (token.is_parser_whitespace()) {
@ -1107,12 +1108,12 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
}
if (token.is_doctype()) {
PARSE_ERROR();
log_parse_error();
return;
}
if (token.is_start_tag() && token.tag_name() == HTML::TagNames::html) {
PARSE_ERROR();
log_parse_error();
if (m_stack_of_open_elements.contains(HTML::TagNames::template_))
return;
for (auto& attribute : token.m_tag.attributes) {
@ -1133,7 +1134,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
}
if (token.is_start_tag() && token.tag_name() == HTML::TagNames::body) {
PARSE_ERROR();
log_parse_error();
if (m_stack_of_open_elements.elements().size() == 1
|| m_stack_of_open_elements.elements().at(1).local_name() != HTML::TagNames::body
|| m_stack_of_open_elements.contains(HTML::TagNames::template_)) {
@ -1151,7 +1152,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
}
if (token.is_start_tag() && token.tag_name() == HTML::TagNames::frameset) {
PARSE_ERROR();
log_parse_error();
if (m_stack_of_open_elements.elements().size() == 1
|| m_stack_of_open_elements.elements().at(1).local_name() != HTML::TagNames::body) {
@ -1173,7 +1174,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
for (auto& node : m_stack_of_open_elements.elements()) {
if (!node.local_name().is_one_of(HTML::TagNames::dd, HTML::TagNames::dt, HTML::TagNames::li, HTML::TagNames::optgroup, HTML::TagNames::option, HTML::TagNames::p, HTML::TagNames::rb, HTML::TagNames::rp, HTML::TagNames::rt, HTML::TagNames::rtc, HTML::TagNames::tbody, HTML::TagNames::td, HTML::TagNames::tfoot, HTML::TagNames::th, HTML::TagNames::thead, HTML::TagNames::tr, HTML::TagNames::body, HTML::TagNames::html)) {
PARSE_ERROR();
log_parse_error();
break;
}
}
@ -1184,13 +1185,13 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
if (token.is_end_tag() && token.tag_name() == HTML::TagNames::body) {
if (!m_stack_of_open_elements.has_in_scope(HTML::TagNames::body)) {
PARSE_ERROR();
log_parse_error();
return;
}
for (auto& node : m_stack_of_open_elements.elements()) {
if (!node.local_name().is_one_of(HTML::TagNames::dd, HTML::TagNames::dt, HTML::TagNames::li, HTML::TagNames::optgroup, HTML::TagNames::option, HTML::TagNames::p, HTML::TagNames::rb, HTML::TagNames::rp, HTML::TagNames::rt, HTML::TagNames::rtc, HTML::TagNames::tbody, HTML::TagNames::td, HTML::TagNames::tfoot, HTML::TagNames::th, HTML::TagNames::thead, HTML::TagNames::tr, HTML::TagNames::body, HTML::TagNames::html)) {
PARSE_ERROR();
log_parse_error();
break;
}
}
@ -1201,13 +1202,13 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
if (token.is_end_tag() && token.tag_name() == HTML::TagNames::html) {
if (!m_stack_of_open_elements.has_in_scope(HTML::TagNames::body)) {
PARSE_ERROR();
log_parse_error();
return;
}
for (auto& node : m_stack_of_open_elements.elements()) {
if (!node.local_name().is_one_of(HTML::TagNames::dd, HTML::TagNames::dt, HTML::TagNames::li, HTML::TagNames::optgroup, HTML::TagNames::option, HTML::TagNames::p, HTML::TagNames::rb, HTML::TagNames::rp, HTML::TagNames::rt, HTML::TagNames::rtc, HTML::TagNames::tbody, HTML::TagNames::td, HTML::TagNames::tfoot, HTML::TagNames::th, HTML::TagNames::thead, HTML::TagNames::tr, HTML::TagNames::body, HTML::TagNames::html)) {
PARSE_ERROR();
log_parse_error();
break;
}
}
@ -1228,7 +1229,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
if (m_stack_of_open_elements.has_in_button_scope(HTML::TagNames::p))
close_a_p_element();
if (current_node().local_name().is_one_of(HTML::TagNames::h1, HTML::TagNames::h2, HTML::TagNames::h3, HTML::TagNames::h4, HTML::TagNames::h5, HTML::TagNames::h6)) {
PARSE_ERROR();
log_parse_error();
m_stack_of_open_elements.pop();
}
insert_html_element(token);
@ -1257,7 +1258,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
if (token.is_start_tag() && token.tag_name() == HTML::TagNames::form) {
if (m_form_element && !m_stack_of_open_elements.contains(HTML::TagNames::template_)) {
PARSE_ERROR();
log_parse_error();
return;
}
if (m_stack_of_open_elements.has_in_button_scope(HTML::TagNames::p))
@ -1277,7 +1278,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
if (node->local_name() == HTML::TagNames::li) {
generate_implied_end_tags(HTML::TagNames::li);
if (current_node().local_name() != HTML::TagNames::li) {
PARSE_ERROR();
log_parse_error();
}
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::li);
break;
@ -1301,7 +1302,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
if (node->local_name() == HTML::TagNames::dd) {
generate_implied_end_tags(HTML::TagNames::dd);
if (current_node().local_name() != HTML::TagNames::dd) {
PARSE_ERROR();
log_parse_error();
}
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::dd);
break;
@ -1309,7 +1310,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
if (node->local_name() == HTML::TagNames::dt) {
generate_implied_end_tags(HTML::TagNames::dt);
if (current_node().local_name() != HTML::TagNames::dt) {
PARSE_ERROR();
log_parse_error();
}
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::dt);
break;
@ -1333,7 +1334,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
if (token.is_start_tag() && token.tag_name() == HTML::TagNames::button) {
if (m_stack_of_open_elements.has_in_button_scope(HTML::TagNames::button)) {
PARSE_ERROR();
log_parse_error();
generate_implied_end_tags();
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::button);
}
@ -1345,14 +1346,14 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
if (token.is_end_tag() && token.tag_name().is_one_of(HTML::TagNames::address, HTML::TagNames::article, HTML::TagNames::aside, HTML::TagNames::blockquote, HTML::TagNames::button, HTML::TagNames::center, HTML::TagNames::details, HTML::TagNames::dialog, HTML::TagNames::dir, HTML::TagNames::div, HTML::TagNames::dl, HTML::TagNames::fieldset, HTML::TagNames::figcaption, HTML::TagNames::figure, HTML::TagNames::footer, HTML::TagNames::header, HTML::TagNames::hgroup, HTML::TagNames::listing, HTML::TagNames::main, HTML::TagNames::menu, HTML::TagNames::nav, HTML::TagNames::ol, HTML::TagNames::pre, HTML::TagNames::section, HTML::TagNames::summary, HTML::TagNames::ul)) {
if (!m_stack_of_open_elements.has_in_scope(token.tag_name())) {
PARSE_ERROR();
log_parse_error();
return;
}
generate_implied_end_tags();
if (current_node().local_name() != token.tag_name()) {
PARSE_ERROR();
log_parse_error();
}
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(token.tag_name());
@ -1364,22 +1365,22 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
auto node = m_form_element;
m_form_element = nullptr;
if (!node || !m_stack_of_open_elements.has_in_scope(*node)) {
PARSE_ERROR();
log_parse_error();
return;
}
generate_implied_end_tags();
if (&current_node() != node) {
PARSE_ERROR();
log_parse_error();
}
m_stack_of_open_elements.elements().remove_first_matching([&](auto& entry) { return entry.ptr() == node.ptr(); });
} else {
if (!m_stack_of_open_elements.has_in_scope(HTML::TagNames::form)) {
PARSE_ERROR();
log_parse_error();
return;
}
generate_implied_end_tags();
if (current_node().local_name() != HTML::TagNames::form) {
PARSE_ERROR();
log_parse_error();
}
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::form);
}
@ -1388,7 +1389,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
if (token.is_end_tag() && token.tag_name() == HTML::TagNames::p) {
if (!m_stack_of_open_elements.has_in_button_scope(HTML::TagNames::p)) {
PARSE_ERROR();
log_parse_error();
insert_html_element(HTMLToken::make_start_tag(HTML::TagNames::p));
}
close_a_p_element();
@ -1397,12 +1398,12 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
if (token.is_end_tag() && token.tag_name() == HTML::TagNames::li) {
if (!m_stack_of_open_elements.has_in_list_item_scope(HTML::TagNames::li)) {
PARSE_ERROR();
log_parse_error();
return;
}
generate_implied_end_tags(HTML::TagNames::li);
if (current_node().local_name() != HTML::TagNames::li) {
PARSE_ERROR();
log_parse_error();
dbgln("Expected <li> current node, but had <{}>", current_node().local_name());
}
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::li);
@ -1411,12 +1412,12 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
if (token.is_end_tag() && token.tag_name().is_one_of(HTML::TagNames::dd, HTML::TagNames::dt)) {
if (!m_stack_of_open_elements.has_in_scope(token.tag_name())) {
PARSE_ERROR();
log_parse_error();
return;
}
generate_implied_end_tags(token.tag_name());
if (current_node().local_name() != token.tag_name()) {
PARSE_ERROR();
log_parse_error();
}
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(token.tag_name());
return;
@ -1429,13 +1430,13 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
&& !m_stack_of_open_elements.has_in_scope(HTML::TagNames::h4)
&& !m_stack_of_open_elements.has_in_scope(HTML::TagNames::h5)
&& !m_stack_of_open_elements.has_in_scope(HTML::TagNames::h6)) {
PARSE_ERROR();
log_parse_error();
return;
}
generate_implied_end_tags();
if (current_node().local_name() != token.tag_name()) {
PARSE_ERROR();
log_parse_error();
}
for (;;) {
@ -1448,7 +1449,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
if (token.is_start_tag() && token.tag_name() == HTML::TagNames::a) {
if (auto* element = m_list_of_active_formatting_elements.last_element_with_tag_name_before_marker(HTML::TagNames::a)) {
PARSE_ERROR();
log_parse_error();
if (run_the_adoption_agency_algorithm(token) == AdoptionAgencyAlgorithmOutcome::RunAnyOtherEndTagSteps)
goto AnyOtherEndTag;
m_list_of_active_formatting_elements.remove(*element);
@ -1472,7 +1473,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
if (token.is_start_tag() && token.tag_name() == HTML::TagNames::nobr) {
reconstruct_the_active_formatting_elements();
if (m_stack_of_open_elements.has_in_scope(HTML::TagNames::nobr)) {
PARSE_ERROR();
log_parse_error();
run_the_adoption_agency_algorithm(token);
reconstruct_the_active_formatting_elements();
}
@ -1497,13 +1498,13 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
if (token.is_end_tag() && token.tag_name().is_one_of(HTML::TagNames::applet, HTML::TagNames::marquee, HTML::TagNames::object)) {
if (!m_stack_of_open_elements.has_in_scope(token.tag_name())) {
PARSE_ERROR();
log_parse_error();
return;
}
generate_implied_end_tags();
if (current_node().local_name() != token.tag_name()) {
PARSE_ERROR();
log_parse_error();
}
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(token.tag_name());
m_list_of_active_formatting_elements.clear_up_to_the_last_marker();
@ -1567,7 +1568,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
if (token.is_start_tag() && token.tag_name() == HTML::TagNames::image) {
// Parse error. Change the token's tag name to HTML::TagNames::img and reprocess it. (Don't ask.)
PARSE_ERROR();
log_parse_error();
token.m_tag.tag_name.clear();
token.m_tag.tag_name.append(HTML::TagNames::img);
process_using_the_rules_for(m_insertion_mode, token);
@ -1649,7 +1650,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
generate_implied_end_tags();
if (current_node().local_name() != HTML::TagNames::ruby)
PARSE_ERROR();
log_parse_error();
insert_html_element(token);
return;
@ -1660,7 +1661,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
generate_implied_end_tags(HTML::TagNames::rtc);
if (current_node().local_name() != HTML::TagNames::rtc || current_node().local_name() != HTML::TagNames::ruby)
PARSE_ERROR();
log_parse_error();
insert_html_element(token);
return;
@ -1695,7 +1696,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
}
if ((token.is_start_tag() && token.tag_name().is_one_of(HTML::TagNames::caption, HTML::TagNames::col, HTML::TagNames::colgroup, HTML::TagNames::frame, HTML::TagNames::head, HTML::TagNames::tbody, HTML::TagNames::td, HTML::TagNames::tfoot, HTML::TagNames::th, HTML::TagNames::thead, HTML::TagNames::tr))) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -1714,7 +1715,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
if (node->local_name() == token.tag_name()) {
generate_implied_end_tags(token.tag_name());
if (node != current_node()) {
PARSE_ERROR();
log_parse_error();
}
while (&current_node() != node) {
m_stack_of_open_elements.pop();
@ -1723,7 +1724,7 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token)
break;
}
if (is_special_tag(node->local_name(), node->namespace_())) {
PARSE_ERROR();
log_parse_error();
return;
}
}
@ -1871,7 +1872,7 @@ void HTMLDocumentParser::handle_text(HTMLToken& token)
return;
}
if (token.is_end_of_file()) {
PARSE_ERROR();
log_parse_error();
if (current_node().local_name() == HTML::TagNames::script)
downcast<HTMLScriptElement>(current_node()).set_already_started({}, true);
m_stack_of_open_elements.pop();
@ -1985,7 +1986,7 @@ void HTMLDocumentParser::handle_in_row(HTMLToken& token)
if (token.is_end_tag() && token.tag_name() == HTML::TagNames::tr) {
if (!m_stack_of_open_elements.has_in_table_scope(HTML::TagNames::tr)) {
PARSE_ERROR();
log_parse_error();
return;
}
clear_the_stack_back_to_a_table_row_context();
@ -1997,7 +1998,7 @@ void HTMLDocumentParser::handle_in_row(HTMLToken& token)
if ((token.is_start_tag() && token.tag_name().is_one_of(HTML::TagNames::caption, HTML::TagNames::col, HTML::TagNames::colgroup, HTML::TagNames::tbody, HTML::TagNames::tfoot, HTML::TagNames::thead, HTML::TagNames::tr))
|| (token.is_end_tag() && token.tag_name() == HTML::TagNames::table)) {
if (!m_stack_of_open_elements.has_in_table_scope(HTML::TagNames::tr)) {
PARSE_ERROR();
log_parse_error();
return;
}
clear_the_stack_back_to_a_table_row_context();
@ -2009,7 +2010,7 @@ void HTMLDocumentParser::handle_in_row(HTMLToken& token)
if (token.is_end_tag() && token.tag_name().is_one_of(HTML::TagNames::tbody, HTML::TagNames::tfoot, HTML::TagNames::thead)) {
if (!m_stack_of_open_elements.has_in_table_scope(token.tag_name())) {
PARSE_ERROR();
log_parse_error();
return;
}
if (!m_stack_of_open_elements.has_in_table_scope(HTML::TagNames::tr)) {
@ -2023,7 +2024,7 @@ void HTMLDocumentParser::handle_in_row(HTMLToken& token)
}
if (token.is_end_tag() && token.tag_name().is_one_of(HTML::TagNames::body, HTML::TagNames::caption, HTML::TagNames::col, HTML::TagNames::colgroup, HTML::TagNames::html, HTML::TagNames::td, HTML::TagNames::th)) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -2034,7 +2035,7 @@ void HTMLDocumentParser::close_the_cell()
{
generate_implied_end_tags();
if (!current_node().local_name().is_one_of(HTML::TagNames::td, HTML::TagNames::th)) {
PARSE_ERROR();
log_parse_error();
}
while (!current_node().local_name().is_one_of(HTML::TagNames::td, HTML::TagNames::th))
m_stack_of_open_elements.pop();
@ -2047,13 +2048,13 @@ void HTMLDocumentParser::handle_in_cell(HTMLToken& token)
{
if (token.is_end_tag() && token.tag_name().is_one_of(HTML::TagNames::td, HTML::TagNames::th)) {
if (!m_stack_of_open_elements.has_in_table_scope(token.tag_name())) {
PARSE_ERROR();
log_parse_error();
return;
}
generate_implied_end_tags();
if (current_node().local_name() != token.tag_name()) {
PARSE_ERROR();
log_parse_error();
}
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(token.tag_name());
@ -2066,7 +2067,7 @@ void HTMLDocumentParser::handle_in_cell(HTMLToken& token)
if (token.is_start_tag() && token.tag_name().is_one_of(HTML::TagNames::caption, HTML::TagNames::col, HTML::TagNames::colgroup, HTML::TagNames::tbody, HTML::TagNames::td, HTML::TagNames::tfoot, HTML::TagNames::th, HTML::TagNames::thead, HTML::TagNames::tr)) {
if (!m_stack_of_open_elements.has_in_table_scope(HTML::TagNames::td) && !m_stack_of_open_elements.has_in_table_scope(HTML::TagNames::th)) {
VERIFY(m_parsing_fragment);
PARSE_ERROR();
log_parse_error();
return;
}
close_the_cell();
@ -2075,13 +2076,13 @@ void HTMLDocumentParser::handle_in_cell(HTMLToken& token)
}
if (token.is_end_tag() && token.tag_name().is_one_of(HTML::TagNames::body, HTML::TagNames::caption, HTML::TagNames::col, HTML::TagNames::colgroup, HTML::TagNames::html)) {
PARSE_ERROR();
log_parse_error();
return;
}
if (token.is_end_tag() && token.tag_name().is_one_of(HTML::TagNames::table, HTML::TagNames::tbody, HTML::TagNames::tfoot, HTML::TagNames::thead, HTML::TagNames::tr)) {
if (!m_stack_of_open_elements.has_in_table_scope(token.tag_name())) {
PARSE_ERROR();
log_parse_error();
return;
}
close_the_cell();
@ -2097,7 +2098,7 @@ void HTMLDocumentParser::handle_in_table_text(HTMLToken& token)
{
if (token.is_character()) {
if (token.code_point() == 0) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -2112,7 +2113,7 @@ void HTMLDocumentParser::handle_in_table_text(HTMLToken& token)
// are character tokens that are not ASCII whitespace, then this is a parse error:
// reprocess the character tokens in the pending table character tokens list using
// the rules given in the "anything else" entry in the "in table" insertion mode.
PARSE_ERROR();
log_parse_error();
m_foster_parenting = true;
process_using_the_rules_for(InsertionMode::InBody, token);
m_foster_parenting = false;
@ -2138,7 +2139,7 @@ void HTMLDocumentParser::handle_in_table_body(HTMLToken& token)
}
if (token.is_start_tag() && token.tag_name().is_one_of(HTML::TagNames::th, HTML::TagNames::td)) {
PARSE_ERROR();
log_parse_error();
clear_the_stack_back_to_a_table_body_context();
insert_html_element(HTMLToken::make_start_tag(HTML::TagNames::tr));
m_insertion_mode = InsertionMode::InRow;
@ -2148,7 +2149,7 @@ void HTMLDocumentParser::handle_in_table_body(HTMLToken& token)
if (token.is_end_tag() && token.tag_name().is_one_of(HTML::TagNames::tbody, HTML::TagNames::tfoot, HTML::TagNames::thead)) {
if (!m_stack_of_open_elements.has_in_table_scope(token.tag_name())) {
PARSE_ERROR();
log_parse_error();
return;
}
clear_the_stack_back_to_a_table_body_context();
@ -2163,7 +2164,7 @@ void HTMLDocumentParser::handle_in_table_body(HTMLToken& token)
if (!m_stack_of_open_elements.has_in_table_scope(HTML::TagNames::tbody)
&& !m_stack_of_open_elements.has_in_table_scope(HTML::TagNames::thead)
&& !m_stack_of_open_elements.has_in_table_scope(HTML::TagNames::tfoot)) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -2175,7 +2176,7 @@ void HTMLDocumentParser::handle_in_table_body(HTMLToken& token)
}
if (token.is_end_tag() && token.tag_name().is_one_of(HTML::TagNames::body, HTML::TagNames::caption, HTML::TagNames::col, HTML::TagNames::colgroup, HTML::TagNames::html, HTML::TagNames::td, HTML::TagNames::th, HTML::TagNames::tr)) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -2196,7 +2197,7 @@ void HTMLDocumentParser::handle_in_table(HTMLToken& token)
return;
}
if (token.is_doctype()) {
PARSE_ERROR();
log_parse_error();
return;
}
if (token.is_start_tag() && token.tag_name() == HTML::TagNames::caption) {
@ -2233,7 +2234,7 @@ void HTMLDocumentParser::handle_in_table(HTMLToken& token)
return;
}
if (token.is_start_tag() && token.tag_name() == HTML::TagNames::table) {
PARSE_ERROR();
log_parse_error();
if (!m_stack_of_open_elements.has_in_table_scope(HTML::TagNames::table))
return;
@ -2245,7 +2246,7 @@ void HTMLDocumentParser::handle_in_table(HTMLToken& token)
}
if (token.is_end_tag() && token.tag_name() == HTML::TagNames::table) {
if (!m_stack_of_open_elements.has_in_table_scope(HTML::TagNames::table)) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -2255,7 +2256,7 @@ void HTMLDocumentParser::handle_in_table(HTMLToken& token)
return;
}
if (token.is_end_tag() && token.tag_name().is_one_of(HTML::TagNames::body, HTML::TagNames::caption, HTML::TagNames::col, HTML::TagNames::colgroup, HTML::TagNames::html, HTML::TagNames::tbody, HTML::TagNames::td, HTML::TagNames::tfoot, HTML::TagNames::th, HTML::TagNames::thead, HTML::TagNames::tr)) {
PARSE_ERROR();
log_parse_error();
return;
}
if ((token.is_start_tag() && token.tag_name().is_one_of(HTML::TagNames::style, HTML::TagNames::script, HTML::TagNames::template_))
@ -2269,7 +2270,7 @@ void HTMLDocumentParser::handle_in_table(HTMLToken& token)
goto AnythingElse;
}
PARSE_ERROR();
log_parse_error();
insert_html_element(token);
// FIXME: Is this the correct interpretation of "Pop that input element off the stack of open elements."?
@ -2280,7 +2281,7 @@ void HTMLDocumentParser::handle_in_table(HTMLToken& token)
return;
}
if (token.is_start_tag() && token.tag_name() == HTML::TagNames::form) {
PARSE_ERROR();
log_parse_error();
if (m_form_element || m_stack_of_open_elements.contains(HTML::TagNames::template_)) {
return;
}
@ -2297,7 +2298,7 @@ void HTMLDocumentParser::handle_in_table(HTMLToken& token)
}
AnythingElse:
PARSE_ERROR();
log_parse_error();
m_foster_parenting = true;
process_using_the_rules_for(InsertionMode::InBody, token);
m_foster_parenting = false;
@ -2306,7 +2307,7 @@ AnythingElse:
void HTMLDocumentParser::handle_in_select_in_table(HTMLToken& token)
{
if (token.is_start_tag() && token.tag_name().is_one_of(HTML::TagNames::caption, HTML::TagNames::table, HTML::TagNames::tbody, HTML::TagNames::tfoot, HTML::TagNames::thead, HTML::TagNames::tr, HTML::TagNames::td, HTML::TagNames::th)) {
PARSE_ERROR();
log_parse_error();
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::select);
reset_the_insertion_mode_appropriately();
process_using_the_rules_for(m_insertion_mode, token);
@ -2314,7 +2315,7 @@ void HTMLDocumentParser::handle_in_select_in_table(HTMLToken& token)
}
if (token.is_end_tag() && token.tag_name().is_one_of(HTML::TagNames::caption, HTML::TagNames::table, HTML::TagNames::tbody, HTML::TagNames::tfoot, HTML::TagNames::thead, HTML::TagNames::tr, HTML::TagNames::td, HTML::TagNames::th)) {
PARSE_ERROR();
log_parse_error();
if (!m_stack_of_open_elements.has_in_table_scope(token.tag_name()))
return;
@ -2332,7 +2333,7 @@ void HTMLDocumentParser::handle_in_select(HTMLToken& token)
{
if (token.is_character()) {
if (token.code_point() == 0) {
PARSE_ERROR();
log_parse_error();
return;
}
insert_character(token.code_point());
@ -2345,7 +2346,7 @@ void HTMLDocumentParser::handle_in_select(HTMLToken& token)
}
if (token.is_doctype()) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -2380,7 +2381,7 @@ void HTMLDocumentParser::handle_in_select(HTMLToken& token)
if (current_node().local_name() == HTML::TagNames::optgroup) {
m_stack_of_open_elements.pop();
} else {
PARSE_ERROR();
log_parse_error();
return;
}
return;
@ -2390,7 +2391,7 @@ void HTMLDocumentParser::handle_in_select(HTMLToken& token)
if (current_node().local_name() == HTML::TagNames::option) {
m_stack_of_open_elements.pop();
} else {
PARSE_ERROR();
log_parse_error();
return;
}
return;
@ -2399,7 +2400,7 @@ void HTMLDocumentParser::handle_in_select(HTMLToken& token)
if (token.is_end_tag() && token.tag_name() == HTML::TagNames::select) {
if (!m_stack_of_open_elements.has_in_select_scope(HTML::TagNames::select)) {
VERIFY(m_parsing_fragment);
PARSE_ERROR();
log_parse_error();
return;
}
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::select);
@ -2408,7 +2409,7 @@ void HTMLDocumentParser::handle_in_select(HTMLToken& token)
}
if (token.is_start_tag() && token.tag_name() == HTML::TagNames::select) {
PARSE_ERROR();
log_parse_error();
if (!m_stack_of_open_elements.has_in_select_scope(HTML::TagNames::select)) {
VERIFY(m_parsing_fragment);
@ -2421,7 +2422,7 @@ void HTMLDocumentParser::handle_in_select(HTMLToken& token)
}
if (token.is_start_tag() && token.tag_name().is_one_of(HTML::TagNames::input, HTML::TagNames::keygen, HTML::TagNames::textarea)) {
PARSE_ERROR();
log_parse_error();
if (!m_stack_of_open_elements.has_in_select_scope(HTML::TagNames::select)) {
VERIFY(m_parsing_fragment);
@ -2449,7 +2450,7 @@ void HTMLDocumentParser::handle_in_select(HTMLToken& token)
return;
}
PARSE_ERROR();
log_parse_error();
}
void HTMLDocumentParser::handle_in_caption(HTMLToken& token)
@ -2457,14 +2458,14 @@ void HTMLDocumentParser::handle_in_caption(HTMLToken& token)
if (token.is_end_tag() && token.tag_name() == HTML::TagNames::caption) {
if (!m_stack_of_open_elements.has_in_table_scope(HTML::TagNames::caption)) {
VERIFY(m_parsing_fragment);
PARSE_ERROR();
log_parse_error();
return;
}
generate_implied_end_tags();
if (current_node().local_name() != HTML::TagNames::caption)
PARSE_ERROR();
log_parse_error();
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::caption);
m_list_of_active_formatting_elements.clear_up_to_the_last_marker();
@ -2477,14 +2478,14 @@ void HTMLDocumentParser::handle_in_caption(HTMLToken& token)
|| (token.is_end_tag() && token.tag_name() == HTML::TagNames::table)) {
if (!m_stack_of_open_elements.has_in_table_scope(HTML::TagNames::caption)) {
VERIFY(m_parsing_fragment);
PARSE_ERROR();
log_parse_error();
return;
}
generate_implied_end_tags();
if (current_node().local_name() != HTML::TagNames::caption)
PARSE_ERROR();
log_parse_error();
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::caption);
m_list_of_active_formatting_elements.clear_up_to_the_last_marker();
@ -2495,7 +2496,7 @@ void HTMLDocumentParser::handle_in_caption(HTMLToken& token)
}
if (token.is_end_tag() && token.tag_name().is_one_of(HTML::TagNames::body, HTML::TagNames::col, HTML::TagNames::colgroup, HTML::TagNames::html, HTML::TagNames::tbody, HTML::TagNames::td, HTML::TagNames::tfoot, HTML::TagNames::th, HTML::TagNames::thead, HTML::TagNames::tr)) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -2515,7 +2516,7 @@ void HTMLDocumentParser::handle_in_column_group(HTMLToken& token)
}
if (token.is_doctype()) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -2533,7 +2534,7 @@ void HTMLDocumentParser::handle_in_column_group(HTMLToken& token)
if (token.is_end_tag() && token.tag_name() == HTML::TagNames::colgroup) {
if (current_node().local_name() != HTML::TagNames::colgroup) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -2543,7 +2544,7 @@ void HTMLDocumentParser::handle_in_column_group(HTMLToken& token)
}
if (token.is_end_tag() && token.tag_name() == HTML::TagNames::col) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -2558,7 +2559,7 @@ void HTMLDocumentParser::handle_in_column_group(HTMLToken& token)
}
if (current_node().local_name() != HTML::TagNames::colgroup) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -2625,7 +2626,7 @@ void HTMLDocumentParser::handle_in_template(HTMLToken& token)
}
if (token.is_end_tag()) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -2636,7 +2637,7 @@ void HTMLDocumentParser::handle_in_template(HTMLToken& token)
return;
}
PARSE_ERROR();
log_parse_error();
m_stack_of_open_elements.pop_until_an_element_with_tag_name_has_been_popped(HTML::TagNames::template_);
m_list_of_active_formatting_elements.clear_up_to_the_last_marker();
m_stack_of_template_insertion_modes.take_last();
@ -2658,7 +2659,7 @@ void HTMLDocumentParser::handle_in_frameset(HTMLToken& token)
}
if (token.is_doctype()) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -2702,7 +2703,7 @@ void HTMLDocumentParser::handle_in_frameset(HTMLToken& token)
return;
}
PARSE_ERROR();
log_parse_error();
}
void HTMLDocumentParser::handle_after_frameset(HTMLToken& token)
@ -2718,7 +2719,7 @@ void HTMLDocumentParser::handle_after_frameset(HTMLToken& token)
}
if (token.is_doctype()) {
PARSE_ERROR();
log_parse_error();
return;
}
@ -2742,7 +2743,7 @@ void HTMLDocumentParser::handle_after_frameset(HTMLToken& token)
return;
}
PARSE_ERROR();
log_parse_error();
}
void HTMLDocumentParser::handle_after_after_frameset(HTMLToken& token)
@ -2768,14 +2769,14 @@ void HTMLDocumentParser::handle_after_after_frameset(HTMLToken& token)
return;
}
PARSE_ERROR();
log_parse_error();
}
void HTMLDocumentParser::process_using_the_rules_for_foreign_content(HTMLToken& token)
{
if (token.is_character()) {
if (token.code_point() == 0) {
PARSE_ERROR();
log_parse_error();
insert_character(0xFFFD);
return;
}
@ -2794,13 +2795,13 @@ void HTMLDocumentParser::process_using_the_rules_for_foreign_content(HTMLToken&
}
if (token.is_doctype()) {
PARSE_ERROR();
log_parse_error();
return;
}
if ((token.is_start_tag() && token.tag_name().is_one_of(HTML::TagNames::b, HTML::TagNames::big, HTML::TagNames::blockquote, HTML::TagNames::body, HTML::TagNames::br, HTML::TagNames::center, HTML::TagNames::code, HTML::TagNames::dd, HTML::TagNames::div, HTML::TagNames::dl, HTML::TagNames::dt, HTML::TagNames::em, HTML::TagNames::embed, HTML::TagNames::h1, HTML::TagNames::h2, HTML::TagNames::h3, HTML::TagNames::h4, HTML::TagNames::h5, HTML::TagNames::h6, HTML::TagNames::head, HTML::TagNames::hr, HTML::TagNames::i, HTML::TagNames::img, HTML::TagNames::li, HTML::TagNames::listing, HTML::TagNames::menu, HTML::TagNames::meta, HTML::TagNames::nobr, HTML::TagNames::ol, HTML::TagNames::p, HTML::TagNames::pre, HTML::TagNames::ruby, HTML::TagNames::s, HTML::TagNames::small, HTML::TagNames::span, HTML::TagNames::strong, HTML::TagNames::strike, HTML::TagNames::sub, HTML::TagNames::sup, HTML::TagNames::table, HTML::TagNames::tt, HTML::TagNames::u, HTML::TagNames::ul, HTML::TagNames::var))
|| (token.is_start_tag() && token.tag_name() == HTML::TagNames::font && (token.has_attribute(HTML::AttributeNames::color) || token.has_attribute(HTML::AttributeNames::face) || token.has_attribute(HTML::AttributeNames::size)))) {
PARSE_ERROR();
log_parse_error();
if (m_parsing_fragment) {
goto AnyOtherStartTag;
}
@ -2843,7 +2844,7 @@ void HTMLDocumentParser::process_using_the_rules_for_foreign_content(HTMLToken&
RefPtr<DOM::Element> node = current_node();
// FIXME: Not sure if this is the correct to_lowercase, as the specification says "to ASCII lowercase"
if (node->tag_name().to_lowercase() != token.tag_name())
PARSE_ERROR();
log_parse_error();
for (ssize_t i = m_stack_of_open_elements.elements().size() - 1; i >= 0; --i) {
if (node == m_stack_of_open_elements.first()) {
VERIFY(m_parsing_fragment);