mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:27:45 +00:00
LibWeb: Spec-comment consume_a_component_value()
This commit is contained in:
parent
be86d19529
commit
999cc51512
1 changed files with 10 additions and 0 deletions
|
@ -1697,20 +1697,30 @@ RefPtr<StyleRule> Parser::consume_a_qualified_rule(TokenStream<T>& tokens)
|
||||||
template<>
|
template<>
|
||||||
StyleComponentValueRule Parser::consume_a_component_value(TokenStream<StyleComponentValueRule>& tokens)
|
StyleComponentValueRule Parser::consume_a_component_value(TokenStream<StyleComponentValueRule>& tokens)
|
||||||
{
|
{
|
||||||
|
// Note: This overload is called once tokens have already been converted into component values,
|
||||||
|
// so we do not need to do the work in the more general overload.
|
||||||
return tokens.next_token();
|
return tokens.next_token();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 5.4.7. Consume a component value
|
||||||
|
// https://www.w3.org/TR/css-syntax-3/#consume-component-value
|
||||||
template<typename T>
|
template<typename T>
|
||||||
StyleComponentValueRule Parser::consume_a_component_value(TokenStream<T>& tokens)
|
StyleComponentValueRule Parser::consume_a_component_value(TokenStream<T>& tokens)
|
||||||
{
|
{
|
||||||
|
// To consume a component value:
|
||||||
|
|
||||||
|
// Consume the next input token.
|
||||||
auto& token = tokens.next_token();
|
auto& token = tokens.next_token();
|
||||||
|
|
||||||
|
// If the current input token is a <{-token>, <[-token>, or <(-token>, consume a simple block and return it.
|
||||||
if (token.is(Token::Type::OpenCurly) || token.is(Token::Type::OpenSquare) || token.is(Token::Type::OpenParen))
|
if (token.is(Token::Type::OpenCurly) || token.is(Token::Type::OpenSquare) || token.is(Token::Type::OpenParen))
|
||||||
return StyleComponentValueRule(consume_a_simple_block(tokens));
|
return StyleComponentValueRule(consume_a_simple_block(tokens));
|
||||||
|
|
||||||
|
// Otherwise, if the current input token is a <function-token>, consume a function and return it.
|
||||||
if (token.is(Token::Type::Function))
|
if (token.is(Token::Type::Function))
|
||||||
return StyleComponentValueRule(consume_a_function(tokens));
|
return StyleComponentValueRule(consume_a_function(tokens));
|
||||||
|
|
||||||
|
// Otherwise, return the current input token.
|
||||||
return StyleComponentValueRule(token);
|
return StyleComponentValueRule(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue