From bd25d0b1b424abb6b50978f94fd05f8f619ba067 Mon Sep 17 00:00:00 2001 From: Gingeh <39150378+Gingeh@users.noreply.github.com> Date: Wed, 30 Oct 2024 21:36:57 +1100 Subject: [PATCH] LibWeb: Parse drop-shadow filter with missing or starting color --- .../Screenshot/css-filter-drop-shadow.html | 22 ++++++++++++++++++ .../images/css-filter-drop-shadow-ref.png | Bin 0 -> 6700 bytes .../reference/css-filter-drop-shadow-ref.html | 10 ++++++++ .../Libraries/LibWeb/CSS/Parser/Parser.cpp | 7 +++++- 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 Tests/LibWeb/Screenshot/css-filter-drop-shadow.html create mode 100644 Tests/LibWeb/Screenshot/images/css-filter-drop-shadow-ref.png create mode 100644 Tests/LibWeb/Screenshot/reference/css-filter-drop-shadow-ref.html diff --git a/Tests/LibWeb/Screenshot/css-filter-drop-shadow.html b/Tests/LibWeb/Screenshot/css-filter-drop-shadow.html new file mode 100644 index 00000000000..84a285d8eb7 --- /dev/null +++ b/Tests/LibWeb/Screenshot/css-filter-drop-shadow.html @@ -0,0 +1,22 @@ + + + + +
+
+
+
+
+
+
+
+
+
diff --git a/Tests/LibWeb/Screenshot/images/css-filter-drop-shadow-ref.png b/Tests/LibWeb/Screenshot/images/css-filter-drop-shadow-ref.png new file mode 100644 index 0000000000000000000000000000000000000000..991ddf9c9cbbfd29047fe8edcf29b9018efa8a82 GIT binary patch literal 6700 zcmeHLYgkj)w%q}&-~$X;tq%x)V-oWy~?g zoNKO~{;h}e@+E7RKoGS28yBoM1Zf&Wkj8%PPr#F0!r4d&S|j=fyK`S${v?MJ{j$F% zwX+oc6=6n+|FIBh6&b-L)Y%)dKABt^y4$IF{4qHmJNFrGv|y^}!r3oOY^Qg_=|JJmo`BQ|#9;KuDMN3c$`q=-;=TdF41g!^#N zui`&u>0aOSy^KLzVA2lqX8;65)9(UBkM}gkfOLu1bUw)ADt21n<|O|7(;s?aP-@w+ z50lb%BP}JPUT{@erl96x^dPV>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|42&%eLdd`}Y$ng1i`tK^B&rt7R`#q3kh zEp_bz#jHPNJ`s?Pv$w(^1D#tc9iImwl8X#>3h~cHeZX?&1qkCO3LDj&AZV-J1)_W# z@bba7MJ+vxEaS1D12o|d9y5^TV}O%A?4rovL~9EDb2sL{e&_yshyV4(?{7-}rsUUO lfdBTx-+uW2_Jd;evTt7#Jj3fF!65;Cv)cn(;dJ=ye* + * { + margin: 0; + } + + body { + background-color: white; + } + + diff --git a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp index a945d2318df..8af7a1069b8 100644 --- a/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp +++ b/Userland/Libraries/LibWeb/CSS/Parser/Parser.cpp @@ -5455,6 +5455,7 @@ RefPtr Parser::parse_filter_value_list_value(TokenStream maybe_radius = {}; auto maybe_color = parse_color_value(tokens); + tokens.discard_whitespace(); auto x_offset = parse_length(tokens); tokens.discard_whitespace(); if (!x_offset.has_value() || !tokens.has_next_token()) @@ -5476,8 +5477,12 @@ RefPtr Parser::parse_filter_value_list_value(TokenStream color = {}; + if (maybe_color) + color = maybe_color->to_color({}); + // FIXME: Support calculated offsets and radius - return if_no_more_tokens_return(FilterOperation::DropShadow { x_offset->value(), y_offset->value(), maybe_radius.map([](auto& it) { return it.value(); }), maybe_color->to_color({}) }); + return if_no_more_tokens_return(FilterOperation::DropShadow { x_offset->value(), y_offset->value(), maybe_radius.map([](auto& it) { return it.value(); }), color }); } else if (filter_token == FilterToken::HueRotate) { // hue-rotate( [ | ]? ) if (!tokens.has_next_token())