mirror of
https://github.com/RGBCube/serenity
synced 2025-07-19 18:57:40 +00:00
LibWeb: Convert parse_source_size_value() to TokenStream
This commit is contained in:
parent
a76f29e56b
commit
306acf43c4
2 changed files with 7 additions and 13 deletions
|
@ -1832,21 +1832,14 @@ Optional<TimePercentage> Parser::parse_time_percentage(TokenStream<ComponentValu
|
||||||
return {};
|
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() };
|
return LengthOrCalculated { Length::make_auto() };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto calculated_value = parse_calculated_value(component_value)) {
|
return parse_length(tokens);
|
||||||
return LengthOrCalculated { calculated_value.release_nonnull() };
|
|
||||||
}
|
|
||||||
|
|
||||||
if (auto length = parse_length(component_value); length.has_value()) {
|
|
||||||
return LengthOrCalculated { length.release_value() };
|
|
||||||
}
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<Length> Parser::parse_length(ComponentValue const& component_value)
|
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.
|
// let size be its value and remove the component value from unparsed size.
|
||||||
// FIXME: Any CSS function other than the math functions is invalid.
|
// FIXME: Any CSS function other than the math functions is invalid.
|
||||||
// Otherwise, there is a parse error; continue.
|
// 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();
|
size = source_size_value.value();
|
||||||
unparsed_size.take_last();
|
unparsed_size.take_last();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -187,7 +187,7 @@ private:
|
||||||
Optional<Color> parse_rgb_or_hsl_color(StringView function_name, Vector<ComponentValue> const&);
|
Optional<Color> parse_rgb_or_hsl_color(StringView function_name, Vector<ComponentValue> const&);
|
||||||
Optional<Color> parse_color(ComponentValue const&);
|
Optional<Color> parse_color(ComponentValue const&);
|
||||||
Optional<Length> parse_length(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<Ratio> parse_ratio(TokenStream<ComponentValue>&);
|
||||||
Optional<Gfx::UnicodeRange> parse_unicode_range(TokenStream<ComponentValue>&);
|
Optional<Gfx::UnicodeRange> parse_unicode_range(TokenStream<ComponentValue>&);
|
||||||
Optional<Gfx::UnicodeRange> parse_unicode_range(StringView);
|
Optional<Gfx::UnicodeRange> parse_unicode_range(StringView);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue