Skip to content

Commit 0811a39

Browse files
AtkinsSJawesomekling
authored andcommitted
LibWeb: Use new parse_length() in filter parsing
1 parent e0875b9 commit 0811a39

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3950,44 +3950,44 @@ RefPtr<StyleValue> Parser::parse_filter_value_list_value(TokenStream<ComponentVa
39503950
// blur( <length>? )
39513951
if (!tokens.has_next_token())
39523952
return Filter::Blur {};
3953-
auto blur_radius = parse_length(tokens.next_token());
3953+
auto blur_radius = parse_length(tokens);
3954+
tokens.skip_whitespace();
39543955
if (!blur_radius.has_value())
39553956
return {};
3956-
return if_no_more_tokens_return(Filter::Blur { *blur_radius });
3957+
// FIXME: Support calculated radius
3958+
return if_no_more_tokens_return(Filter::Blur { blur_radius->value() });
39573959
} else if (filter_token == FilterToken::DropShadow) {
39583960
if (!tokens.has_next_token())
39593961
return {};
3960-
auto next_token = [&]() -> auto& {
3961-
auto& token = tokens.next_token();
3962-
tokens.skip_whitespace();
3963-
return token;
3964-
};
39653962
// drop-shadow( [ <color>? && <length>{2,3} ] )
39663963
// Note: The following code is a little awkward to allow the color to be before or after the lengths.
3967-
auto& first_param = next_token();
3968-
Optional<Length> maybe_radius = {};
3969-
auto maybe_color = parse_color(first_param);
3970-
auto x_offset = parse_length(maybe_color.has_value() ? next_token() : first_param);
3964+
Optional<LengthOrCalculated> maybe_radius = {};
3965+
auto maybe_color = parse_color(tokens.peek_token());
3966+
if (maybe_color.has_value())
3967+
(void)tokens.next_token();
3968+
auto x_offset = parse_length(tokens);
3969+
tokens.skip_whitespace();
39713970
if (!x_offset.has_value() || !tokens.has_next_token()) {
39723971
return {};
39733972
}
3974-
auto y_offset = parse_length(next_token());
3973+
auto y_offset = parse_length(tokens);
39753974
if (!y_offset.has_value()) {
39763975
return {};
39773976
}
39783977
if (tokens.has_next_token()) {
3979-
auto& token = next_token();
3980-
maybe_radius = parse_length(token);
3978+
maybe_radius = parse_length(tokens);
39813979
if (!maybe_color.has_value() && (!maybe_radius.has_value() || tokens.has_next_token())) {
3982-
maybe_color = parse_color(!maybe_radius.has_value() ? token : next_token());
3980+
maybe_color = parse_color(tokens.next_token());
3981+
tokens.skip_whitespace();
39833982
if (!maybe_color.has_value()) {
39843983
return {};
39853984
}
39863985
} else if (!maybe_radius.has_value()) {
39873986
return {};
39883987
}
39893988
}
3990-
return if_no_more_tokens_return(Filter::DropShadow { *x_offset, *y_offset, maybe_radius, maybe_color });
3989+
// FIXME: Support calculated offsets and radius
3990+
return if_no_more_tokens_return(Filter::DropShadow { x_offset->value(), y_offset->value(), maybe_radius.map([](auto& it) { return it.value(); }), maybe_color });
39913991
} else if (filter_token == FilterToken::HueRotate) {
39923992
// hue-rotate( [ <angle> | <zero> ]? )
39933993
if (!tokens.has_next_token())

0 commit comments

Comments
 (0)