LibWeb: Set hue-rotate angle to 0 degrees if omitted

This commit is contained in:
Tim Ledbetter 2025-04-04 12:23:39 +01:00
parent bf541db81f
commit e62526dcf3
4 changed files with 15 additions and 20 deletions

View file

@ -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("{}(",

View file

@ -39,7 +39,7 @@ struct HueRotate {
bool operator==(Zero const&) const = default;
};
using AngleOrZero = Variant<AngleOrCalculated, Zero>;
Optional<AngleOrZero> angle;
AngleOrZero angle { Angle::make_degrees(0) };
float angle_degrees(Layout::Node const&) const;
bool operator==(HueRotate const&) const = default;
};

View file

@ -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)'

View file

@ -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