mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 16:35:07 +00:00
LibWeb: Use new parse_length() in filter parsing
This commit is contained in:
parent
e0875b99cc
commit
0811a39392
1 changed files with 16 additions and 16 deletions
|
@ -3950,36 +3950,35 @@ RefPtr<StyleValue> Parser::parse_filter_value_list_value(TokenStream<ComponentVa
|
||||||
// blur( <length>? )
|
// blur( <length>? )
|
||||||
if (!tokens.has_next_token())
|
if (!tokens.has_next_token())
|
||||||
return Filter::Blur {};
|
return Filter::Blur {};
|
||||||
auto blur_radius = parse_length(tokens.next_token());
|
auto blur_radius = parse_length(tokens);
|
||||||
|
tokens.skip_whitespace();
|
||||||
if (!blur_radius.has_value())
|
if (!blur_radius.has_value())
|
||||||
return {};
|
return {};
|
||||||
return if_no_more_tokens_return(Filter::Blur { *blur_radius });
|
// FIXME: Support calculated radius
|
||||||
|
return if_no_more_tokens_return(Filter::Blur { blur_radius->value() });
|
||||||
} else if (filter_token == FilterToken::DropShadow) {
|
} else if (filter_token == FilterToken::DropShadow) {
|
||||||
if (!tokens.has_next_token())
|
if (!tokens.has_next_token())
|
||||||
return {};
|
return {};
|
||||||
auto next_token = [&]() -> auto& {
|
|
||||||
auto& token = tokens.next_token();
|
|
||||||
tokens.skip_whitespace();
|
|
||||||
return token;
|
|
||||||
};
|
|
||||||
// drop-shadow( [ <color>? && <length>{2,3} ] )
|
// drop-shadow( [ <color>? && <length>{2,3} ] )
|
||||||
// Note: The following code is a little awkward to allow the color to be before or after the lengths.
|
// Note: The following code is a little awkward to allow the color to be before or after the lengths.
|
||||||
auto& first_param = next_token();
|
Optional<LengthOrCalculated> maybe_radius = {};
|
||||||
Optional<Length> maybe_radius = {};
|
auto maybe_color = parse_color(tokens.peek_token());
|
||||||
auto maybe_color = parse_color(first_param);
|
if (maybe_color.has_value())
|
||||||
auto x_offset = parse_length(maybe_color.has_value() ? next_token() : first_param);
|
(void)tokens.next_token();
|
||||||
|
auto x_offset = parse_length(tokens);
|
||||||
|
tokens.skip_whitespace();
|
||||||
if (!x_offset.has_value() || !tokens.has_next_token()) {
|
if (!x_offset.has_value() || !tokens.has_next_token()) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
auto y_offset = parse_length(next_token());
|
auto y_offset = parse_length(tokens);
|
||||||
if (!y_offset.has_value()) {
|
if (!y_offset.has_value()) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
if (tokens.has_next_token()) {
|
if (tokens.has_next_token()) {
|
||||||
auto& token = next_token();
|
maybe_radius = parse_length(tokens);
|
||||||
maybe_radius = parse_length(token);
|
|
||||||
if (!maybe_color.has_value() && (!maybe_radius.has_value() || tokens.has_next_token())) {
|
if (!maybe_color.has_value() && (!maybe_radius.has_value() || tokens.has_next_token())) {
|
||||||
maybe_color = parse_color(!maybe_radius.has_value() ? token : next_token());
|
maybe_color = parse_color(tokens.next_token());
|
||||||
|
tokens.skip_whitespace();
|
||||||
if (!maybe_color.has_value()) {
|
if (!maybe_color.has_value()) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -3987,7 +3986,8 @@ RefPtr<StyleValue> Parser::parse_filter_value_list_value(TokenStream<ComponentVa
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return if_no_more_tokens_return(Filter::DropShadow { *x_offset, *y_offset, maybe_radius, maybe_color });
|
// FIXME: Support calculated offsets and radius
|
||||||
|
return if_no_more_tokens_return(Filter::DropShadow { x_offset->value(), y_offset->value(), maybe_radius.map([](auto& it) { return it.value(); }), maybe_color });
|
||||||
} else if (filter_token == FilterToken::HueRotate) {
|
} else if (filter_token == FilterToken::HueRotate) {
|
||||||
// hue-rotate( [ <angle> | <zero> ]? )
|
// hue-rotate( [ <angle> | <zero> ]? )
|
||||||
if (!tokens.has_next_token())
|
if (!tokens.has_next_token())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue