diff options
author | Andreas Kling <kling@serenityos.org> | 2020-05-30 18:40:23 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-30 18:40:23 +0200 |
commit | 756829555ab55ea9bb01712b80bcd68b6f4a9613 (patch) | |
tree | 9b7937a6f2305521a782bf0ba9a1b0929b716541 /Libraries | |
parent | f4778d1ba098c19d3aa845b2f7ff7f2954d5a5a5 (diff) | |
download | serenity-756829555ab55ea9bb01712b80bcd68b6f4a9613.zip |
LibWeb: Parse "textarea" tags during the "in body" insertion mode
Had to handle some more cases in the tokenizer to support this.
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibWeb/Parser/HTMLDocumentParser.cpp | 19 | ||||
-rw-r--r-- | Libraries/LibWeb/Parser/HTMLTokenizer.cpp | 37 |
2 files changed, 45 insertions, 11 deletions
diff --git a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp index 24b7fdc280..cb320cfb50 100644 --- a/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp +++ b/Libraries/LibWeb/Parser/HTMLDocumentParser.cpp @@ -1154,7 +1154,24 @@ void HTMLDocumentParser::handle_in_body(HTMLToken& token) } if (token.is_start_tag() && token.tag_name() == "textarea") { - TODO(); + insert_html_element(token); + + // If the next token is a U+000A LINE FEED (LF) character token, + // then ignore that token and move on to the next one. + // (Newlines at the start of pre blocks are ignored as an authoring convenience.) + auto next_token = m_tokenizer.next_token(); + + m_tokenizer.switch_to({}, HTMLTokenizer::State::RCDATA); + m_original_insertion_mode = m_insertion_mode; + m_frameset_ok = false; + m_insertion_mode = InsertionMode::Text; + + if (next_token.has_value() && next_token.value().is_character() && next_token.value().codepoint() == '\n') { + // Ignore it. + } else { + process_using_the_rules_for(m_insertion_mode, next_token.value()); + } + return; } if (token.is_start_tag() && token.tag_name() == "xmp") { diff --git a/Libraries/LibWeb/Parser/HTMLTokenizer.cpp b/Libraries/LibWeb/Parser/HTMLTokenizer.cpp index 82555d04bd..7c20d5d535 100644 --- a/Libraries/LibWeb/Parser/HTMLTokenizer.cpp +++ b/Libraries/LibWeb/Parser/HTMLTokenizer.cpp @@ -1029,11 +1029,13 @@ _StartOfFunction: } ON_EOF { - TODO(); + PARSE_ERROR(); + EMIT_EOF; } ANYTHING_ELSE { - TODO(); + PARSE_ERROR(); + RECONSUME_IN(BeforeAttributeName); } } END_STATE @@ -1521,7 +1523,9 @@ _StartOfFunction: ANYTHING_ELSE { // FIXME: Emit a U+003C LESS-THAN SIGN character token and a U+002F SOLIDUS character token. Reconsume in the RCDATA state. - TODO(); + m_queued_tokens.enqueue(HTMLToken::make_character('<')); + m_queued_tokens.enqueue(HTMLToken::make_character('/')); + RECONSUME_IN(RCDATA); } } END_STATE @@ -1531,24 +1535,33 @@ _StartOfFunction: ON_WHITESPACE { if (!current_end_tag_token_is_appropriate()) { - // FIXME: Otherwise, treat it as per the "anything else" entry below. - TODO(); + m_queued_tokens.enqueue(HTMLToken::make_character('<')); + m_queued_tokens.enqueue(HTMLToken::make_character('/')); + for (auto codepoint : m_temporary_buffer) + m_queued_tokens.enqueue(HTMLToken::make_character(codepoint)); + RECONSUME_IN(RCDATA); } SWITCH_TO(BeforeAttributeName); } ON('/') { if (!current_end_tag_token_is_appropriate()) { - // FIXME: Otherwise, treat it as per the "anything else" entry below. - TODO(); + m_queued_tokens.enqueue(HTMLToken::make_character('<')); + m_queued_tokens.enqueue(HTMLToken::make_character('/')); + for (auto codepoint : m_temporary_buffer) + m_queued_tokens.enqueue(HTMLToken::make_character(codepoint)); + RECONSUME_IN(RCDATA); } SWITCH_TO(SelfClosingStartTag); } ON('>') { if (!current_end_tag_token_is_appropriate()) { - // FIXME: Otherwise, treat it as per the "anything else" entry below. - TODO(); + m_queued_tokens.enqueue(HTMLToken::make_character('<')); + m_queued_tokens.enqueue(HTMLToken::make_character('/')); + for (auto codepoint : m_temporary_buffer) + m_queued_tokens.enqueue(HTMLToken::make_character(codepoint)); + RECONSUME_IN(RCDATA); } SWITCH_TO_AND_EMIT_CURRENT_TOKEN(Data); } @@ -1566,7 +1579,11 @@ _StartOfFunction: } ANYTHING_ELSE { - TODO(); + m_queued_tokens.enqueue(HTMLToken::make_character('<')); + m_queued_tokens.enqueue(HTMLToken::make_character('/')); + for (auto codepoint : m_temporary_buffer) + m_queued_tokens.enqueue(HTMLToken::make_character(codepoint)); + RECONSUME_IN(RCDATA); } } END_STATE |