LibWeb: Teach more of HTMLTokenizer to stop at the insertion point

In particular, input character lookahead now knows how to stop at the
insertion point marker if needed.

This makes it possible to do amazing things like having document.write()
insert doctypes one character at a time.
This commit is contained in:
Andreas Kling 2024-11-24 10:18:17 +01:00 committed by Andreas Kling
parent 82b540e501
commit 5c70436cb2
Notes: github-actions[bot] 2024-11-24 10:46:43 +00:00
6 changed files with 87 additions and 32 deletions

View file

@ -153,9 +153,16 @@ public:
private:
void skip(size_t count);
Optional<u32> next_code_point();
Optional<u32> peek_code_point(size_t offset) const;
bool consume_next_if_match(StringView, CaseSensitivity = CaseSensitivity::CaseSensitive);
Optional<u32> next_code_point(StopAtInsertionPoint);
Optional<u32> peek_code_point(size_t offset, StopAtInsertionPoint) const;
enum class ConsumeNextResult {
Consumed,
NotConsumed,
RanOutOfCharacters,
};
[[nodiscard]] ConsumeNextResult consume_next_if_match(StringView, StopAtInsertionPoint, CaseSensitivity = CaseSensitivity::CaseSensitive);
void create_new_token(HTMLToken::Type);
bool current_end_tag_token_is_appropriate() const;
String consume_current_builder();