diff options
author | Andreas Kling <kling@serenityos.org> | 2020-05-25 19:50:44 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-25 19:51:23 +0200 |
commit | 406fd95f327bd196e3781f8b1a21cfdcee684c2b (patch) | |
tree | 109d3e7b037d1189e402ef6dd2fac27870ec5abb /Libraries | |
parent | 556a6eea6155243fd1a4bed8370194c25c16f5d3 (diff) | |
download | serenity-406fd95f327bd196e3781f8b1a21cfdcee684c2b.zip |
LibWeb: Flesh out the remaining DOCTYPE related tokenizer states
We can now parse public and system identifiers! Not super useful, but
at least we can do it :^)
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibWeb/Parser/HTMLTokenizer.cpp | 311 |
1 files changed, 311 insertions, 0 deletions
diff --git a/Libraries/LibWeb/Parser/HTMLTokenizer.cpp b/Libraries/LibWeb/Parser/HTMLTokenizer.cpp index b0b1bfaab0..ba4df5d474 100644 --- a/Libraries/LibWeb/Parser/HTMLTokenizer.cpp +++ b/Libraries/LibWeb/Parser/HTMLTokenizer.cpp @@ -337,6 +337,317 @@ Optional<HTMLToken> HTMLTokenizer::next_token() } ANYTHING_ELSE { + if (toupper(current_input_character.value()) == 'P' && consume_next_if_match("UBLIC", CaseSensitivity::CaseInsensitive)) { + SWITCH_TO(AfterDOCTYPEPublicKeyword); + } + if (toupper(current_input_character.value()) == 'S' && consume_next_if_match("YSTEM", CaseSensitivity::CaseInsensitive)) { + SWITCH_TO(AfterDOCTYPESystemKeyword); + } + TODO(); + } + } + END_STATE + + BEGIN_STATE(AfterDOCTYPEPublicKeyword) + { + ON_WHITESPACE + { + SWITCH_TO(BeforeDOCTYPEPublicIdentifier); + } + ON('"') + { + TODO(); + } + ON('\'') + { + TODO(); + } + ON('>') + { + TODO(); + } + ON_EOF + { + TODO(); + } + ANYTHING_ELSE + { + TODO(); + } + } + END_STATE + + BEGIN_STATE(AfterDOCTYPESystemKeyword) + { + ON_WHITESPACE + { + SWITCH_TO(BeforeDOCTYPESystemIdentifier); + } + ON('"') + { + TODO(); + } + ON('\'') + { + TODO(); + } + ON('>') + { + TODO(); + } + ON_EOF + { + TODO(); + } + ANYTHING_ELSE + { + TODO(); + } + } + END_STATE + + BEGIN_STATE(BeforeDOCTYPEPublicIdentifier) + { + ON_WHITESPACE + { + continue; + } + ON('"') + { + m_current_token.m_doctype.public_identifier.clear(); + SWITCH_TO(DOCTYPEPublicIdentifierDoubleQuoted); + } + ON('\'') + { + m_current_token.m_doctype.public_identifier.clear(); + SWITCH_TO(DOCTYPEPublicIdentifierSingleQuoted); + } + ON('>') + { + TODO(); + } + ON_EOF + { + TODO(); + } + ANYTHING_ELSE + { + TODO(); + } + } + END_STATE + + BEGIN_STATE(BeforeDOCTYPESystemIdentifier) + { + ON_WHITESPACE + { + continue; + } + ON('"') + { + m_current_token.m_doctype.system_identifier.clear(); + SWITCH_TO(DOCTYPESystemIdentifierDoubleQuoted); + } + ON('\'') + { + m_current_token.m_doctype.system_identifier.clear(); + SWITCH_TO(DOCTYPESystemIdentifierSingleQuoted); + } + ON('>') + { + TODO(); + } + ON_EOF + { + TODO(); + } + ANYTHING_ELSE + { + TODO(); + } + } + END_STATE + + BEGIN_STATE(DOCTYPEPublicIdentifierDoubleQuoted) + { + ON('"') + { + SWITCH_TO(AfterDOCTYPEPublicIdentifier); + } + ON(0) + { + TODO(); + } + ON('>') + { + TODO(); + } + ON_EOF + { + TODO(); + } + ANYTHING_ELSE + { + m_current_token.m_doctype.public_identifier.append(current_input_character.value()); + continue; + } + } + END_STATE + + BEGIN_STATE(DOCTYPEPublicIdentifierSingleQuoted) + { + ON('\'') + { + SWITCH_TO(AfterDOCTYPEPublicIdentifier); + } + ON(0) + { + TODO(); + } + ON('>') + { + TODO(); + } + ON_EOF + { + TODO(); + } + ANYTHING_ELSE + { + m_current_token.m_doctype.public_identifier.append(current_input_character.value()); + continue; + } + } + END_STATE + + BEGIN_STATE(DOCTYPESystemIdentifierDoubleQuoted) + { + ON('"') + { + SWITCH_TO(AfterDOCTYPESystemIdentifier); + } + ON(0) + { + TODO(); + } + ON('>') + { + TODO(); + } + ON_EOF + { + TODO(); + } + ANYTHING_ELSE + { + m_current_token.m_doctype.system_identifier.append(current_input_character.value()); + continue; + } + } + END_STATE + + BEGIN_STATE(DOCTYPESystemIdentifierSingleQuoted) + { + ON('\'') + { + SWITCH_TO(AfterDOCTYPESystemIdentifier); + } + ON(0) + { + TODO(); + } + ON('>') + { + TODO(); + } + ON_EOF + { + TODO(); + } + ANYTHING_ELSE + { + m_current_token.m_doctype.system_identifier.append(current_input_character.value()); + continue; + } + } + END_STATE + + BEGIN_STATE(AfterDOCTYPEPublicIdentifier) + { + ON_WHITESPACE + { + SWITCH_TO(BetweenDOCTYPEPublicAndSystemIdentifiers); + } + ON('>') + { + SWITCH_TO_AND_EMIT_CURRENT_TOKEN(Data); + } + ON('"') + { + TODO(); + } + ON('\'') + { + TODO(); + } + ON_EOF + { + TODO(); + } + ANYTHING_ELSE + { + TODO(); + } + } + END_STATE + + BEGIN_STATE(BetweenDOCTYPEPublicAndSystemIdentifiers) + { + ON_WHITESPACE + { + continue; + } + ON('>') + { + SWITCH_TO_AND_EMIT_CURRENT_TOKEN(Data); + } + ON('"') + { + m_current_token.m_doctype.system_identifier.clear(); + SWITCH_TO(DOCTYPESystemIdentifierDoubleQuoted); + } + ON('\'') + { + m_current_token.m_doctype.system_identifier.clear(); + SWITCH_TO(DOCTYPESystemIdentifierSingleQuoted); + } + ON_EOF + { + TODO(); + } + ANYTHING_ELSE + { + TODO(); + } + } + END_STATE + + BEGIN_STATE(AfterDOCTYPESystemIdentifier) + { + ON_WHITESPACE + { + continue; + } + ON('>') + { + SWITCH_TO_AND_EMIT_CURRENT_TOKEN(Data); + } + ON_EOF + { + TODO(); + } + ANYTHING_ELSE + { TODO(); } } |