LibWeb: Parse enough to handle a <style> inside a <head> :^)

This commit is contained in:
Andreas Kling 2020-05-24 20:36:43 +02:00
parent af8a9331b2
commit 5d332c1f11
Notes: sideshowbarker 2024-07-19 06:10:18 +09:00
3 changed files with 103 additions and 0 deletions

View file

@ -207,6 +207,11 @@ void HTMLDocumentParser::handle_in_head(HTMLToken& token)
return;
}
if (token.is_start_tag() && ((token.tag_name() == "noscript" && m_scripting_enabled) || token.tag_name() == "noframes" || token.tag_name() == "style")) {
parse_generic_raw_text_element(token);
return;
}
if (token.is_start_tag() && token.tag_name() == "meta") {
auto element = insert_html_element(token);
m_stack_of_open_elements.pop();
@ -228,6 +233,14 @@ void HTMLDocumentParser::handle_in_head_noscript(HTMLToken&)
ASSERT_NOT_REACHED();
}
void HTMLDocumentParser::parse_generic_raw_text_element(HTMLToken& token)
{
insert_html_element(token);
m_tokenizer.switch_to({}, HTMLTokenizer::State::RAWTEXT);
m_original_insertion_mode = m_insertion_mode;
m_insertion_mode = InsertionMode::Text;
}
void HTMLDocumentParser::insert_character(u32 data)
{
auto adjusted_insertion_location = find_appropriate_place_for_inserting_node();