diff --git a/Libraries/LibWeb/CSS/StyleValues/FilterValueListStyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/FilterValueListStyleValue.cpp index 2fbc4541a7e..27ff81fc7a6 100644 --- a/Libraries/LibWeb/CSS/StyleValues/FilterValueListStyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/FilterValueListStyleValue.cpp @@ -24,10 +24,7 @@ float FilterOperation::Blur::resolved_radius(Layout::Node const& node) const float FilterOperation::HueRotate::angle_degrees(Layout::Node const& node) const { - // Default value when omitted is 0deg. - if (!angle.has_value()) - return 0.0f; - return angle->visit([&](AngleOrCalculated const& a) { return a.resolved({ .length_resolution_context = Length::ResolutionContext::for_layout_node(node) })->to_degrees(); }, [&](Zero) { return 0.0; }); + return angle.visit([&](AngleOrCalculated const& a) { return a.resolved({ .length_resolution_context = Length::ResolutionContext::for_layout_node(node) })->to_degrees(); }, [&](Zero) { return 0.0; }); } float FilterOperation::Color::resolved_amount() const @@ -75,15 +72,13 @@ String FilterValueListStyleValue::to_string(SerializationMode) const }, [&](FilterOperation::HueRotate const& hue_rotate) { builder.append("hue-rotate("sv); - if (hue_rotate.angle.has_value()) { - hue_rotate.angle->visit( - [&](Angle const& angle) { - return builder.append(angle.to_string()); - }, - [&](auto&) { - return builder.append('0'); - }); - } + hue_rotate.angle.visit( + [&](Angle const& angle) { + builder.append(angle.to_string()); + }, + [&](auto&) { + builder.append("0deg"sv); + }); }, [&](FilterOperation::Color const& color) { builder.appendff("{}(", diff --git a/Libraries/LibWeb/CSS/StyleValues/FilterValueListStyleValue.h b/Libraries/LibWeb/CSS/StyleValues/FilterValueListStyleValue.h index fe5687c5e30..a2f87c43823 100644 --- a/Libraries/LibWeb/CSS/StyleValues/FilterValueListStyleValue.h +++ b/Libraries/LibWeb/CSS/StyleValues/FilterValueListStyleValue.h @@ -39,7 +39,7 @@ struct HueRotate { bool operator==(Zero const&) const = default; }; using AngleOrZero = Variant; - Optional angle; + AngleOrZero angle { Angle::make_degrees(0) }; float angle_degrees(Layout::Node const&) const; bool operator==(HueRotate 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 b599a03fc95..3ed60d237ee 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,8 +2,8 @@ Harness status: OK Found 34 tests -16 Pass -18 Fail +17 Pass +17 Fail Pass Property filter value 'none' Pass Property filter value 'blur(100px)' Fail Property filter value 'blur()' @@ -21,7 +21,7 @@ Fail Property filter value 'grayscale(2)' Fail Property filter value 'grayscale(calc(2))' Pass Property filter value 'grayscale()' Fail Property filter value 'hue-rotate(90deg)' -Fail Property filter value 'hue-rotate()' +Pass Property filter value 'hue-rotate()' Pass Property filter value 'invert(0)' Fail Property filter value 'invert(100%)' Fail Property filter value 'invert(2)' diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/filter-effects/parsing/filter-parsing-valid.txt b/Tests/LibWeb/Text/expected/wpt-import/css/filter-effects/parsing/filter-parsing-valid.txt index 0db8824f6bb..88a86a4b900 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/filter-effects/parsing/filter-parsing-valid.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/filter-effects/parsing/filter-parsing-valid.txt @@ -2,8 +2,8 @@ Harness status: OK Found 39 tests -30 Pass -9 Fail +31 Pass +8 Fail Pass e.style['filter'] = "none" should set the property value Pass e.style['filter'] = "blur(100px)" should set the property value Pass e.style['filter'] = "blur(0)" should set the property value @@ -26,7 +26,7 @@ Pass e.style['filter'] = "grayscale(calc(300%))" should set the property value Pass e.style['filter'] = "grayscale(calc(101% * sign(1em - 1px)))" should set the property value Pass e.style['filter'] = "grayscale()" should set the property value Fail e.style['filter'] = "hue-rotate(90deg)" should set the property value -Fail e.style['filter'] = "hue-rotate(0)" should set the property value +Pass e.style['filter'] = "hue-rotate(0)" should set the property value Pass e.style['filter'] = "hue-rotate()" should set the property value Pass e.style['filter'] = "invert(0)" should set the property value Fail e.style['filter'] = "invert(300%)" should set the property value