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

LibWeb: Bring up basic external script execution in the new parser

This only works in some narrow cases, but should be enough for our own
welcome.html at least. :^)
This commit is contained in:
Andreas Kling 2020-05-27 23:01:04 +02:00
parent 2cb50f6750
commit 4c9c6b3a7b
7 changed files with 60 additions and 3 deletions

View file

@ -704,8 +704,48 @@ void HTMLDocumentParser::handle_text(HTMLToken& token)
if (script_nesting_level() == 0)
m_parser_pause_flag = false;
// FIXME: Handle tokenizer insertion point stuff here too.
while (document().pending_parsing_blocking_script()) {
if (script_nesting_level() != 0) {
m_parser_pause_flag = true;
// FIXME: Abort the processing of any nested invocations of the tokenizer,
// yielding control back to the caller. (Tokenization will resume when
// the caller returns to the "outer" tree construction stage.)
TODO();
} else {
auto the_script = document().take_pending_parsing_blocking_script({});
m_tokenizer.set_blocked(true);
// FIXME: If the parser's Document has a style sheet that is blocking scripts
// or the script's "ready to be parser-executed" flag is not set:
// spin the event loop until the parser's Document has no style sheet
// that is blocking scripts and the script's "ready to be parser-executed"
// flag is set.
ASSERT(the_script->is_ready_to_be_parser_executed());
if (m_aborted)
return;
m_tokenizer.set_blocked(false);
// FIXME: Handle tokenizer insertion point stuff here too.
ASSERT(script_nesting_level() == 0);
increment_script_nesting_level();
the_script->execute_script();
decrement_script_nesting_level();
ASSERT(script_nesting_level() == 0);
m_parser_pause_flag = false;
// FIXME: Handle tokenizer insertion point stuff here too.
}
}
return;
}
if (token.is_end_tag()) {
m_stack_of_open_elements.pop();
m_insertion_mode = m_original_insertion_mode;

View file

@ -121,7 +121,7 @@ private:
bool m_parsing_fragment { false };
bool m_scripting_enabled { true };
bool m_invoked_via_document_write { false };
bool m_aborted { false };
bool m_parser_pause_flag { false };
size_t m_script_nesting_level { 0 };

View file

@ -130,6 +130,9 @@ public:
void switch_to(Badge<HTMLDocumentParser>, State new_state);
void set_blocked(bool b) { m_blocked = b; }
bool is_blocked() const { return m_blocked; }
private:
Optional<u32> next_codepoint();
Optional<u32> peek_codepoint(size_t offset) const;
@ -172,5 +175,8 @@ private:
Queue<HTMLToken> m_queued_tokens;
u32 m_character_reference_code { 0 };
bool m_blocked { false };
};
}