diff options
author | Max Wipfli <mail@maxwipfli.ch> | 2021-07-15 15:55:46 +0200 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-07-17 16:24:57 +0430 |
commit | 25cba4387bf677233374095d30d3304b35620e74 (patch) | |
tree | 24dd3f0acd8ab0717760ca12f672cb4baf64c6e9 /Userland | |
parent | f2e3c770f9cbbea86b6bf3c044d035368b3dea79 (diff) | |
download | serenity-25cba4387bf677233374095d30d3304b35620e74.zip |
LibWeb: Add HTMLToken(Type) constructor and use it
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/Parser/HTMLToken.h | 13 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp | 3 |
2 files changed, 10 insertions, 6 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLToken.h b/Userland/Libraries/LibWeb/HTML/Parser/HTMLToken.h index c51a43fc8f..a986e1442b 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLToken.h +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLToken.h @@ -62,20 +62,25 @@ public: static HTMLToken make_character(u32 code_point) { - HTMLToken token; - token.m_type = Type::Character; + HTMLToken token { Type::Character }; token.set_code_point(code_point); return token; } static HTMLToken make_start_tag(FlyString const& tag_name) { - HTMLToken token; - token.m_type = Type::StartTag; + HTMLToken token { Type::StartTag }; token.set_tag_name(tag_name); return token; } + HTMLToken() = default; + + HTMLToken(Type type) + : m_type(type) + { + } + bool is_doctype() const { return m_type == Type::DOCTYPE; } bool is_start_tag() const { return m_type == Type::StartTag; } bool is_end_tag() const { return m_type == Type::EndTag; } diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp index 45d392946a..a0a514856b 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp @@ -2665,8 +2665,7 @@ bool HTMLTokenizer::consume_next_if_match(StringView const& string, CaseSensitiv void HTMLTokenizer::create_new_token(HTMLToken::Type type) { - m_current_token = {}; - m_current_token.m_type = type; + m_current_token = { type }; size_t offset = 0; switch (type) { case HTMLToken::Type::StartTag: |