mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-31 15:32:51 +00:00
LibWeb/CSS: Un-template parse_comma_separated_value_list()
This doesn't need to be a template. Changing it means we can use it from any FooParsing.cpp file, and also move it ValueParsing.cpp where it belongs.
This commit is contained in:
parent
fd4f4f425d
commit
79093291b5
Notes:
github-actions[bot]
2025-04-04 09:42:24 +00:00
Author: https://github.com/AtkinsSJ
Commit: 79093291b5
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4206
3 changed files with 25 additions and 25 deletions
|
@ -54,6 +54,7 @@
|
|||
#include <LibWeb/CSS/StyleValues/RectStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/ResolutionStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StringStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/StyleValueList.h>
|
||||
#include <LibWeb/CSS/StyleValues/TimeStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/URLStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/UnicodeRangeStyleValue.h>
|
||||
|
@ -64,6 +65,29 @@
|
|||
|
||||
namespace Web::CSS::Parser {
|
||||
|
||||
RefPtr<CSSStyleValue> Parser::parse_comma_separated_value_list(TokenStream<ComponentValue>& tokens, ParseFunction parse_one_value)
|
||||
{
|
||||
auto first = parse_one_value(tokens);
|
||||
if (!first || !tokens.has_next_token())
|
||||
return first;
|
||||
|
||||
StyleValueVector values;
|
||||
values.append(first.release_nonnull());
|
||||
|
||||
while (tokens.has_next_token()) {
|
||||
if (!tokens.consume_a_token().is(Token::Type::Comma))
|
||||
return nullptr;
|
||||
|
||||
if (auto maybe_value = parse_one_value(tokens)) {
|
||||
values.append(maybe_value.release_nonnull());
|
||||
continue;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return StyleValueList::create(move(values), StyleValueList::Separator::Comma);
|
||||
}
|
||||
|
||||
Optional<Dimension> Parser::parse_dimension(ComponentValue const& component_value)
|
||||
{
|
||||
if (component_value.is(Token::Type::Dimension)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue