1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:57:35 +00:00

LibWeb: Add support for the SVG gradient spreadMethod attribute

This commit is contained in:
MacDue 2023-08-20 15:45:02 +01:00 committed by Andreas Kling
parent 1ecb2cf28c
commit 46f42d9755
6 changed files with 52 additions and 0 deletions

View file

@ -22,6 +22,8 @@ void SVGGradientElement::attribute_changed(DeprecatedFlyString const& name, Depr
SVGElement::attribute_changed(name, value);
if (name == AttributeNames::gradientUnits) {
m_gradient_units = AttributeParser::parse_gradient_units(value);
} else if (name == AttributeNames::spreadMethod) {
m_spread_method = AttributeParser::parse_spread_method(value);
} else if (name == AttributeNames::gradientTransform) {
if (auto transform_list = AttributeParser::parse_transform(value); transform_list.has_value()) {
m_gradient_transform = transform_from_transform_list(*transform_list);
@ -40,6 +42,15 @@ GradientUnits SVGGradientElement::gradient_units() const
return GradientUnits::ObjectBoundingBox;
}
SpreadMethod SVGGradientElement::spread_method() const
{
if (m_spread_method.has_value())
return *m_spread_method;
if (auto gradient = linked_gradient())
return gradient->spread_method();
return SpreadMethod::Pad;
}
Optional<Gfx::AffineTransform> SVGGradientElement::gradient_transform() const
{
if (m_gradient_transform.has_value())