1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:07:34 +00:00

LibWeb: Add TokenStream::rewind_to_position()

Parsing media queries sometimes requires significant back-tracking, so
`reconsume_current_input_token()` was not good enough.
`rewind_to_position()` lets you reconsume an erbitrary number of tokens
to return to an earlier point in the stream, which you previously saved
from `TokenStream::position()`.
This commit is contained in:
Sam Atkins 2021-09-30 17:17:21 +01:00 committed by Andreas Kling
parent c7cd489689
commit 2ed0f880ee
2 changed files with 10 additions and 0 deletions

View file

@ -106,6 +106,13 @@ void TokenStream<T>::reconsume_current_input_token()
--m_iterator_offset;
}
template<typename T>
void TokenStream<T>::rewind_to_position(int position)
{
VERIFY(position <= m_iterator_offset);
m_iterator_offset = position;
}
template<typename T>
void TokenStream<T>::skip_whitespace()
{