LibWeb: Set doctype node immediately while parsing XML document

Instead of deferring it to the end of parsing, where scripts that
were expecting to look at the doctype may have already run.
This commit is contained in:
Andreas Kling 2024-11-20 11:43:20 +01:00 committed by Andreas Kling
commit cd446e5e9c
Notes: github-actions[bot] 2024-11-20 15:11:55 +00:00
6 changed files with 66 additions and 9 deletions

View file

@ -62,7 +62,7 @@ void XMLDocumentBuilder::set_source(ByteString source)
m_document->set_source(MUST(String::from_byte_string(source)));
}
void XMLDocumentBuilder::set_doctype(XML::Doctype doctype)
void XMLDocumentBuilder::doctype(XML::Doctype const& doctype)
{
if (m_document->doctype()) {
return;
@ -73,13 +73,13 @@ void XMLDocumentBuilder::set_doctype(XML::Doctype doctype)
document_type->set_name(name);
if (doctype.external_id.has_value()) {
auto external_id = doctype.external_id.release_value();
auto const& external_id = *doctype.external_id;
auto system_id = MUST(AK::String::from_byte_string(external_id.system_id.system_literal));
document_type->set_system_id(system_id);
if (external_id.public_id.has_value()) {
auto public_id = MUST(AK::String::from_byte_string(external_id.public_id.release_value().public_literal));
auto public_id = MUST(AK::String::from_byte_string(external_id.public_id->public_literal));
document_type->set_public_id(public_id);
}
}