1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:18:13 +00:00

LibWeb: Handle two kinds of deferred script executions

This patch adds two script lists to Document:

- Scripts to execute when parsing has finished
- Scripts to execute as soon as possible

Since we don't actually load scripts asynchronously yet (we just do a
synchronous load when parsing the <script> element for simplicity),
these are already loaded by the time we get to "The end" of parsing.
This commit is contained in:
Andreas Kling 2020-05-30 12:26:15 +02:00
parent 6f85422e8a
commit e82226f3fb
4 changed files with 41 additions and 6 deletions

View file

@ -51,10 +51,10 @@
#include <LibWeb/DOM/Window.h>
#include <LibWeb/Dump.h>
#include <LibWeb/Frame.h>
#include <LibWeb/PageView.h>
#include <LibWeb/Layout/LayoutDocument.h>
#include <LibWeb/Layout/LayoutTreeBuilder.h>
#include <LibWeb/Origin.h>
#include <LibWeb/PageView.h>
#include <LibWeb/Parser/CSSParser.h>
#include <stdio.h>
@ -429,4 +429,24 @@ NonnullRefPtr<HTMLScriptElement> Document::take_pending_parsing_blocking_script(
return m_pending_parsing_blocking_script.release_nonnull();
}
void Document::add_script_to_execute_when_parsing_has_finished(Badge<HTMLScriptElement>, HTMLScriptElement& script)
{
m_scripts_to_execute_when_parsing_has_finished.append(script);
}
NonnullRefPtrVector<HTMLScriptElement> Document::take_scripts_to_execute_when_parsing_has_finished(Badge<HTMLDocumentParser>)
{
return move(m_scripts_to_execute_when_parsing_has_finished);
}
void Document::add_script_to_execute_as_soon_as_possible(Badge<HTMLScriptElement>, HTMLScriptElement& script)
{
m_scripts_to_execute_as_soon_as_possible.append(script);
}
NonnullRefPtrVector<HTMLScriptElement> Document::take_scripts_to_execute_as_soon_as_possible(Badge<HTMLDocumentParser>)
{
return move(m_scripts_to_execute_as_soon_as_possible);
}
}