Bug 196025 - Remove the SVG tear off objects for SVGColorAnimator
Summary: Remove the SVG tear off objects for SVGColorAnimator
Status: RESOLVED FIXED
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: InRadar
Depends on: 195960
Blocks: 191237 196037
  Show dependency treegraph
 
Reported: 2019-03-20 13:13 PDT by Said Abou-Hallawa
Modified: 2019-03-20 16:52 PDT (History)
4 users (show)

See Also:


Attachments
Patch (57.52 KB, patch)
2019-03-20 13:47 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 2019-03-20 13:13:57 PDT
SVG attributes like "fill" and "stroke" do not have reflecting properties in SVGElement but they are animatable by SMIL. Since there is no animated properties for these attributes, a temporary variable must be created and initialized with the attribute value. This The value of this variable is progressed during the animation interval. The new progressed value has to be pushed to SVGElementRareData during the animation. When animation stops, the attribute and its animated value is removed from SVGElementRareData.

Because the attribute can be animated by multiple animators, all the multiple animators must reference the same temporary variable. A new animator named SVGColorAnimator will be created. The creator SVGPropertyAnimatorCreator will keep a RefCounted object for the temporary variable in a HashMap which is indexed by the attribute name. A new entry is created and appended to this HashMap when the first animator is created. An existing entry will be removed when the last animator is removed.
Comment 1 Said Abou-Hallawa 2019-03-20 13:47:22 PDT
Created attachment 365394 [details]
Patch
Comment 2 Simon Fraser (smfr) 2019-03-20 16:15:12 PDT
Comment on attachment 365394 [details]
Patch

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

> Source/WebCore/ChangeLog:44
> +        -- SVGPropertyAnimatorCreator checks its HashMap it has an entry for the

checks whether its HashMap has an entry

> Source/WebCore/ChangeLog:53
> +           SVGElement about that which will notify its SVGPropertyAnimatorCreator.

Remove "about that"

> Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp:38
> +    static NeverDestroyed<const AtomicString> currentColor("currentColor", AtomicString::ConstructFromLiteral);
> +
> +    if (string != currentColor.get())

Not sure why this uses AtomicString; this code does an explicit string compare, so doesn't atomic-ness.

> Source/WebCore/svg/properties/SVGPropertyAnimatorCreator.h:33
> +class SVGPropertyAnimatorCreator {

Classes that make things are usually called "factories". So SVGPropertyAnimatorFactory

> Source/WebCore/svg/properties/SVGPropertyAnimatorCreator.h:63
> +        // If refCount = 1 (in the animator) + 1 (in m_attributeProperty) = 2, the entry can be deleted.
> +        if (iterator->value->refCount() == 2)
> +            m_attributeProperty.remove(iterator);

Removing based on looking at refCounts feels a bit icky.
Comment 3 Said Abou-Hallawa 2019-03-20 16:35:56 PDT
Comment on attachment 365394 [details]
Patch

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

>> Source/WebCore/ChangeLog:44
>> +        -- SVGPropertyAnimatorCreator checks its HashMap it has an entry for the
> 
> checks whether its HashMap has an entry

Fixed.

>> Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp:38
>> +    if (string != currentColor.get())
> 
> Not sure why this uses AtomicString; this code does an explicit string compare, so doesn't atomic-ness.

static variable is converted to NeverDestroyed<const String>.

>> Source/WebCore/svg/properties/SVGPropertyAnimatorCreator.h:33
>> +class SVGPropertyAnimatorCreator {
> 
> Classes that make things are usually called "factories". So SVGPropertyAnimatorFactory

Done.

>> Source/WebCore/svg/properties/SVGPropertyAnimatorCreator.h:63
>> +            m_attributeProperty.remove(iterator);
> 
> Removing based on looking at refCounts feels a bit icky.

I will think about it.
Comment 4 Radar WebKit Bug Importer 2019-03-20 16:38:22 PDT
<rdar://problem/49085121>
Comment 5 Said Abou-Hallawa 2019-03-20 16:52:06 PDT
Committed r243259: <https://trac.webkit.org/changeset/243259>