From cd576e594d3462b6e2a109d4c5b28dc49c59f49d Mon Sep 17 00:00:00 2001 From: mikiubo Date: Thu, 2 Jan 2025 00:42:49 +0100 Subject: [PATCH] LibXml: Notify listener when doctype is parsed --- Libraries/LibXML/Parser/Parser.cpp | 7 +++--- .../dom/nodes/DocumentType-literal-xhtml.txt | 6 +++++ .../nodes/DocumentType-literal-xhtml.xhtml | 23 +++++++++++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 Tests/LibWeb/Text/expected/wpt-import/dom/nodes/DocumentType-literal-xhtml.txt create mode 100644 Tests/LibWeb/Text/input/wpt-import/dom/nodes/DocumentType-literal-xhtml.xhtml diff --git a/Libraries/LibXML/Parser/Parser.cpp b/Libraries/LibXML/Parser/Parser.cpp index aa0503cf14b..6e1e93d326b 100644 --- a/Libraries/LibXML/Parser/Parser.cpp +++ b/Libraries/LibXML/Parser/Parser.cpp @@ -182,9 +182,6 @@ ErrorOr Parser::parse_with_listener(Listener& listener) if (result.is_error()) m_listener->error(result.error()); m_listener->document_end(); - if (m_doctype.has_value()) { - m_listener->set_doctype(m_doctype.release_value()); - } m_root_node.clear(); return result; } @@ -622,6 +619,10 @@ ErrorOr Parser::parse_doctype_decl() rollback.disarm(); m_doctype = move(doctype); + if (m_doctype.has_value() && m_listener) { + m_listener->set_doctype(m_doctype.value()); + } + return {}; } diff --git a/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/DocumentType-literal-xhtml.txt b/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/DocumentType-literal-xhtml.txt new file mode 100644 index 00000000000..bca3c1b0233 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/dom/nodes/DocumentType-literal-xhtml.txt @@ -0,0 +1,6 @@ +Harness status: OK + +Found 1 tests + +1 Pass +Pass DocumentType literals \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/dom/nodes/DocumentType-literal-xhtml.xhtml b/Tests/LibWeb/Text/input/wpt-import/dom/nodes/DocumentType-literal-xhtml.xhtml new file mode 100644 index 00000000000..72fed402db0 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/dom/nodes/DocumentType-literal-xhtml.xhtml @@ -0,0 +1,23 @@ + + + +DocumentType literals + + + + + + + +
+ + +