mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:57:36 +00:00
LibWeb: Add CSS Tokenizer::consume_as_much_whitespace_as_possible()
This is a step in the spec in 3 places, and we had it implemented differently in each one. This unifies them and makes it clearer what we're doing.
This commit is contained in:
parent
dfbdc20f87
commit
9a2eecaca4
2 changed files with 12 additions and 21 deletions
|
@ -490,13 +490,7 @@ String Tokenizer::consume_a_name()
|
||||||
Token Tokenizer::consume_a_url_token()
|
Token Tokenizer::consume_a_url_token()
|
||||||
{
|
{
|
||||||
auto token = create_new_token(Token::Type::Url);
|
auto token = create_new_token(Token::Type::Url);
|
||||||
for (;;) {
|
consume_as_much_whitespace_as_possible();
|
||||||
if (!is_whitespace(peek_code_point())) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
(void)next_code_point();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
||||||
|
@ -512,13 +506,8 @@ Token Tokenizer::consume_a_url_token()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_whitespace(input)) {
|
if (is_whitespace(input)) {
|
||||||
for (;;) {
|
consume_as_much_whitespace_as_possible();
|
||||||
if (!is_whitespace(peek_code_point())) {
|
input = peek_code_point();
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
input = next_code_point();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_eof(input)) {
|
if (is_eof(input)) {
|
||||||
log_parse_error();
|
log_parse_error();
|
||||||
|
@ -580,6 +569,13 @@ void Tokenizer::consume_the_remnants_of_a_bad_url()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Tokenizer::consume_as_much_whitespace_as_possible()
|
||||||
|
{
|
||||||
|
while (is_whitespace(peek_code_point())) {
|
||||||
|
(void)next_code_point();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Tokenizer::reconsume_current_input_code_point()
|
void Tokenizer::reconsume_current_input_code_point()
|
||||||
{
|
{
|
||||||
m_utf8_iterator = m_prev_utf8_iterator;
|
m_utf8_iterator = m_prev_utf8_iterator;
|
||||||
|
@ -763,13 +759,7 @@ Token Tokenizer::consume_a_token()
|
||||||
|
|
||||||
if (is_whitespace(input)) {
|
if (is_whitespace(input)) {
|
||||||
dbgln_if(CSS_TOKENIZER_DEBUG, "is whitespace");
|
dbgln_if(CSS_TOKENIZER_DEBUG, "is whitespace");
|
||||||
|
consume_as_much_whitespace_as_possible();
|
||||||
auto next = peek_code_point();
|
|
||||||
while (is_whitespace(next)) {
|
|
||||||
(void)next_code_point();
|
|
||||||
next = peek_code_point();
|
|
||||||
}
|
|
||||||
|
|
||||||
return create_new_token(Token::Type::Whitespace);
|
return create_new_token(Token::Type::Whitespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,7 @@ private:
|
||||||
[[nodiscard]] Token consume_a_url_token();
|
[[nodiscard]] Token consume_a_url_token();
|
||||||
void consume_the_remnants_of_a_bad_url();
|
void consume_the_remnants_of_a_bad_url();
|
||||||
void consume_comments();
|
void consume_comments();
|
||||||
|
void consume_as_much_whitespace_as_possible();
|
||||||
void reconsume_current_input_code_point();
|
void reconsume_current_input_code_point();
|
||||||
[[nodiscard]] static bool is_valid_escape_sequence(U32Twin);
|
[[nodiscard]] static bool is_valid_escape_sequence(U32Twin);
|
||||||
[[nodiscard]] bool would_start_an_identifier();
|
[[nodiscard]] bool would_start_an_identifier();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue