Bug 187258 - Introduce SVGAttribute
Summary: Introduce SVGAttribute
Status: RESOLVED DUPLICATE of bug 186751
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Said Abou-Hallawa
URL:
Keywords:
Depends on:
Blocks: 186751
  Show dependency treegraph
 
Reported: 2018-07-02 11:37 PDT by Said Abou-Hallawa
Modified: 2018-08-06 14:26 PDT (History)
9 users (show)

See Also:


Attachments
Patch (6.39 KB, patch)
2018-07-02 11:38 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Said Abou-Hallawa 2018-07-02 11:37:05 PDT
Introduce the classes which are needed to redefine the SVGElements' attribute. This work is towards removing the SVG elements' attributes macros.
Comment 1 Said Abou-Hallawa 2018-07-02 11:38:17 PDT
Created attachment 344120 [details]
Patch
Comment 2 Daniel Bates 2018-07-10 21:23:33 PDT
Comment on attachment 344120 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=344120&action=review

> Source/WebCore/ChangeLog:8
> +        This work is towards removing the SVG attributes macros.

It is great that you explained your plan. We tend to prefer to patches that both add a new data structure and include at least one actual code change that makes use of the new data structure. The latter provides a concrete example of how the data structure is used and reduces the likelihood that we are leave dead code in the repository in the unlikely event that you are unable to follow through with your plan.

> Source/WebCore/svg/properties/SVGAttribute.h:64
> +struct SVGPropertyAttribute : public SVGAttribute {
> +    SVGPropertyAttribute()
> +        : m_property(SVGPropertyTraits<PropertyType>::initialValue())
> +    {
> +    }
> +
> +    template<typename... Arguments>
> +    SVGPropertyAttribute(Arguments&&... arguments)
> +        : m_property(std::forward<Arguments>(arguments)...)
> +    {
> +    }
> +
> +    PropertyType& value() { return m_property; }
> +    const PropertyType& value() const { return m_property; }
> +
> +    void setValue(PropertyType&& property) { m_property = WTFMove(property); }
> +    void setValue(const PropertyType& property) { m_property = property; }
> +    void resetValue() { m_property = SVGPropertyTraits<PropertyType>::initialValue(); }
> +
> +    String toString() const { return SVGPropertyTraits<PropertyType>::toString(m_property); }
> +
> +    void setShouldSynchronize(bool shouldSynchronize) { m_shouldSynchronize = shouldSynchronize; }
> +    bool shouldSynchronize() const { return m_shouldSynchronize; }
> +    void synchronize(Element& element, const QualifiedName& attributeName)
> +    {
> +        if (!m_shouldSynchronize)
> +            return;
> +        element.setSynchronizedLazyAttribute(attributeName, toString());
> +    }

This is weird. We are underutilizing the purpose of the keyword "struct" and using it solely to avoid typing "public:\n". Having said that this data structure feels like a struct because it does not provide any encapsulation: it exposes all its instance data via setters and getters.

> Source/WebCore/svg/properties/SVGAttribute.h:79
> +    SVGAnimatedAttribute()
> +    {
> +    }

= default?

> Source/WebCore/svg/properties/SVGAttribute.h:96
> +    SVGAnimatedAttributeList()
> +    {
> +    }

= default?
Comment 3 Simon Fraser (smfr) 2018-07-11 11:39:45 PDT
Comment on attachment 344120 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=344120&action=review

> Source/WebCore/svg/properties/SVGAttribute.h:33
> +struct SVGAttribute { };

"attribute" has a well-known meaning in the context of HTML/XML, and I wonder if using the term here is going to cause confusion.
Comment 4 Said Abou-Hallawa 2018-07-30 16:42:55 PDT
The plan is submit all the SVG macro removal change as one patch although reviewing it will be done through multiple incremental patches in 186751.

*** This bug has been marked as a duplicate of bug 186751 ***