mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:27:45 +00:00
LibWeb: Bring parse_a_list_of_rules()
to spec
This is not actually used by anything currently, but it should be used for `@media` and other at-rules. Removed the public parse_as_list_of_rules() because public functions should be things that outside classes actually need to use.
This commit is contained in:
parent
85d8c652e9
commit
7a225a380c
2 changed files with 13 additions and 17 deletions
|
@ -1903,24 +1903,21 @@ RefPtr<CSSRule> Parser::parse_a_rule(TokenStream<T>& tokens)
|
|||
return {};
|
||||
}
|
||||
|
||||
NonnullRefPtrVector<CSSRule> Parser::parse_as_list_of_rules()
|
||||
{
|
||||
return parse_a_list_of_rules(m_token_stream);
|
||||
}
|
||||
|
||||
// 5.3.4. Parse a list of rules
|
||||
// https://www.w3.org/TR/css-syntax-3/#parse-list-of-rules
|
||||
template<typename T>
|
||||
NonnullRefPtrVector<CSSRule> Parser::parse_a_list_of_rules(TokenStream<T>& tokens)
|
||||
NonnullRefPtrVector<StyleRule> Parser::parse_a_list_of_rules(TokenStream<T>& tokens)
|
||||
{
|
||||
auto parsed_rules = consume_a_list_of_rules(tokens, TopLevel::No);
|
||||
NonnullRefPtrVector<CSSRule> rules;
|
||||
// To parse a list of rules from input:
|
||||
|
||||
for (auto& rule : parsed_rules) {
|
||||
auto converted_rule = convert_to_rule(rule);
|
||||
if (converted_rule)
|
||||
rules.append(*converted_rule);
|
||||
}
|
||||
// 1. Normalize input, and set input to the result.
|
||||
// Note: This is done when initializing the Parser.
|
||||
|
||||
return rules;
|
||||
// 2. Consume a list of rules from the input, with the top-level flag unset.
|
||||
auto list_of_rules = consume_a_list_of_rules(tokens, TopLevel::No);
|
||||
|
||||
// 3. Return the returned list.
|
||||
return list_of_rules;
|
||||
}
|
||||
|
||||
Optional<StyleProperty> Parser::parse_as_declaration()
|
||||
|
|
|
@ -89,8 +89,6 @@ public:
|
|||
Parser(ParsingContext const&, StringView input, String const& encoding = "utf-8");
|
||||
~Parser() = default;
|
||||
|
||||
// For the content of at-rules such as @media. It differs from "Parse a stylesheet" in the handling of <CDO-token> and <CDC-token>.
|
||||
NonnullRefPtrVector<CSSRule> parse_as_list_of_rules();
|
||||
// For use by the CSSStyleSheet#insertRule method, and similar functions which might exist, which parse text into a single rule.
|
||||
RefPtr<CSSRule> parse_as_rule();
|
||||
// Used in @supports conditions. [CSS3-CONDITIONAL]
|
||||
|
@ -141,8 +139,9 @@ private:
|
|||
template<typename T>
|
||||
ParsedStyleSheet parse_a_stylesheet(TokenStream<T>&, Optional<AK::URL> location);
|
||||
|
||||
// For the content of at-rules such as @media. It differs from "Parse a stylesheet" in the handling of <CDO-token> and <CDC-token>.
|
||||
template<typename T>
|
||||
NonnullRefPtrVector<CSSRule> parse_a_list_of_rules(TokenStream<T>&);
|
||||
NonnullRefPtrVector<StyleRule> parse_a_list_of_rules(TokenStream<T>&);
|
||||
template<typename T>
|
||||
RefPtr<CSSRule> parse_a_rule(TokenStream<T>&);
|
||||
template<typename T>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue