summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/CSS/Parser
diff options
context:
space:
mode:
authorSam Atkins <atkinssj@serenityos.org>2022-03-30 14:14:31 +0100
committerAndreas Kling <kling@serenityos.org>2022-03-30 18:43:07 +0200
commit999cc51512da3f0d1c0faf557248da138f2eb4e1 (patch)
treee0b1c59154cd7398e2243e62686cab821a52c8dc /Userland/Libraries/LibWeb/CSS/Parser
parentbe86d19529d9a8f619e15ceba1807e24ed79272a (diff)
downloadserenity-999cc51512da3f0d1c0faf557248da138f2eb4e1.zip
LibWeb: Spec-comment `consume_a_component_value()`
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS/Parser')
-rw-r--r--Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
index 9067744016..9c345e32a5 100644
--- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
+++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp
@@ -1697,20 +1697,30 @@ RefPtr<StyleRule> Parser::consume_a_qualified_rule(TokenStream<T>& tokens)
template<>
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();
}
+// 5.4.7. Consume a component value
+// https://www.w3.org/TR/css-syntax-3/#consume-component-value
template<typename T>
StyleComponentValueRule Parser::consume_a_component_value(TokenStream<T>& tokens)
{
+ // To consume a component value:
+
+ // Consume the next input 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))
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))
return StyleComponentValueRule(consume_a_function(tokens));
+ // Otherwise, return the current input token.
return StyleComponentValueRule(token);
}