diff options
author | Max Wipfli <mail@maxwipfli.ch> | 2021-07-15 15:53:54 +0200 |
---|---|---|
committer | Ali Mohammad Pur <Ali.mpfard@gmail.com> | 2021-07-17 16:24:57 +0430 |
commit | f2e3c770f9cbbea86b6bf3c044d035368b3dea79 (patch) | |
tree | 293d3bc4a641a68a07b8ec12808d2a019e3ae52c | |
parent | 8b31e41692014ce51f920cfc43fe7736f984f80c (diff) | |
download | serenity-f2e3c770f9cbbea86b6bf3c044d035368b3dea79.zip |
LibWeb: Use setter for HTMLToken::m_{start,end}_position
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/Parser/HTMLToken.h | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp | 22 |
2 files changed, 16 insertions, 11 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLToken.h b/Userland/Libraries/LibWeb/HTML/Parser/HTMLToken.h index 49de74d50d..c51a43fc8f 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLToken.h +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLToken.h @@ -16,6 +16,8 @@ namespace Web::HTML { +class HTMLTokenizer; + class HTMLToken { friend class HTMLDocumentParser; friend class HTMLTokenizer; @@ -282,6 +284,9 @@ public: Position const& start_position() const { return m_start_position; } Position const& end_position() const { return m_end_position; } + void set_start_position(Badge<HTMLTokenizer>, Position start_position) { m_start_position = start_position; } + void set_end_position(Badge<HTMLTokenizer>, Position end_position) { m_end_position = end_position; } + private: Type m_type { Type::Invalid }; diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp index fb730b28d5..45d392946a 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLTokenizer.cpp @@ -284,7 +284,7 @@ _StartOfFunction: { log_parse_error(); create_new_token(HTMLToken::Type::Comment); - m_current_token.m_start_position = nth_last_position(2); + m_current_token.set_start_position({}, nth_last_position(2)); RECONSUME_IN(BogusComment); } ON_EOF @@ -306,44 +306,44 @@ _StartOfFunction: ON_WHITESPACE { m_current_token.set_tag_name(consume_current_builder()); - m_current_token.m_end_position = nth_last_position(1); + m_current_token.set_end_position({}, nth_last_position(1)); SWITCH_TO(BeforeAttributeName); } ON('/') { m_current_token.set_tag_name(consume_current_builder()); - m_current_token.m_end_position = nth_last_position(0); + m_current_token.set_end_position({}, nth_last_position(0)); SWITCH_TO(SelfClosingStartTag); } ON('>') { m_current_token.set_tag_name(consume_current_builder()); - m_current_token.m_end_position = nth_last_position(1); + m_current_token.set_end_position({}, nth_last_position(1)); SWITCH_TO_AND_EMIT_CURRENT_TOKEN(Data); } ON_ASCII_UPPER_ALPHA { m_current_builder.append_code_point(to_ascii_lowercase(current_input_character.value())); - m_current_token.m_end_position = nth_last_position(0); + m_current_token.set_end_position({}, nth_last_position(0)); continue; } ON(0) { log_parse_error(); m_current_builder.append_code_point(0xFFFD); - m_current_token.m_end_position = nth_last_position(0); + m_current_token.set_end_position({}, nth_last_position(0)); continue; } ON_EOF { log_parse_error(); - m_current_token.m_end_position = nth_last_position(0); + m_current_token.set_end_position({}, nth_last_position(0)); EMIT_EOF; } ANYTHING_ELSE { m_current_builder.append_code_point(current_input_character.value()); - m_current_token.m_end_position = nth_last_position(0); + m_current_token.set_end_position({}, nth_last_position(0)); continue; } } @@ -382,7 +382,7 @@ _StartOfFunction: DONT_CONSUME_NEXT_INPUT_CHARACTER; if (consume_next_if_match("--")) { create_new_token(HTMLToken::Type::Comment); - m_current_token.m_start_position = nth_last_position(4); + m_current_token.set_start_position({}, nth_last_position(4)); SWITCH_TO(CommentStart); } if (consume_next_if_match("DOCTYPE", CaseSensitivity::CaseInsensitive)) { @@ -2679,7 +2679,7 @@ void HTMLTokenizer::create_new_token(HTMLToken::Type type) break; } - m_current_token.m_start_position = nth_last_position(offset); + m_current_token.set_start_position({}, nth_last_position(offset)); } HTMLTokenizer::HTMLTokenizer(StringView const& input, String const& encoding) @@ -2712,7 +2712,7 @@ void HTMLTokenizer::will_emit(HTMLToken& token) { if (token.is_start_tag()) m_last_emitted_start_tag_name = token.tag_name(); - token.m_end_position = nth_last_position(0); + token.set_end_position({}, nth_last_position(0)); } bool HTMLTokenizer::current_end_tag_token_is_appropriate() const |