mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +00:00
LibWeb: Wait until ReadyState is complete before detaching HTML parser
Previously, the DOM complete time was never being set, as the HTML parser was detached before `DocumentReadyState` was set to complete.
This commit is contained in:
parent
03024765e9
commit
f8b8c9c4a4
Notes:
github-actions[bot]
2025-01-11 10:12:54 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/f8b8c9c4a4e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3156
1 changed files with 5 additions and 2 deletions
|
@ -240,7 +240,6 @@ void HTMLParser::run(const URL::URL& url, HTMLTokenizer::StopAtInsertionPoint st
|
|||
m_document->set_source(MUST(String::from_byte_string(m_tokenizer.source())));
|
||||
run(stop_at_insertion_point);
|
||||
the_end(*m_document, this);
|
||||
m_document->detach_parser({});
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/parsing.html#the-end
|
||||
|
@ -339,10 +338,14 @@ void HTMLParser::the_end(GC::Ref<DOM::Document> document, GC::Ptr<HTMLParser> pa
|
|||
}));
|
||||
|
||||
// 9. Queue a global task on the DOM manipulation task source given the Document's relevant global object to run the following steps:
|
||||
queue_global_task(HTML::Task::Source::DOMManipulation, *document, GC::create_function(document->heap(), [document] {
|
||||
queue_global_task(HTML::Task::Source::DOMManipulation, *document, GC::create_function(document->heap(), [document, parser] {
|
||||
// 1. Update the current document readiness to "complete".
|
||||
document->update_readiness(HTML::DocumentReadyState::Complete);
|
||||
|
||||
// AD-HOC: We need to wait until the document ready state is complete before detaching the parser, otherwise the DOM complete time will not be set correctly.
|
||||
if (parser)
|
||||
document->detach_parser({});
|
||||
|
||||
// 2. If the Document object's browsing context is null, then abort these steps.
|
||||
if (!document->browsing_context())
|
||||
return;
|
||||
|
|
Loading…
Add table
Reference in a new issue