mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:57:43 +00:00
LibWeb: Add CSS::Tokenizer::start_of_input_stream_[twin|triplet]()
These correspond to "If the input stream starts with..." in the spec, which up until now we were not handling correctly, which led to some fun bugs. As noted, reconsuming the input code point in order to read its value is hacky, but works. Keeping track of the current code point in Tokenizer would be nicer, when I'm feeling brave enough to mess with it!
This commit is contained in:
parent
8600d89407
commit
981badb45f
2 changed files with 27 additions and 0 deletions
|
@ -309,6 +309,30 @@ U32Triplet Tokenizer::peek_triplet() const
|
|||
return values;
|
||||
}
|
||||
|
||||
U32Twin Tokenizer::start_of_input_stream_twin()
|
||||
{
|
||||
U32Twin twin;
|
||||
// FIXME: Reconsuming just to read the current code point again is weird.
|
||||
reconsume_current_input_code_point();
|
||||
twin.first = next_code_point();
|
||||
twin.second = peek_code_point();
|
||||
|
||||
return twin;
|
||||
}
|
||||
|
||||
U32Triplet Tokenizer::start_of_input_stream_triplet()
|
||||
{
|
||||
U32Triplet triplet;
|
||||
// FIXME: Reconsuming just to read the current code point again is weird.
|
||||
reconsume_current_input_code_point();
|
||||
triplet.first = next_code_point();
|
||||
auto next_two = peek_twin();
|
||||
triplet.second = next_two.first;
|
||||
triplet.third = next_two.second;
|
||||
|
||||
return triplet;
|
||||
}
|
||||
|
||||
Token Tokenizer::create_new_token(Token::Type type)
|
||||
{
|
||||
Token token = {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue