⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 243259 in webkit


Ignore:
Timestamp:
Mar 20, 2019, 4:51:47 PM (7 years ago)
Author:
Said Abou-Hallawa
Message:

Remove the SVG tear off objects for SVGColorAnimator
https://bugs.webkit.org/show_bug.cgi?id=196025

Reviewed by Simon Fraser.

SVG attributes like "fill" and "stroke" do not have reflecting properties
in SVGElement but they are animatable by SMIL. Animating such attributes
is different from animating the SVG animated properties. These new classes
will be added to handle the first type of this kind of attribute: the Color:

-- SVGPropertyAnimatorCreator is added to SVGElement. It is responsible

for creating SVGPropertyAnimators for the attribute which do not have
reflecting animated properties stored by SVGElement. It will maintain
a HashMap for the animated values for these attributes which is indexed
by the attribute name. The animated values has to be RefCounted because
the same attribute can be animated by multiple animators. So the values
of this HashMap will be of type Ref<SVGProperty>, e.g.

<circle cx="80" cy="120" r="35">

<animate attributeName="fill" values="#080" begin="2s" />
<animate attributeName="fill" values="#602;#004" begin="4s" dur="5s"/>

</circle>

-- SVGPropertyAnimator is the a new type which animates an attribute with

no reflecting animated property.

-- SVGPrimitivePropertyAnimator is a template class which is responsible

for animating attributes with primitive types, e.g. Color, string and
float. It is derived form SVGPropertyAnimator and it is initialized
with a Ref<SVGValueProperty<PropertyType>> which is created and maintained
by SVGPropertyAnimatorFactory.

-- SVGAnimationColorFunction is the animation function that animates the

attributes whose type are Color. Note the conversion form String to
Color in this class has to handle the case when its value is "attributeName="
e.g. <animate attributeName="fill" from="attributeName="r"/>

-- SVGColorAnimator will be defined to be

SVGPrimitivePropertyAnimator<Color, SVGAnimationColorFunction>.

The life cycle of the RefCounted properties can be explained as follows:

-- SVGPropertyAnimatorFactory checks whether its HashMap has an entry

for the given attribute name. If it does not have, it will create a
new value through the value creation method for this attribute.

-- SVGPropertyAnimatorFactory passes the shared animated value to the

animator creation method. So multiple animators will be accessing the
same value through their RefCounted pointers.

-- When the animator is about to be deleted, it will notify the target

SVGElement which will notify its SVGPropertyAnimatorFactory.
SVGPropertyAnimatorFactory will check its HashMap and retrieves the
entry for the given attribute name. If the refCount is 2, it is going
to remove the entry form the HashMap.

  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • svg/SVGAnimateColorElement.cpp:

(WebCore::attributeValueIsCurrentColor): Deleted.
(WebCore::SVGAnimateColorElement::determinePropertyValueTypes): Deleted.

  • svg/SVGAnimateColorElement.h:
  • svg/SVGAnimateElementBase.cpp:

(WebCore::SVGAnimateElementBase::attributeAnimationController):

  • svg/SVGAnimatedColor.cpp: Removed.
  • svg/SVGAnimatedColor.h: Removed.
  • svg/SVGAnimatorFactory.h:

(WebCore::SVGAnimatorFactory::create):

  • svg/SVGAttributeAnimationController.cpp:

(WebCore::SVGAttributeAnimationController::~SVGAttributeAnimationController):

  • svg/SVGAttributeAnimationController.h:
  • svg/SVGElement.cpp:

(WebCore::SVGElement::SVGElement):
(WebCore::SVGElement::isAnimatedAttribute const):
(WebCore::SVGElement::createAnimator):
(WebCore::SVGElement::animatorWillBeDeleted):

  • svg/SVGElement.h:

(WebCore::SVGElement::propertyAnimatorFactory):

  • svg/SVGFitToViewBox.h:
  • svg/SVGMPathElement.cpp:
  • svg/graphics/filters/SVGFEImage.h:
  • svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp: Added.

(WebCore::SVGAnimationColorFunction::colorFromString):

  • svg/properties/SVGAnimationAdditiveValueFunctionImpl.h:

(WebCore::SVGAnimationColorFunction::progress):

  • svg/properties/SVGAnimationFunction.h:
  • svg/properties/SVGAttributeAnimator.cpp:

(WebCore::SVGAttributeAnimator::applyAnimatedStylePropertyChange):
(WebCore::SVGAttributeAnimator::removeAnimatedStyleProperty):

  • svg/properties/SVGAttributeAnimator.h:
  • svg/properties/SVGPrimitivePropertyAnimator.h: Added.

(WebCore::SVGPrimitivePropertyAnimator::create):
(WebCore::SVGPrimitivePropertyAnimator::SVGPrimitivePropertyAnimator):

  • svg/properties/SVGPrimitivePropertyAnimatorImpl.h: Added.
  • svg/properties/SVGPropertyAnimator.h: Added.

(WebCore::SVGPropertyAnimator::SVGPropertyAnimator):
(WebCore::SVGPropertyAnimator::adjustForInheritance const):
(WebCore::SVGPropertyAnimator::computeCSSPropertyValue const):
(WebCore::SVGPropertyAnimator::computeInheritedCSSPropertyValue const):

  • svg/properties/SVGPropertyAnimatorFactory.h: Added.

(WebCore::SVGPropertyAnimatorFactory::isKnownAttribute):
(WebCore::SVGPropertyAnimatorFactory::createAnimator):
(WebCore::SVGPropertyAnimatorFactory::animatorWillBeDeleted):
(WebCore::SVGPropertyAnimatorFactory::createColorAnimator):
(WebCore::SVGPropertyAnimatorFactory::attributeAnimatorCreator):

Location:
trunk/Source/WebCore
Files:
5 added
2 deleted
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r243252 r243259  
     12019-03-20  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        Remove the SVG tear off objects for SVGColorAnimator
     4        https://bugs.webkit.org/show_bug.cgi?id=196025
     5
     6        Reviewed by Simon Fraser.
     7
     8        SVG attributes like "fill" and "stroke" do not have reflecting properties
     9        in SVGElement but they are animatable by SMIL. Animating such attributes
     10        is different from animating the SVG animated properties. These new classes
     11        will be added to handle the first type of this kind of attribute: the Color:
     12
     13        -- SVGPropertyAnimatorCreator is added to SVGElement. It is responsible
     14           for creating SVGPropertyAnimators for the attribute which do not have
     15           reflecting animated properties stored by SVGElement. It will maintain
     16           a HashMap for the animated values for these attributes which is indexed
     17           by the attribute name. The animated values has to be RefCounted because
     18           the same attribute can be animated by multiple animators. So the values
     19           of this HashMap will be of type Ref<SVGProperty>, e.g.
     20            <circle cx="80" cy="120" r="35">
     21                <animate attributeName="fill" values="#080" begin="2s" />
     22                <animate attributeName="fill" values="#602;#004" begin="4s" dur="5s"/>
     23            </circle>
     24
     25        -- SVGPropertyAnimator is the a new type which animates an attribute with
     26           no reflecting animated property.
     27
     28        -- SVGPrimitivePropertyAnimator is a template class which is responsible
     29           for animating attributes with primitive types, e.g. Color, string and
     30           float. It is derived form SVGPropertyAnimator and it is initialized
     31           with a Ref<SVGValueProperty<PropertyType>> which is created and maintained
     32           by SVGPropertyAnimatorFactory.
     33
     34        -- SVGAnimationColorFunction is the animation function that animates the
     35           attributes whose type are Color. Note the conversion form String to
     36           Color in this class has to handle the case when its value is "attributeName="
     37           e.g. <animate attributeName="fill" from="attributeName="r"/>
     38
     39        -- SVGColorAnimator will be defined to be
     40           SVGPrimitivePropertyAnimator<Color, SVGAnimationColorFunction>.
     41
     42        The life cycle of the RefCounted properties can be explained as follows:
     43
     44        -- SVGPropertyAnimatorFactory checks whether its HashMap has an entry
     45           for the given attribute name. If it does not have, it will create a
     46           new value through the value creation method for this attribute.
     47
     48        -- SVGPropertyAnimatorFactory passes the shared animated value to the
     49           animator creation method. So multiple animators will be accessing the
     50           same value through their RefCounted pointers.
     51
     52        -- When the animator is about to be deleted, it will notify the target
     53           SVGElement which will notify its SVGPropertyAnimatorFactory.
     54           SVGPropertyAnimatorFactory will check its HashMap and retrieves the
     55           entry for the given attribute name. If the refCount is 2, it is going
     56           to remove the entry form the HashMap.
     57
     58        * Sources.txt:
     59        * WebCore.xcodeproj/project.pbxproj:
     60        * svg/SVGAnimateColorElement.cpp:
     61        (WebCore::attributeValueIsCurrentColor): Deleted.
     62        (WebCore::SVGAnimateColorElement::determinePropertyValueTypes): Deleted.
     63        * svg/SVGAnimateColorElement.h:
     64        * svg/SVGAnimateElementBase.cpp:
     65        (WebCore::SVGAnimateElementBase::attributeAnimationController):
     66        * svg/SVGAnimatedColor.cpp: Removed.
     67        * svg/SVGAnimatedColor.h: Removed.
     68        * svg/SVGAnimatorFactory.h:
     69        (WebCore::SVGAnimatorFactory::create):
     70        * svg/SVGAttributeAnimationController.cpp:
     71        (WebCore::SVGAttributeAnimationController::~SVGAttributeAnimationController):
     72        * svg/SVGAttributeAnimationController.h:
     73        * svg/SVGElement.cpp:
     74        (WebCore::SVGElement::SVGElement):
     75        (WebCore::SVGElement::isAnimatedAttribute const):
     76        (WebCore::SVGElement::createAnimator):
     77        (WebCore::SVGElement::animatorWillBeDeleted):
     78        * svg/SVGElement.h:
     79        (WebCore::SVGElement::propertyAnimatorFactory):
     80        * svg/SVGFitToViewBox.h:
     81        * svg/SVGMPathElement.cpp:
     82        * svg/graphics/filters/SVGFEImage.h:
     83        * svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp: Added.
     84        (WebCore::SVGAnimationColorFunction::colorFromString):
     85        * svg/properties/SVGAnimationAdditiveValueFunctionImpl.h:
     86        (WebCore::SVGAnimationColorFunction::progress):
     87        * svg/properties/SVGAnimationFunction.h:
     88        * svg/properties/SVGAttributeAnimator.cpp:
     89        (WebCore::SVGAttributeAnimator::applyAnimatedStylePropertyChange):
     90        (WebCore::SVGAttributeAnimator::removeAnimatedStyleProperty):
     91        * svg/properties/SVGAttributeAnimator.h:
     92        * svg/properties/SVGPrimitivePropertyAnimator.h: Added.
     93        (WebCore::SVGPrimitivePropertyAnimator::create):
     94        (WebCore::SVGPrimitivePropertyAnimator::SVGPrimitivePropertyAnimator):
     95        * svg/properties/SVGPrimitivePropertyAnimatorImpl.h: Added.
     96        * svg/properties/SVGPropertyAnimator.h: Added.
     97        (WebCore::SVGPropertyAnimator::SVGPropertyAnimator):
     98        (WebCore::SVGPropertyAnimator::adjustForInheritance const):
     99        (WebCore::SVGPropertyAnimator::computeCSSPropertyValue const):
     100        (WebCore::SVGPropertyAnimator::computeInheritedCSSPropertyValue const):
     101        * svg/properties/SVGPropertyAnimatorFactory.h: Added.
     102        (WebCore::SVGPropertyAnimatorFactory::isKnownAttribute):
     103        (WebCore::SVGPropertyAnimatorFactory::createAnimator):
     104        (WebCore::SVGPropertyAnimatorFactory::animatorWillBeDeleted):
     105        (WebCore::SVGPropertyAnimatorFactory::createColorAnimator):
     106        (WebCore::SVGPropertyAnimatorFactory::attributeAnimatorCreator):
     107
    11082019-03-20  Alex Christensen  <achristensen@webkit.org>
    2109
  • trunk/Source/WebCore/Sources.txt

    r243193 r243259  
    22712271svg/SVGAnimateTransformElement.cpp
    22722272svg/SVGAnimatedAngle.cpp
    2273 svg/SVGAnimatedColor.cpp
    22742273svg/SVGAnimatedEnumeration.cpp
    22752274svg/SVGAnimatedLength.cpp
     
    24232422svg/properties/SVGAnimatedPathSegListPropertyTearOff.cpp
    24242423svg/properties/SVGAnimatedProperty.cpp
     2424svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp
    24252425svg/properties/SVGAttributeAnimator.cpp
    24262426svg/properties/SVGAttributeOwnerProxy.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r243193 r243259  
    12241224                439D334413A6911C00C20F4F /* SVGAnimatedTypeAnimator.h in Headers */ = {isa = PBXBuildFile; fileRef = 439D334113A6911C00C20F4F /* SVGAnimatedTypeAnimator.h */; };
    12251225                439D334513A6911C00C20F4F /* SVGAnimatorFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 439D334213A6911C00C20F4F /* SVGAnimatorFactory.h */; };
    1226                 43A625F813B3304000AC94B8 /* SVGAnimatedColor.h in Headers */ = {isa = PBXBuildFile; fileRef = 43A625F613B3304000AC94B8 /* SVGAnimatedColor.h */; };
    12271226                43B85ED418CBEC5200E31AF4 /* SelectorPseudoClassAndCompatibilityElementMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B85ED218CBEC5200E31AF4 /* SelectorPseudoClassAndCompatibilityElementMap.cpp */; };
    12281227                43B9336913B261B1004584BF /* SVGAnimatedPointList.h in Headers */ = {isa = PBXBuildFile; fileRef = 43B9336713B261B1004584BF /* SVGAnimatedPointList.h */; };
     
    76727671                439D334213A6911C00C20F4F /* SVGAnimatorFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatorFactory.h; sourceTree = "<group>"; };
    76737672                43A0F0B013AC7D6D00A5F0A7 /* SVGAnimatedNumber.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedNumber.cpp; sourceTree = "<group>"; };
    7674                 43A625F613B3304000AC94B8 /* SVGAnimatedColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedColor.h; sourceTree = "<group>"; };
    7675                 43A625F713B3304000AC94B8 /* SVGAnimatedColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedColor.cpp; sourceTree = "<group>"; };
    76767673                43A6266613B3D11000AC94B8 /* SVGAnimatedString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedString.cpp; sourceTree = "<group>"; };
    76777674                43B85ED018CBEACE00E31AF4 /* makeSelectorPseudoClassAndCompatibilityElementMap.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = makeSelectorPseudoClassAndCompatibilityElementMap.py; sourceTree = "<group>"; };
     
    95289525                724EE54E1DC7F25B00A91FFB /* ActivityState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActivityState.h; sourceTree = "<group>"; };
    95299526                724EE54F1DC7F25B00A91FFB /* ActivityStateChangeObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActivityStateChangeObserver.h; sourceTree = "<group>"; };
     9527                7266F0132241BCE200833975 /* SVGPropertyAnimatorFactory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPropertyAnimatorFactory.h; sourceTree = "<group>"; };
     9528                7266F0142241BFB200833975 /* SVGPrimitivePropertyAnimatorImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPrimitivePropertyAnimatorImpl.h; sourceTree = "<group>"; };
     9529                7266F0152241C09800833975 /* SVGPrimitivePropertyAnimator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPrimitivePropertyAnimator.h; sourceTree = "<group>"; };
     9530                7266F0162241C0FE00833975 /* SVGPropertyAnimator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPropertyAnimator.h; sourceTree = "<group>"; };
     9531                7266F01822429CFD00833975 /* SVGAnimationAdditiveValueFunctionImpl.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimationAdditiveValueFunctionImpl.cpp; sourceTree = "<group>"; };
    95309532                727AFED11A2EA6A0000442E8 /* EXTsRGB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EXTsRGB.cpp; sourceTree = "<group>"; };
    95319533                727AFED21A2EA6A0000442E8 /* EXTsRGB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EXTsRGB.h; sourceTree = "<group>"; };
     
    1623616238                                55BE025F223B29C50032F08A /* SVGAnimationAdditiveFunction.h */,
    1623716239                                55EE535E223B2A0E00FBA944 /* SVGAnimationAdditiveValueFunction.h */,
     16240                                7266F01822429CFD00833975 /* SVGAnimationAdditiveValueFunctionImpl.cpp */,
    1623816241                                55BE0259223B29C10032F08A /* SVGAnimationAdditiveValueFunctionImpl.h */,
    1623916242                                55DCC51D2240615500C26E32 /* SVGAnimationDiscreteFunction.h */,
     
    1625816261                                55BE025A223B29C20032F08A /* SVGPointerMemberAccessor.h */,
    1625916262                                55DCC5252240749E00C26E32 /* SVGPrimitiveList.h */,
     16263                                7266F0152241C09800833975 /* SVGPrimitivePropertyAnimator.h */,
     16264                                7266F0142241BFB200833975 /* SVGPrimitivePropertyAnimatorImpl.h */,
    1626016265                                55EE5363223B2A2400FBA944 /* SVGProperty.h */,
    1626116266                                55DCC526224074FA00C26E32 /* SVGPropertyAccessor.h */,
    1626216267                                55DCC5272240750B00C26E32 /* SVGPropertyAccessorImpl.h */,
     16268                                7266F0162241C0FE00833975 /* SVGPropertyAnimator.h */,
     16269                                7266F0132241BCE200833975 /* SVGPropertyAnimatorFactory.h */,
    1626316270                                55EE5360223B2A2100FBA944 /* SVGPropertyOwner.h */,
    1626416271                                55BE025C223B29C30032F08A /* SVGPropertyOwnerRegistry.h */,
     
    2413024137                                B22277E60D00BF1F0071B782 /* SVGAnimatedAngle.idl */,
    2413124138                                B22277E70D00BF1F0071B782 /* SVGAnimatedBoolean.idl */,
    24132                                 43A625F713B3304000AC94B8 /* SVGAnimatedColor.cpp */,
    24133                                 43A625F613B3304000AC94B8 /* SVGAnimatedColor.h */,
    2413424139                                71CC7A1F152A0BFE009EEAF9 /* SVGAnimatedEnumeration.cpp */,
    2413524140                                08D46CE2127AD5FC0089694B /* SVGAnimatedEnumeration.h */,
     
    3192231927                                B222797A0D00BF220071B782 /* SVGAnimateColorElement.h in Headers */,
    3192331928                                087B84961272CEC800A14417 /* SVGAnimatedAngle.h in Headers */,
    31924                                 43A625F813B3304000AC94B8 /* SVGAnimatedColor.h in Headers */,
    3192531929                                08D46CE3127AD5FC0089694B /* SVGAnimatedEnumeration.h in Headers */,
    3192631930                                71FB967B1383D64600AC8A4C /* SVGAnimatedEnumerationPropertyTearOff.h in Headers */,
  • trunk/Source/WebCore/svg/SVGAnimateColorElement.cpp

    r229694 r243259  
    4141}
    4242
    43 static bool attributeValueIsCurrentColor(const String& value)
    44 {
    45     static NeverDestroyed<const AtomicString> currentColor("currentColor", AtomicString::ConstructFromLiteral);
    46     return value == currentColor;
    4743}
    48 
    49 void SVGAnimateColorElement::determinePropertyValueTypes(const String& from, const String& to)
    50 {
    51     SVGAnimateElementBase::determinePropertyValueTypes(from, to);
    52     if (attributeValueIsCurrentColor(from))
    53         m_fromPropertyValueType = CurrentColorValue;
    54     if (attributeValueIsCurrentColor(to))
    55         m_toPropertyValueType = CurrentColorValue;
    56 }
    57 
    58 }
  • trunk/Source/WebCore/svg/SVGAnimateColorElement.h

    r229694 r243259  
    3333private:
    3434    SVGAnimateColorElement(const QualifiedName&, Document&);
    35     void determinePropertyValueTypes(const String& from, const String& to) override;
    3635};
    3736
  • trunk/Source/WebCore/svg/SVGAnimateElementBase.cpp

    r243036 r243259  
    5050
    5151    if (!m_attributeAnimationController) {
    52         if (targetElement()->isAnimatedPropertyAttribute(attributeName()))
     52        if (targetElement()->isAnimatedAttribute(attributeName()))
    5353            m_attributeAnimationController = std::make_unique<SVGAttributeAnimationController>(*this, *targetElement());
    5454        else
  • trunk/Source/WebCore/svg/SVGAnimatorFactory.h

    r243185 r243259  
    2121
    2222#include "SVGAnimatedAngle.h"
    23 #include "SVGAnimatedColor.h"
    2423#include "SVGAnimatedEnumeration.h"
    2524#include "SVGAnimatedLength.h"
     
    4544
    4645        switch (attributeType) {
     46        case AnimatedBoolean:
     47        case AnimatedColor:
     48        case AnimatedInteger:
     49        case AnimatedIntegerOptionalInteger:
     50        case AnimatedPreserveAspectRatio:
     51        case AnimatedRect:
     52            return nullptr;
     53
    4754        case AnimatedAngle:
    4855            return std::make_unique<SVGAnimatedAngleAnimator>(animationElement, contextElement);
    49         case AnimatedBoolean:
    50             return nullptr;
    51         case AnimatedColor:
    52             return std::make_unique<SVGAnimatedColorAnimator>(*animationElement, *contextElement);
    5356        case AnimatedEnumeration:
    5457            return std::make_unique<SVGAnimatedEnumerationAnimator>(animationElement, contextElement);
    55         case AnimatedInteger:
    56             return nullptr;
    57         case AnimatedIntegerOptionalInteger:
    58             return nullptr;
    5958        case AnimatedLength:
    6059            return std::make_unique<SVGAnimatedLengthAnimator>(animationElement, contextElement);
     
    7170        case AnimatedPoints:
    7271            return std::make_unique<SVGAnimatedPointListAnimator>(animationElement, contextElement);
    73         case AnimatedPreserveAspectRatio:
    74             return nullptr;
    75         case AnimatedRect:
    76             return nullptr;
    7772        case AnimatedString:
    7873            return std::make_unique<SVGAnimatedStringAnimator>(animationElement, contextElement);
  • trunk/Source/WebCore/svg/SVGAttributeAnimationController.cpp

    r243183 r243259  
    3737    : SVGAttributeAnimationControllerBase(animationElement, targetElement)
    3838{
     39}
     40   
     41SVGAttributeAnimationController::~SVGAttributeAnimationController()
     42{
     43    if (m_animator)
     44        m_targetElement.animatorWillBeDeleted(m_animationElement.attributeName());
    3945}
    4046
  • trunk/Source/WebCore/svg/SVGAttributeAnimationController.h

    r243183 r243259  
    3838public:
    3939    SVGAttributeAnimationController(SVGAnimationElement&, SVGElement&);
     40    ~SVGAttributeAnimationController();
    4041   
    4142private:
  • trunk/Source/WebCore/svg/SVGElement.cpp

    r243130 r243259  
    4545#include "SVGImageElement.h"
    4646#include "SVGNames.h"
     47#include "SVGPropertyAnimatorFactory.h"
    4748#include "SVGRenderStyle.h"
    4849#include "SVGRenderSupport.h"
     
    276277    : StyledElement(tagName, document, CreateSVGElement)
    277278    , SVGLangSpace(this)
     279    , m_propertyAnimatorFactory(std::make_unique<SVGPropertyAnimatorFactory>())
    278280{
    279281    registerAttributes();
     
    757759bool SVGElement::isAnimatedAttribute(const QualifiedName& attributeName) const
    758760{
    759     return isAnimatedPropertyAttribute(attributeName);
     761    return SVGPropertyAnimatorFactory::isKnownAttribute(attributeName) || isAnimatedPropertyAttribute(attributeName);
    760762}
    761763
    762764std::unique_ptr<SVGAttributeAnimator> SVGElement::createAnimator(const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive)
    763765{
     766    // Property animator, e.g. "fill" or "fill-opacity".
     767    if (auto animator = propertyAnimatorFactory().createAnimator(attributeName, animationMode, calcMode, isAccumulated, isAdditive))
     768        return animator;
     769   
     770    // Animated property animator.
    764771    auto animator = propertyRegistry().createAnimator(attributeName, animationMode, calcMode, isAccumulated, isAdditive);
    765772    if (!animator)
     
    768775        instance->propertyRegistry().appendAnimatedInstance(attributeName, *animator);
    769776    return animator;
     777}
     778   
     779void SVGElement::animatorWillBeDeleted(const QualifiedName& attributeName)
     780{
     781    propertyAnimatorFactory().animatorWillBeDeleted(attributeName);
    770782}
    771783
  • trunk/Source/WebCore/svg/SVGElement.h

    r243130 r243259  
    4343class SVGDocumentExtensions;
    4444class SVGElementRareData;
     45class SVGPropertyAnimatorFactory;
    4546class SVGSVGElement;
    4647class SVGUseElement;
     
    162163
    163164    const SVGElement* attributeContextElement() const override { return this; }
     165    SVGPropertyAnimatorFactory& propertyAnimatorFactory() { return *m_propertyAnimatorFactory; }
    164166    std::unique_ptr<SVGAttributeAnimator> createAnimator(const QualifiedName&, AnimationMode, CalcMode, bool isAccumulated, bool isAdditive);
     167    void animatorWillBeDeleted(const QualifiedName&);
    165168
    166169    // These are needed for the RenderTree, animation and DOM.
     
    215218
    216219    HashSet<SVGElement*> m_elementsWithRelativeLengths;
     220
     221    std::unique_ptr<SVGPropertyAnimatorFactory> m_propertyAnimatorFactory;
    217222
    218223    AttributeOwnerProxy m_attributeOwnerProxy { *this };
  • trunk/Source/WebCore/svg/SVGFitToViewBox.h

    r243185 r243259  
    22 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005, 2006, 2007, 2010 Rob Buis <buis@kde.org>
    4  * Copyright (C) 2018 Apple Inc. All rights reserved.
     4 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
    55 *
    66 * This library is free software; you can redistribute it and/or
     
    2424#include "FloatRect.h"
    2525#include "QualifiedName.h"
     26#include "SVGAnimatedPropertyImpl.h"
     27#include "SVGAttributeOwnerProxyImpl.h"
    2628#include "SVGAttributeRegistry.h"
    2729#include "SVGNames.h"
    2830#include "SVGPreserveAspectRatio.h"
     31#include "SVGPropertyOwnerRegistry.h"
    2932#include <wtf/HashSet.h>
    3033
  • trunk/Source/WebCore/svg/SVGMPathElement.cpp

    r240237 r243259  
    2727#include "SVGNames.h"
    2828#include "SVGPathElement.h"
     29#include <wtf/IsoMallocInlines.h>
    2930
    3031namespace WebCore {
  • trunk/Source/WebCore/svg/graphics/filters/SVGFEImage.h

    r238524 r243259  
    3131class Image;
    3232class RenderElement;
     33class TreeScope;
    3334
    3435class FEImage final : public FilterEffect {
  • trunk/Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunctionImpl.h

    r243183 r243259  
    3030
    3131namespace WebCore {
     32
     33class SVGAnimationColorFunction : public SVGAnimationAdditiveValueFunction<Color> {
     34public:
     35    using Base = SVGAnimationAdditiveValueFunction<Color>;
     36    using Base::Base;
     37
     38    void setFromAndToValues(SVGElement* targetElement, const String& from, const String& to) override
     39    {
     40        m_from = colorFromString(targetElement, from);
     41        m_to = colorFromString(targetElement, to);
     42    }
     43
     44    void setToAtEndOfDurationValue(const String& toAtEndOfDuration) override
     45    {
     46        m_toAtEndOfDuration = SVGPropertyTraits<Color>::fromString(toAtEndOfDuration);
     47    }
     48
     49    void progress(SVGElement*, float percentage, unsigned repeatCount, Color& animated)
     50    {
     51        Color from = m_animationMode == AnimationMode::To ? animated : m_from;
     52       
     53        float red = Base::progress(percentage, repeatCount, from.red(), m_to.red(), toAtEndOfDuration().red(), animated.red());
     54        float green = Base::progress(percentage, repeatCount, from.green(), m_to.green(), toAtEndOfDuration().green(), animated.green());
     55        float blue = Base::progress(percentage, repeatCount, from.blue(), m_to.blue(), toAtEndOfDuration().blue(), animated.blue());
     56        float alpha = Base::progress(percentage, repeatCount, from.alpha(), m_to.alpha(), toAtEndOfDuration().alpha(), animated.alpha());
     57       
     58        animated = { roundAndClampColorChannel(red), roundAndClampColorChannel(green), roundAndClampColorChannel(blue), roundAndClampColorChannel(alpha) };
     59    }
     60
     61    float calculateDistance(SVGElement*, const String& from, const String& to) const override
     62    {
     63        Color fromColor = CSSParser::parseColor(from.stripWhiteSpace());
     64        if (!fromColor.isValid())
     65            return -1;
     66        Color toColor = CSSParser::parseColor(to.stripWhiteSpace());
     67        if (!toColor.isValid())
     68            return -1;
     69        float red = fromColor.red() - toColor.red();
     70        float green = fromColor.green() - toColor.green();
     71        float blue = fromColor.blue() - toColor.blue();
     72        return sqrtf(red * red + green * green + blue * blue);
     73    }
     74
     75private:
     76    void addFromAndToValues(SVGElement*) override
     77    {
     78        // Ignores any alpha and sets alpha on result to 100% opaque.
     79        m_to = {
     80            roundAndClampColorChannel(m_to.red() + m_from.red()),
     81            roundAndClampColorChannel(m_to.green() + m_from.green()),
     82            roundAndClampColorChannel(m_to.blue() + m_from.blue())
     83        };
     84    }
     85
     86    static Color colorFromString(SVGElement*, const String&);
     87};
    3288
    3389class SVGAnimationIntegerFunction : public SVGAnimationAdditiveValueFunction<int> {
  • trunk/Source/WebCore/svg/properties/SVGAnimationFunction.h

    r243036 r243259  
    2626#pragma once
    2727
     28#include "SVGAttributeAnimator.h"
     29
    2830namespace WebCore {
     31
     32class SVGElement;
    2933
    3034class SVGAnimationFunction {
  • trunk/Source/WebCore/svg/properties/SVGAttributeAnimator.cpp

    r243036 r243259  
    3333namespace WebCore {
    3434
     35void SVGAttributeAnimator::applyAnimatedStylePropertyChange(SVGElement* element, CSSPropertyID id, const String& value)
     36{
     37    ASSERT(element);
     38    ASSERT(!element->m_deletionHasBegun);
     39   
     40    if (!element->ensureAnimatedSMILStyleProperties().setProperty(id, value, false))
     41        return;
     42    element->invalidateStyle();
     43}
     44
     45void SVGAttributeAnimator::applyAnimatedStylePropertyChange(SVGElement* targetElement, const String& value)
     46{
     47    ASSERT(targetElement);
     48    ASSERT(m_attributeName != anyQName());
     49   
     50    // FIXME: Do we really need to check both isConnected and !parentNode?
     51    if (!targetElement->isConnected() || !targetElement->parentNode())
     52        return;
     53   
     54    CSSPropertyID id = cssPropertyID(m_attributeName.localName());
     55   
     56    SVGElement::InstanceUpdateBlocker blocker(*targetElement);
     57    applyAnimatedStylePropertyChange(targetElement, id, value);
     58   
     59    // If the target element has instances, update them as well, w/o requiring the <use> tree to be rebuilt.
     60    for (auto* instance : targetElement->instances())
     61        applyAnimatedStylePropertyChange(instance, id, value);
     62}
     63   
     64void SVGAttributeAnimator::removeAnimatedStyleProperty(SVGElement* element, CSSPropertyID id)
     65{
     66    ASSERT(element);
     67    ASSERT(!element->m_deletionHasBegun);
     68
     69    element->ensureAnimatedSMILStyleProperties().removeProperty(id);
     70    element->invalidateStyle();
     71}
     72
     73void SVGAttributeAnimator::removeAnimatedStyleProperty(SVGElement* targetElement)
     74{
     75    ASSERT(targetElement);
     76    ASSERT(m_attributeName != anyQName());
     77
     78    // FIXME: Do we really need to check both isConnected and !parentNode?
     79    if (!targetElement->isConnected() || !targetElement->parentNode())
     80        return;
     81
     82    CSSPropertyID id = cssPropertyID(m_attributeName.localName());
     83
     84    SVGElement::InstanceUpdateBlocker blocker(*targetElement);
     85    removeAnimatedStyleProperty(targetElement, id);
     86
     87    // If the target element has instances, update them as well, w/o requiring the <use> tree to be rebuilt.
     88    for (auto* instance : targetElement->instances())
     89        removeAnimatedStyleProperty(instance, id);
     90}
     91   
    3592void SVGAttributeAnimator::applyAnimatedPropertyChange(SVGElement* element, const QualifiedName& attributeName)
    3693{
  • trunk/Source/WebCore/svg/properties/SVGAttributeAnimator.h

    r243036 r243259  
    7575
    7676protected:
     77    static void applyAnimatedStylePropertyChange(SVGElement*, CSSPropertyID, const String& value);
     78    static void removeAnimatedStyleProperty(SVGElement*, CSSPropertyID);
    7779    static void applyAnimatedPropertyChange(SVGElement*, const QualifiedName&);
    7880
     81    void applyAnimatedStylePropertyChange(SVGElement*, const String& value);
     82    void removeAnimatedStyleProperty(SVGElement*);
    7983    void applyAnimatedPropertyChange(SVGElement*);
    8084
Note: See TracChangeset for help on using the changeset viewer.