Bug 257906 - <animateTransform> broken with no type attribute
Summary: <animateTransform> broken with no type attribute
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: BrowserCompat, InRadar, WPTImpact
Depends on:
Blocks:
 
Reported: 2023-06-09 13:18 PDT by Ahmad Saleem
Modified: 2024-07-04 12:04 PDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ahmad Saleem 2023-06-09 13:18:10 PDT
Hi Team,

While going through WPT failure, came across another, where Safari / WebKit is odd one out.


WPT Test Link: https://wpt.fyi/results/svg/animations/scripted/animatetransform-type-missing-value-default.html?label=experimental&label=master&aligned

WPT Live Link: http://wpt.live/svg/animations/scripted/animatetransform-type-missing-value-default.html

_____

Blink Commit: https://chromium.googlesource.com/chromium/src.git/+/5351b4d9ef755bfde1e07f994197d6f7ef8317d4

____

Just wanted to raise so we can track this failure and fix it.

Thanks!
Comment 2 Radar WebKit Bug Importer 2023-06-16 13:19:16 PDT
<rdar://problem/110915695>
Comment 3 Ahmad Saleem 2023-07-05 08:32:03 PDT
Changing this:

https://searchfox.org/wubkat/source/Source/WebCore/svg/SVGAnimateTransformElement.cpp#36

from:

, m_type(SVGTransformValue::SVG_TRANSFORM_UNKNOWN)


to:

, m_type(SVGTransformValue::SVG_TRANSFORM_TRANSLATE)

_____

It progress one test. While we still fail last one, still looking into it.
Comment 4 Ahmad Saleem 2023-11-13 17:11:53 PST
static SVGTransformValue parseTypeAttribute(const String& value)
{
    if (value.isNull())
        return SVGTransformValue::SVG_TRANSFORM_TRANSLATE;
    auto transformType = SVGTransformable::parseTransformType(value);
    // Since parseTransformType() is also used when parsing transform lists, it accepts the value
    // "matrix". That value is however not recognized by the 'type' attribute, so treat it as invalid.
    if (transformType == SVGTransformValue::SVG_TRANSFORM_MATRIX)
        transformType = SVGTransformValue::SVG_TRANSFORM_UNKNOWN;
    return transformType;
}

void SVGAnimateTransformElement::attributeChanged(const QualifiedName& name, const AtomString& oldValue, const AtomString& newValue, AttributeModificationReason attributeModificationReason)
{
    if (name == SVGNames::typeAttr) {
        auto oldTransformType = m_type;
        m_type = SVGTransformable::parseTransformType(newValue);
        if (m_type != oldTransformType)
            animationAttributeChanged();
            return;
    }

    SVGAnimateElementBase::attributeChanged(name, oldValue, newValue, attributeModificationReason);
}

___

Something like this but haven't tested or compiled locally.
Comment 5 Ahmad Saleem 2024-07-04 12:04:29 PDT
static std::optional<SVGTransformValue::SVGTransformType> parseTypeAttribute(const String& value)
{
    if (value.isNull())
        return SVGTransformValue::SVG_TRANSFORM_TRANSLATE;
    auto transformType = SVGTransformable::parseTransformType(value);
    // Since parseTransformType() is also used when parsing transform lists, it accepts the value
    // "matrix". That value is however not recognized by the 'type' attribute, so treat it as invalid.
    if (transformType == SVGTransformValue::SVG_TRANSFORM_TRANSLATE)
        transformType = SVGTransformValue::SVG_TRANSFORM_UNKNOWN;
    return transformType;
}

void SVGAnimateTransformElement::attributeChanged(const QualifiedName& name, const AtomString& oldValue, const AtomString& newValue, AttributeModificationReason attributeModificationReason)
{
    if (name == SVGNames::typeAttr) {
       auto oldTransformType = m_type;
        m_type = parseTypeAttribute(newValue);
        if (m_type != oldTransformType)
            animationAttributeChanged();
    }

    SVGAnimateElementBase::attributeChanged(name, oldValue, newValue, attributeModificationReason);
}

__

Get following error:

assigning to 'SVGTransformValue::SVGTransformType' from incompatible type
      'std::optional<SVGTransformValue::SVGTransformType>'
        m_type = parseTypeAttribute(newValue);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.