LibWeb: Restore the previous tokenizer iterator after inserting input

Otherwise, m_prev_utf8_iterator still points at the old source.
This commit is contained in:
Timothy Flynn 2024-02-18 12:39:56 -05:00 committed by Andreas Kling
parent fcf83a8ed0
commit 64dcd3f1f4
Notes: sideshowbarker 2024-07-17 07:08:37 +09:00

View file

@ -2802,6 +2802,7 @@ HTMLTokenizer::HTMLTokenizer(StringView input, ByteString const& encoding)
void HTMLTokenizer::insert_input_at_insertion_point(StringView input)
{
auto utf8_iterator_byte_offset = m_utf8_view.byte_offset_of(m_utf8_iterator);
auto prev_utf8_iterator_byte_offset = m_utf8_view.byte_offset_of(m_prev_utf8_iterator);
// FIXME: Implement a InputStream to handle insertion_point and iterators.
StringBuilder builder {};
@ -2812,6 +2813,7 @@ void HTMLTokenizer::insert_input_at_insertion_point(StringView input)
m_utf8_view = Utf8View(m_decoded_input);
m_utf8_iterator = m_utf8_view.iterator_at_byte_offset(utf8_iterator_byte_offset);
m_prev_utf8_iterator = m_utf8_view.iterator_at_byte_offset(prev_utf8_iterator_byte_offset);
m_insertion_point.position += input.length();
}