mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibWeb: Convert parse_source_size_value() to TokenStream
This commit is contained in:
parent
a76f29e56b
commit
306acf43c4
Notes:
sideshowbarker
2024-07-17 18:08:55 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/306acf43c4 Pull-request: https://github.com/SerenityOS/serenity/pull/22476 Reviewed-by: https://github.com/Lubrsi
2 changed files with 7 additions and 13 deletions
|
@ -1832,21 +1832,14 @@ Optional<TimePercentage> Parser::parse_time_percentage(TokenStream<ComponentValu
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<LengthOrCalculated> Parser::parse_source_size_value(ComponentValue const& component_value)
|
||||
Optional<LengthOrCalculated> Parser::parse_source_size_value(TokenStream<ComponentValue>& tokens)
|
||||
{
|
||||
if (component_value.is_ident("auto"sv)) {
|
||||
if (tokens.peek_token().is_ident("auto"sv)) {
|
||||
(void)tokens.next_token(); // auto
|
||||
return LengthOrCalculated { Length::make_auto() };
|
||||
}
|
||||
|
||||
if (auto calculated_value = parse_calculated_value(component_value)) {
|
||||
return LengthOrCalculated { calculated_value.release_nonnull() };
|
||||
}
|
||||
|
||||
if (auto length = parse_length(component_value); length.has_value()) {
|
||||
return LengthOrCalculated { length.release_value() };
|
||||
}
|
||||
|
||||
return {};
|
||||
return parse_length(tokens);
|
||||
}
|
||||
|
||||
Optional<Length> Parser::parse_length(ComponentValue const& component_value)
|
||||
|
@ -6625,7 +6618,8 @@ LengthOrCalculated Parser::Parser::parse_as_sizes_attribute()
|
|||
// let size be its value and remove the component value from unparsed size.
|
||||
// FIXME: Any CSS function other than the math functions is invalid.
|
||||
// Otherwise, there is a parse error; continue.
|
||||
if (auto source_size_value = parse_source_size_value(unparsed_size.last()); source_size_value.has_value()) {
|
||||
auto last_value_stream = TokenStream<ComponentValue>::of_single_token(unparsed_size.last());
|
||||
if (auto source_size_value = parse_source_size_value(last_value_stream); source_size_value.has_value()) {
|
||||
size = source_size_value.value();
|
||||
unparsed_size.take_last();
|
||||
} else {
|
||||
|
|
|
@ -187,7 +187,7 @@ private:
|
|||
Optional<Color> parse_rgb_or_hsl_color(StringView function_name, Vector<ComponentValue> const&);
|
||||
Optional<Color> parse_color(ComponentValue const&);
|
||||
Optional<Length> parse_length(ComponentValue const&);
|
||||
[[nodiscard]] Optional<LengthOrCalculated> parse_source_size_value(ComponentValue const&);
|
||||
Optional<LengthOrCalculated> parse_source_size_value(TokenStream<ComponentValue>&);
|
||||
Optional<Ratio> parse_ratio(TokenStream<ComponentValue>&);
|
||||
Optional<Gfx::UnicodeRange> parse_unicode_range(TokenStream<ComponentValue>&);
|
||||
Optional<Gfx::UnicodeRange> parse_unicode_range(StringView);
|
||||
|
|
Loading…
Reference in a new issue