diff --git a/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp b/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp index d1342cf61ff..14595851dcc 100644 --- a/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp +++ b/Libraries/LibWeb/CSS/Parser/PropertyParsing.cpp @@ -4433,7 +4433,7 @@ RefPtr Parser::parse_filter_value_list_value(TokenStreamis_number() && amount->number().value() < 0) return {}; } - return if_no_more_tokens_return(FilterOperation::Color { filter_token_to_operation(filter_token), amount }); + return if_no_more_tokens_return(FilterOperation::Color { filter_token_to_operation(filter_token), amount.value_or(Number { Number::Type::Integer, 1 }) }); } }; diff --git a/Libraries/LibWeb/CSS/StyleValues/FilterValueListStyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/FilterValueListStyleValue.cpp index bc8d45e4829..2fbc4541a7e 100644 --- a/Libraries/LibWeb/CSS/StyleValues/FilterValueListStyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/FilterValueListStyleValue.cpp @@ -32,23 +32,19 @@ float FilterOperation::HueRotate::angle_degrees(Layout::Node const& node) const float FilterOperation::Color::resolved_amount() const { - // Default value when omitted is 1. - if (!amount.has_value()) - return 1; + if (amount.is_number()) + return amount.number().value(); - if (amount->is_number()) - return amount->number().value(); + if (amount.is_percentage()) + return amount.percentage().as_fraction(); - if (amount->is_percentage()) - return amount->percentage().as_fraction(); - - if (amount->is_calculated()) { + if (amount.is_calculated()) { CalculationResolutionContext context {}; - if (amount->calculated()->resolves_to_number()) - return amount->calculated()->resolve_number(context).value(); + if (amount.calculated()->resolves_to_number()) + return amount.calculated()->resolve_number(context).value(); - if (amount->calculated()->resolves_to_percentage()) - return amount->calculated()->resolve_percentage(context)->as_fraction(); + if (amount.calculated()->resolves_to_percentage()) + return amount.calculated()->resolve_percentage(context)->as_fraction(); } VERIFY_NOT_REACHED(); @@ -111,8 +107,8 @@ String FilterValueListStyleValue::to_string(SerializationMode) const VERIFY_NOT_REACHED(); } }()); - if (color.amount.has_value()) - builder.append(color.amount->to_string()); + + builder.append(color.amount.to_string()); }); builder.append(')'); first = false; diff --git a/Libraries/LibWeb/CSS/StyleValues/FilterValueListStyleValue.h b/Libraries/LibWeb/CSS/StyleValues/FilterValueListStyleValue.h index 1be7e71ddc3..fe5687c5e30 100644 --- a/Libraries/LibWeb/CSS/StyleValues/FilterValueListStyleValue.h +++ b/Libraries/LibWeb/CSS/StyleValues/FilterValueListStyleValue.h @@ -46,7 +46,7 @@ struct HueRotate { struct Color { Gfx::ColorFilter::Type operation; - Optional amount {}; + NumberPercentage amount { Number { Number::Type::Integer, 1.0 } }; float resolved_amount() const; bool operator==(Color const&) const = default; }; diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/filter-effects/parsing/filter-computed.txt b/Tests/LibWeb/Text/expected/wpt-import/css/filter-effects/parsing/filter-computed.txt index 45991f9854a..b599a03fc95 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/filter-effects/parsing/filter-computed.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/filter-effects/parsing/filter-computed.txt @@ -2,39 +2,39 @@ Harness status: OK Found 34 tests -9 Pass -25 Fail +16 Pass +18 Fail Pass Property filter value 'none' Pass Property filter value 'blur(100px)' Fail Property filter value 'blur()' Pass Property filter value 'brightness(0)' Fail Property filter value 'brightness(300%)' -Fail Property filter value 'brightness()' +Pass Property filter value 'brightness()' Pass Property filter value 'contrast(0)' Fail Property filter value 'contrast(300%)' -Fail Property filter value 'contrast()' +Pass Property filter value 'contrast()' Fail Property filter value 'drop-shadow(1px 2px)' Pass Property filter value 'drop-shadow(rgb(4, 5, 6) 1px 2px 0px)' Fail Property filter value 'grayscale(50%)' Fail Property filter value 'grayscale(calc(50%))' Fail Property filter value 'grayscale(2)' Fail Property filter value 'grayscale(calc(2))' -Fail Property filter value 'grayscale()' +Pass Property filter value 'grayscale()' Fail Property filter value 'hue-rotate(90deg)' Fail Property filter value 'hue-rotate()' Pass Property filter value 'invert(0)' Fail Property filter value 'invert(100%)' Fail Property filter value 'invert(2)' -Fail Property filter value 'invert()' +Pass Property filter value 'invert()' Pass Property filter value 'opacity(0)' Fail Property filter value 'opacity(100%)' Fail Property filter value 'opacity(2)' -Fail Property filter value 'opacity()' +Pass Property filter value 'opacity()' Pass Property filter value 'saturate(0)' Fail Property filter value 'saturate(300%)' -Fail Property filter value 'saturate()' +Pass Property filter value 'saturate()' Pass Property filter value 'sepia(0)' Fail Property filter value 'sepia(100%)' Fail Property filter value 'sepia(2)' -Fail Property filter value 'sepia()' +Pass Property filter value 'sepia()' Fail Property filter value 'blur(10px) url("https://www.example.com/picture.svg#f") contrast(20) brightness(30)' \ No newline at end of file