mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 14:28:11 +00:00
LibWeb: Spec-comment parse_a_list_of_component_values()
This commit is contained in:
parent
34b3c09462
commit
6ec92f5527
2 changed files with 15 additions and 11 deletions
|
@ -2008,25 +2008,28 @@ Optional<StyleComponentValueRule> Parser::parse_a_component_value(TokenStream<T>
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<StyleComponentValueRule> Parser::parse_as_list_of_component_values()
|
// 5.3.10. Parse a list of component values
|
||||||
{
|
// https://www.w3.org/TR/css-syntax-3/#parse-list-of-component-values
|
||||||
return parse_a_list_of_component_values(m_token_stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Vector<StyleComponentValueRule> Parser::parse_a_list_of_component_values(TokenStream<T>& tokens)
|
Vector<StyleComponentValueRule> Parser::parse_a_list_of_component_values(TokenStream<T>& tokens)
|
||||||
{
|
{
|
||||||
Vector<StyleComponentValueRule> rules;
|
// To parse a list of component values from input:
|
||||||
|
|
||||||
|
// 1. Normalize input, and set input to the result.
|
||||||
|
// Note: This is done when initializing the Parser.
|
||||||
|
|
||||||
|
// 2. Repeatedly consume a component value from input until an <EOF-token> is returned, appending the returned values (except the final <EOF-token>) into a list. Return the list.
|
||||||
|
Vector<StyleComponentValueRule> component_values;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (tokens.peek_token().is(Token::Type::EndOfFile)) {
|
if (tokens.peek_token().is(Token::Type::EndOfFile)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
rules.append(consume_a_component_value(tokens));
|
component_values.append(consume_a_component_value(tokens));
|
||||||
}
|
}
|
||||||
|
|
||||||
return rules;
|
return component_values;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector<Vector<StyleComponentValueRule>> Parser::parse_as_comma_separated_list_of_component_values()
|
Vector<Vector<StyleComponentValueRule>> Parser::parse_as_comma_separated_list_of_component_values()
|
||||||
|
@ -4322,7 +4325,7 @@ RefPtr<StyleValue> Parser::parse_transform_origin_value(Vector<StyleComponentVal
|
||||||
|
|
||||||
RefPtr<StyleValue> Parser::parse_as_css_value(PropertyID property_id)
|
RefPtr<StyleValue> Parser::parse_as_css_value(PropertyID property_id)
|
||||||
{
|
{
|
||||||
auto component_values = parse_as_list_of_component_values();
|
auto component_values = parse_a_list_of_component_values(m_token_stream);
|
||||||
auto tokens = TokenStream(component_values);
|
auto tokens = TokenStream(component_values);
|
||||||
auto parsed_value = parse_css_value(property_id, tokens);
|
auto parsed_value = parse_css_value(property_id, tokens);
|
||||||
if (parsed_value.is_error())
|
if (parsed_value.is_error())
|
||||||
|
|
|
@ -89,8 +89,6 @@ public:
|
||||||
Parser(ParsingContext const&, StringView input, String const& encoding = "utf-8");
|
Parser(ParsingContext const&, StringView input, String const& encoding = "utf-8");
|
||||||
~Parser() = default;
|
~Parser() = default;
|
||||||
|
|
||||||
// For the contents of presentational attributes, which parse text into a single declaration’s value, or for parsing a stand-alone selector [SELECT] or list of Media Queries [MEDIAQ], as in Selectors API or the media HTML attribute.
|
|
||||||
Vector<StyleComponentValueRule> parse_as_list_of_component_values();
|
|
||||||
Vector<Vector<StyleComponentValueRule>> parse_as_comma_separated_list_of_component_values();
|
Vector<Vector<StyleComponentValueRule>> parse_as_comma_separated_list_of_component_values();
|
||||||
|
|
||||||
NonnullRefPtr<CSSStyleSheet> parse_as_css_stylesheet(Optional<AK::URL> location);
|
NonnullRefPtr<CSSStyleSheet> parse_as_css_stylesheet(Optional<AK::URL> location);
|
||||||
|
@ -152,8 +150,11 @@ private:
|
||||||
// "Parse a component value" is for things that need to consume a single value, like the parsing rules for attr().
|
// "Parse a component value" is for things that need to consume a single value, like the parsing rules for attr().
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Optional<StyleComponentValueRule> parse_a_component_value(TokenStream<T>&);
|
Optional<StyleComponentValueRule> parse_a_component_value(TokenStream<T>&);
|
||||||
|
|
||||||
|
// "Parse a list of component values" is for the contents of presentational attributes, which parse text into a single declaration’s value, or for parsing a stand-alone selector [SELECT] or list of Media Queries [MEDIAQ], as in Selectors API or the media HTML attribute.
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Vector<StyleComponentValueRule> parse_a_list_of_component_values(TokenStream<T>&);
|
Vector<StyleComponentValueRule> parse_a_list_of_component_values(TokenStream<T>&);
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Vector<Vector<StyleComponentValueRule>> parse_a_comma_separated_list_of_component_values(TokenStream<T>&);
|
Vector<Vector<StyleComponentValueRule>> parse_a_comma_separated_list_of_component_values(TokenStream<T>&);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue