Changeset 243036 in webkit


Ignore:
Timestamp:
Mar 16, 2019 12:42:41 AM (5 years ago)
Author:
commit-queue@webkit.org
Message:

Remove the SVG property tear off objects for SVGAnimatedInteger
https://bugs.webkit.org/show_bug.cgi?id=195722

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2019-03-16
Reviewed by Simon Fraser.

Instead of saving a raw integer value in the SVGElement and then wrapping
the pointer to this raw data in a tear off object, we will represent the
integer as Ref<SVGAnimatedInteger> in SVGElement. This will make the
representation of the property in IDL file match the C++ header file.

When the DOM requests the SVGAnimatedInteger, we get return a reference
to the new animated property. When the rendering code asks for the current
value of the this animated property, we return the animVal() or the
baseVal() depending on whether the property is animating or not.

A pointer to a member in the SVGElement will be registered along with the
associated attribute name in SVGPropertyRegistry. Registering the property
creates an SVGMemberAccessor and links to the associated attribute. The
function of SVGMemberAccessor is to retrieve the value of the property
given a pointer to an SVGElement.

SVGPropertyRegistry manages all the properties of SVGElement. It takes
into account the inherited properties as well.

SVGElement will have a virtual method called propertyRegistry(). Every
superclass will override this method to return a reference to its registry
which includes all the registered properties of this class and its bases.

One important function of the SVGPropertyRegistry and SVGAccessor is they
create the appropriate SVGAttributeAnimator for this property.

SVGAttributeAnimator is just a connection between the animated property
and SVGAnimationFunction. SVGAnimationFunction calculates the values of
the animated property within a time interval. SVGAnimatedPropertyAnimator
updates animVal of the animated property and invalidates the associated
SVGElement and all the instances that references this element.

The plan is to remove all the SVG tear off objects like what this patch
does for SVGAnimatedInteger. So for a period of time the old code and the
new code will co-exist together. These things to consider when reviewing
this patch:

-- SVGAnimatedElementBase was re-factored to use SVGAttributeAnimationControllerBase
which is inherited by SVGLegacyAttributeAnimationController and
SVGAttributeAnimationController. The tear-off properties code which uses
SVGAnimatedType now lives in SVGLegacyAttributeAnimationController. The
new code was added to SVGAttributeAnimationController. The plan is to
remove the three animation controllers and to move the code of
SVGAttributeAnimationController to SVGAnimatedElementBase when all the tear
off code is removed.

-- SVGElement now keeps two registries one for the tear-off world and the
other for the new world. Eventually we need to get rid of tear-off registry.

-- SVGElement will differentiate between the type of the property by the
the method isAnimatedAttribute().

  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateHeader):

  • svg/SVGAnimateElementBase.cpp:

(WebCore::SVGAnimateElementBase::SVGAnimateElementBase):
(WebCore::SVGAnimateElementBase::attributeAnimationController):
(WebCore::SVGAnimateElementBase::attributeAnimationControllerIfExists):
(WebCore::SVGAnimateElementBase::hasValidAttributeType const):
(WebCore::SVGAnimateElementBase::determineAnimatedPropertyType const):
(WebCore::SVGAnimateElementBase::calculateAnimatedValue):
(WebCore::SVGAnimateElementBase::calculateToAtEndOfDurationValue):
(WebCore::SVGAnimateElementBase::calculateFromAndToValues):
(WebCore::SVGAnimateElementBase::calculateFromAndByValues):
(WebCore::SVGAnimateElementBase::resetAnimatedType):
(WebCore::SVGAnimateElementBase::clearAnimatedType):
(WebCore::SVGAnimateElementBase::applyResultsToTarget):
(WebCore::SVGAnimateElementBase::isAdditive const):
(WebCore::SVGAnimateElementBase::calculateDistance):
(WebCore::SVGAnimateElementBase::setTargetElement):
(WebCore::SVGAnimateElementBase::setAttributeName):
(WebCore::SVGAnimateElementBase::resetAnimation):
(WebCore::SVGAnimateElementBase::hasInvalidCSSAttributeType const):
(WebCore::SVGAnimateElementBase::hasValidAttributeType): Deleted.
(WebCore::propertyTypesAreConsistent): Deleted.
(WebCore::applyCSSPropertyToTarget): Deleted.
(WebCore::removeCSSPropertyFromTarget): Deleted.
(WebCore::applyCSSPropertyToTargetAndInstances): Deleted.
(WebCore::removeCSSPropertyFromTargetAndInstances): Deleted.
(WebCore::notifyTargetAboutAnimValChange): Deleted.
(WebCore::notifyTargetAndInstancesAboutAnimValChange): Deleted.
(WebCore::SVGAnimateElementBase::animatedPropertyTypeSupportsAddition const): Deleted.
(WebCore::SVGAnimateElementBase::resetAnimatedPropertyType): Deleted.
(WebCore::SVGAnimateElementBase::ensureAnimator): Deleted.

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

(WebCore::SVGAnimateMotionElement::hasValidAttributeType const):
(WebCore::SVGAnimateMotionElement::hasValidAttributeName const):
(WebCore::SVGAnimateMotionElement::hasValidAttributeType): Deleted.
(WebCore::SVGAnimateMotionElement::hasValidAttributeName): Deleted.

  • svg/SVGAnimateMotionElement.h:
  • svg/SVGAnimateTransformElement.cpp:

(WebCore::SVGAnimateTransformElement::hasValidAttributeType const):
(WebCore::SVGAnimateTransformElement::hasValidAttributeType): Deleted.

  • svg/SVGAnimateTransformElement.h:
  • svg/SVGAnimatedInteger.cpp: Removed.
  • svg/SVGAnimatedInteger.h: Removed.
  • svg/SVGAnimatedIntegerOptionalInteger.cpp: Removed.
  • svg/SVGAnimatedIntegerOptionalInteger.h: Removed.
  • svg/SVGAnimatedPointList.h:
  • svg/SVGAnimationElement.cpp:

(WebCore::SVGAnimationElement::setAttributeType):
(WebCore::SVGAnimationElement::resetAnimation):
(WebCore::SVGAnimationElement::resetAnimatedPropertyType): Deleted.
(WebCore::SVGAnimationElement::setTargetElement): Deleted.
(WebCore::SVGAnimationElement::checkInvalidCSSAttributeType): Deleted.

  • svg/SVGAnimationElement.h:

(WebCore::SVGAnimationElement::attributeType const):
(WebCore::SVGAnimationElement::hasInvalidCSSAttributeType const): Deleted.

  • svg/SVGAnimatorFactory.h:

(WebCore::SVGAnimatorFactory::create):

  • svg/SVGAttributeAnimationController.cpp: Added.

(WebCore::SVGAttributeAnimationController::SVGAttributeAnimationController):
(WebCore::SVGAttributeAnimationController::animator const):
(WebCore::SVGAttributeAnimationController::isDiscreteAnimator const):
(WebCore::SVGAttributeAnimationController::isAdditive const):
(WebCore::SVGAttributeAnimationController::hasValidAttributeType const):
(WebCore::SVGAttributeAnimationController::calculateFromAndToValues):
(WebCore::SVGAttributeAnimationController::calculateFromAndByValues):
(WebCore::SVGAttributeAnimationController::calculateToAtEndOfDurationValue):
(WebCore::SVGAttributeAnimationController::resetAnimatedType):
(WebCore::SVGAttributeAnimationController::calculateAnimatedValue):
(WebCore::SVGAttributeAnimationController::applyResultsToTarget):
(WebCore::SVGAttributeAnimationController::clearAnimatedType):
(WebCore::SVGAttributeAnimationController::calculateDistance):

  • svg/SVGAttributeAnimationController.h: Added.

(WebCore::SVGAttributeAnimationController::animatorIfExists const):

  • svg/SVGAttributeAnimationControllerBase.cpp: Added.

(WebCore::SVGAttributeAnimationControllerBase::SVGAttributeAnimationControllerBase):
(WebCore::SVGAttributeAnimationControllerBase::determineAnimatedPropertyType):

  • svg/SVGAttributeAnimationControllerBase.h: Added.
  • svg/SVGElement.cpp:

(WebCore::SVGElement::synchronizeAllAnimatedSVGAttribute):
(WebCore::SVGElement::synchronizeAnimatedSVGAttribute const):
(WebCore::SVGElement::commitPropertyChange):
(WebCore::SVGElement::isAnimatedPropertyAttribute const):
(WebCore::SVGElement::isAnimatedAttribute const):
(WebCore::SVGElement::createAnimator):

  • svg/SVGElement.h:

(WebCore::SVGElement::propertyRegistry const):

  • svg/SVGFEConvolveMatrixElement.cpp:

(WebCore::SVGFEConvolveMatrixElement::SVGFEConvolveMatrixElement):
(WebCore::SVGFEConvolveMatrixElement::registerAttributes):
(WebCore::SVGFEConvolveMatrixElement::parseAttribute):
(WebCore::SVGFEConvolveMatrixElement::setOrder):
(WebCore::SVGFEConvolveMatrixElement::orderXIdentifier): Deleted.
(WebCore::SVGFEConvolveMatrixElement::orderYIdentifier): Deleted.

  • svg/SVGFEConvolveMatrixElement.h:
  • svg/SVGFETurbulenceElement.cpp:

(WebCore::SVGFETurbulenceElement::SVGFETurbulenceElement):
(WebCore::SVGFETurbulenceElement::registerAttributes):
(WebCore::SVGFETurbulenceElement::parseAttribute):
(WebCore::SVGFETurbulenceElement::svgAttributeChanged):

  • svg/SVGFETurbulenceElement.h:
  • svg/SVGFilterElement.h:
  • svg/SVGLegacyAttributeAnimationController.cpp: Added.

(WebCore::SVGLegacyAttributeAnimationController::SVGLegacyAttributeAnimationController):
(WebCore::SVGLegacyAttributeAnimationController::animatedTypeAnimator):
(WebCore::SVGLegacyAttributeAnimationController::isAdditive const):
(WebCore::SVGLegacyAttributeAnimationController::hasValidAttributeType const):
(WebCore::SVGLegacyAttributeAnimationController::calculateFromAndToValues):
(WebCore::SVGLegacyAttributeAnimationController::calculateFromAndByValues):
(WebCore::SVGLegacyAttributeAnimationController::calculateToAtEndOfDurationValue):
(WebCore::propertyTypesAreConsistent):
(WebCore::SVGLegacyAttributeAnimationController::resetAnimatedType):
(WebCore::SVGLegacyAttributeAnimationController::calculateAnimatedValue):
(WebCore::applyCSSPropertyToTarget):
(WebCore::removeCSSPropertyFromTarget):
(WebCore::applyCSSPropertyToTargetAndInstances):
(WebCore::removeCSSPropertyFromTargetAndInstances):
(WebCore::notifyTargetAboutAnimValChange):
(WebCore::notifyTargetAndInstancesAboutAnimValChange):
(WebCore::SVGLegacyAttributeAnimationController::applyResultsToTarget):
(WebCore::SVGLegacyAttributeAnimationController::clearAnimatedType):
(WebCore::SVGLegacyAttributeAnimationController::calculateDistance):

  • svg/SVGLegacyAttributeAnimationController.h: Added.
  • svg/animation/SVGSMILElement.cpp:

(WebCore::SVGSMILElement::hasValidAttributeName const):
(WebCore::SVGSMILElement::hasValidAttributeName): Deleted.

  • svg/animation/SVGSMILElement.h:
  • svg/properties/SVGAnimatedPrimitiveProperty.h: Added.

(WebCore::SVGAnimatedPrimitiveProperty::create):
(WebCore::SVGAnimatedPrimitiveProperty::setBaseVal):
(WebCore::SVGAnimatedPrimitiveProperty::setBaseValInternal):
(WebCore::SVGAnimatedPrimitiveProperty::baseVal const):
(WebCore::SVGAnimatedPrimitiveProperty::setAnimVal):
(WebCore::SVGAnimatedPrimitiveProperty::animVal const):
(WebCore::SVGAnimatedPrimitiveProperty::animVal):
(WebCore::SVGAnimatedPrimitiveProperty::currentValue const):
(WebCore::SVGAnimatedPrimitiveProperty::SVGAnimatedPrimitiveProperty):

  • svg/properties/SVGAnimatedProperty.cpp: Added.

(WebCore::SVGAnimatedProperty::owner const):
(WebCore::SVGAnimatedProperty::commitPropertyChange):

  • svg/properties/SVGAnimatedProperty.h: Added.

(WebCore::SVGAnimatedProperty::isAttached const):
(WebCore::SVGAnimatedProperty::detach):
(WebCore::SVGAnimatedProperty::contextElement const):
(WebCore::SVGAnimatedProperty::baseValAsString const):
(WebCore::SVGAnimatedProperty::animValAsString const):
(WebCore::SVGAnimatedProperty::isDirty const):
(WebCore::SVGAnimatedProperty::setDirty):
(WebCore::SVGAnimatedProperty::synchronize):
(WebCore::SVGAnimatedProperty::isAnimating const):
(WebCore::SVGAnimatedProperty::startAnimation):
(WebCore::SVGAnimatedProperty::stopAnimation):
(WebCore::SVGAnimatedProperty::instanceStartAnimation):
(WebCore::SVGAnimatedProperty::instanceStopAnimation):
(WebCore::SVGAnimatedProperty::SVGAnimatedProperty):

  • svg/properties/SVGAnimatedPropertyAccessor.h: Added.
  • svg/properties/SVGAnimatedPropertyAccessorImpl.h: Added.
  • svg/properties/SVGAnimatedPropertyAnimator.h: Added.

(WebCore::SVGAnimatedPropertyAnimator::appendAnimatedInstance):
(WebCore::SVGAnimatedPropertyAnimator::SVGAnimatedPropertyAnimator):

  • svg/properties/SVGAnimatedPropertyAnimatorImpl.h: Added.
  • svg/properties/SVGAnimatedPropertyImpl.h: Added.
  • svg/properties/SVGAnimatedPropertyPairAccessor.h: Added.

(WebCore::SVGAnimatedPropertyPairAccessor::SVGAnimatedPropertyPairAccessor):
(WebCore::SVGAnimatedPropertyPairAccessor::singleton):
(WebCore::SVGAnimatedPropertyPairAccessor::property1 const):
(WebCore::SVGAnimatedPropertyPairAccessor::property2 const):

  • svg/properties/SVGAnimatedPropertyPairAccessorImpl.h: Added.
  • svg/properties/SVGAnimatedPropertyPairAnimator.h: Added.

(WebCore::SVGAnimatedPropertyPairAnimator::appendAnimatedInstance):
(WebCore::SVGAnimatedPropertyPairAnimator::SVGAnimatedPropertyPairAnimator):

  • svg/properties/SVGAnimatedPropertyPairAnimatorImpl.h: Added.
  • svg/properties/SVGAnimationAdditiveFunction.h: Added.

(WebCore::SVGAnimationAdditiveFunction::SVGAnimationAdditiveFunction):
(WebCore::SVGAnimationAdditiveFunction::progress):

  • svg/properties/SVGAnimationAdditiveValueFunction.h: Added.

(WebCore::SVGAnimationAdditiveValueFunction::toAtEndOfDuration const):

  • svg/properties/SVGAnimationAdditiveValueFunctionImpl.h: Added.

(WebCore::SVGAnimationIntegerFunction::progress):

  • svg/properties/SVGAnimationFunction.h: Added.

(WebCore::SVGAnimationFunction::isDiscrete const):
(WebCore::SVGAnimationFunction::calculateDistance const):
(WebCore::SVGAnimationFunction::SVGAnimationFunction):
(WebCore::SVGAnimationFunction::addFromAndToValues):

  • svg/properties/SVGAttributeAnimator.cpp: Added.

(WebCore::SVGAttributeAnimator::applyAnimatedPropertyChange):

  • svg/properties/SVGAttributeAnimator.h: Added.

(WebCore::SVGAttributeAnimator::SVGAttributeAnimator):
(WebCore::SVGAttributeAnimator::isDiscrete const):
(WebCore::SVGAttributeAnimator::setFromAndToValues):
(WebCore::SVGAttributeAnimator::setFromAndByValues):
(WebCore::SVGAttributeAnimator::setToAtEndOfDurationValue):
(WebCore::SVGAttributeAnimator::calculateDistance const):

  • svg/properties/SVGAttributeOwnerProxy.cpp:
  • svg/properties/SVGAttributeOwnerProxy.h:
  • svg/properties/SVGAttributeRegistry.h:
  • svg/properties/SVGMemberAccessor.h: Added.

(WebCore::SVGMemberAccessor::detach const):
(WebCore::SVGMemberAccessor::isAnimatedProperty const):
(WebCore::SVGMemberAccessor::isAnimatedLength const):
(WebCore::SVGMemberAccessor::matches const):
(WebCore::SVGMemberAccessor::synchronize const):
(WebCore::SVGMemberAccessor::createAnimator const):
(WebCore::SVGMemberAccessor::appendAnimatedInstance const):

  • svg/properties/SVGPointerMemberAccessor.h: Added.

(WebCore::SVGPointerMemberAccessor::SVGPointerMemberAccessor):
(WebCore::SVGPointerMemberAccessor::property const):
(WebCore::SVGPointerMemberAccessor::singleton):

  • svg/properties/SVGProperty.h: Added.
  • svg/properties/SVGPropertyOwner.h: Added.

(WebCore::SVGPropertyOwner::owner const):
(WebCore::SVGPropertyOwner::attributeContextElement const):
(WebCore::SVGPropertyOwner::commitPropertyChange):

  • svg/properties/SVGPropertyOwnerRegistry.h: Added.

(WebCore::SVGPropertyOwnerRegistry::SVGPropertyOwnerRegistry):
(WebCore::SVGPropertyOwnerRegistry::registerProperty):
(WebCore::SVGPropertyOwnerRegistry::enumerateRecursively):
(WebCore::SVGPropertyOwnerRegistry::isKnownAttribute):
(WebCore::SVGPropertyOwnerRegistry::enumerateRecursivelyBaseTypes):
(WebCore::SVGPropertyOwnerRegistry::findAccessor):

  • svg/properties/SVGPropertyRegistry.h: Added.
Location:
trunk/Source/WebCore
Files:
13 added
4 deleted
26 edited
17 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r243035 r243036  
     12019-03-16  Said Abou-Hallawa  <sabouhallawa@apple.com>
     2
     3        Remove the SVG property tear off objects for SVGAnimatedInteger
     4        https://bugs.webkit.org/show_bug.cgi?id=195722
     5
     6        Reviewed by Simon Fraser.
     7
     8        Instead of saving a raw integer value in the SVGElement and then wrapping
     9        the pointer to this raw data in a tear off object, we will represent the
     10        integer as Ref<SVGAnimatedInteger> in SVGElement. This will make the
     11        representation of the property in IDL file match the C++ header file.
     12
     13        When the DOM requests the SVGAnimatedInteger, we get return a reference
     14        to the new animated property. When the rendering code asks for the current
     15        value of the this animated property, we return the animVal() or the
     16        baseVal() depending on whether the property is animating or not.
     17
     18        A pointer to a member in the SVGElement will be registered along with the
     19        associated attribute name in SVGPropertyRegistry. Registering the property
     20        creates an SVGMemberAccessor and links to the associated attribute. The
     21        function of SVGMemberAccessor is to retrieve the value of the property
     22        given a pointer to an SVGElement.
     23
     24        SVGPropertyRegistry manages all the properties of SVGElement. It takes
     25        into account the inherited properties as well.
     26
     27        SVGElement will have a virtual method called propertyRegistry(). Every
     28        superclass will override this method to return a reference to its registry
     29        which includes all the registered properties of this class and its bases.
     30
     31        One important function of the SVGPropertyRegistry and SVGAccessor is they
     32        create the appropriate SVGAttributeAnimator for this property.
     33
     34        SVGAttributeAnimator is just a connection between the animated property
     35        and SVGAnimationFunction. SVGAnimationFunction calculates the values of
     36        the animated property within a time interval. SVGAnimatedPropertyAnimator
     37        updates animVal of the animated property and invalidates the associated
     38        SVGElement and all the instances that references this element.
     39
     40        The plan is to remove all the SVG tear off objects like what this patch
     41        does for SVGAnimatedInteger. So for a period of time the old code and the
     42        new code will co-exist together. These things to consider when reviewing
     43        this patch:
     44
     45        -- SVGAnimatedElementBase was re-factored to use SVGAttributeAnimationControllerBase
     46        which is inherited by SVGLegacyAttributeAnimationController and
     47        SVGAttributeAnimationController. The tear-off properties code which uses
     48        SVGAnimatedType now lives in SVGLegacyAttributeAnimationController. The
     49        new code was added to SVGAttributeAnimationController. The plan is to
     50        remove the three animation controllers and to move the code of
     51        SVGAttributeAnimationController to SVGAnimatedElementBase when all the tear
     52        off code is removed.
     53
     54        -- SVGElement now keeps two registries one for the tear-off world and the
     55        other for the new world. Eventually we need to get rid of tear-off registry.
     56
     57        -- SVGElement will differentiate between the type of the property by the
     58        the method isAnimatedAttribute().
     59
     60        * Sources.txt:
     61        * WebCore.xcodeproj/project.pbxproj:
     62        * bindings/scripts/CodeGeneratorJS.pm:
     63        (GenerateHeader):
     64        * svg/SVGAnimateElementBase.cpp:
     65        (WebCore::SVGAnimateElementBase::SVGAnimateElementBase):
     66        (WebCore::SVGAnimateElementBase::attributeAnimationController):
     67        (WebCore::SVGAnimateElementBase::attributeAnimationControllerIfExists):
     68        (WebCore::SVGAnimateElementBase::hasValidAttributeType const):
     69        (WebCore::SVGAnimateElementBase::determineAnimatedPropertyType const):
     70        (WebCore::SVGAnimateElementBase::calculateAnimatedValue):
     71        (WebCore::SVGAnimateElementBase::calculateToAtEndOfDurationValue):
     72        (WebCore::SVGAnimateElementBase::calculateFromAndToValues):
     73        (WebCore::SVGAnimateElementBase::calculateFromAndByValues):
     74        (WebCore::SVGAnimateElementBase::resetAnimatedType):
     75        (WebCore::SVGAnimateElementBase::clearAnimatedType):
     76        (WebCore::SVGAnimateElementBase::applyResultsToTarget):
     77        (WebCore::SVGAnimateElementBase::isAdditive const):
     78        (WebCore::SVGAnimateElementBase::calculateDistance):
     79        (WebCore::SVGAnimateElementBase::setTargetElement):
     80        (WebCore::SVGAnimateElementBase::setAttributeName):
     81        (WebCore::SVGAnimateElementBase::resetAnimation):
     82        (WebCore::SVGAnimateElementBase::hasInvalidCSSAttributeType const):
     83        (WebCore::SVGAnimateElementBase::hasValidAttributeType): Deleted.
     84        (WebCore::propertyTypesAreConsistent): Deleted.
     85        (WebCore::applyCSSPropertyToTarget): Deleted.
     86        (WebCore::removeCSSPropertyFromTarget): Deleted.
     87        (WebCore::applyCSSPropertyToTargetAndInstances): Deleted.
     88        (WebCore::removeCSSPropertyFromTargetAndInstances): Deleted.
     89        (WebCore::notifyTargetAboutAnimValChange): Deleted.
     90        (WebCore::notifyTargetAndInstancesAboutAnimValChange): Deleted.
     91        (WebCore::SVGAnimateElementBase::animatedPropertyTypeSupportsAddition const): Deleted.
     92        (WebCore::SVGAnimateElementBase::resetAnimatedPropertyType): Deleted.
     93        (WebCore::SVGAnimateElementBase::ensureAnimator): Deleted.
     94        * svg/SVGAnimateElementBase.h:
     95        * svg/SVGAnimateMotionElement.cpp:
     96        (WebCore::SVGAnimateMotionElement::hasValidAttributeType const):
     97        (WebCore::SVGAnimateMotionElement::hasValidAttributeName const):
     98        (WebCore::SVGAnimateMotionElement::hasValidAttributeType): Deleted.
     99        (WebCore::SVGAnimateMotionElement::hasValidAttributeName): Deleted.
     100        * svg/SVGAnimateMotionElement.h:
     101        * svg/SVGAnimateTransformElement.cpp:
     102        (WebCore::SVGAnimateTransformElement::hasValidAttributeType const):
     103        (WebCore::SVGAnimateTransformElement::hasValidAttributeType): Deleted.
     104        * svg/SVGAnimateTransformElement.h:
     105        * svg/SVGAnimatedInteger.cpp: Removed.
     106        * svg/SVGAnimatedInteger.h: Removed.
     107        * svg/SVGAnimatedIntegerOptionalInteger.cpp: Removed.
     108        * svg/SVGAnimatedIntegerOptionalInteger.h: Removed.
     109        * svg/SVGAnimatedPointList.h:
     110        * svg/SVGAnimationElement.cpp:
     111        (WebCore::SVGAnimationElement::setAttributeType):
     112        (WebCore::SVGAnimationElement::resetAnimation):
     113        (WebCore::SVGAnimationElement::resetAnimatedPropertyType): Deleted.
     114        (WebCore::SVGAnimationElement::setTargetElement): Deleted.
     115        (WebCore::SVGAnimationElement::checkInvalidCSSAttributeType): Deleted.
     116        * svg/SVGAnimationElement.h:
     117        (WebCore::SVGAnimationElement::attributeType const):
     118        (WebCore::SVGAnimationElement::hasInvalidCSSAttributeType const): Deleted.
     119        * svg/SVGAnimatorFactory.h:
     120        (WebCore::SVGAnimatorFactory::create):
     121        * svg/SVGAttributeAnimationController.cpp: Added.
     122        (WebCore::SVGAttributeAnimationController::SVGAttributeAnimationController):
     123        (WebCore::SVGAttributeAnimationController::animator const):
     124        (WebCore::SVGAttributeAnimationController::isDiscreteAnimator const):
     125        (WebCore::SVGAttributeAnimationController::isAdditive const):
     126        (WebCore::SVGAttributeAnimationController::hasValidAttributeType const):
     127        (WebCore::SVGAttributeAnimationController::calculateFromAndToValues):
     128        (WebCore::SVGAttributeAnimationController::calculateFromAndByValues):
     129        (WebCore::SVGAttributeAnimationController::calculateToAtEndOfDurationValue):
     130        (WebCore::SVGAttributeAnimationController::resetAnimatedType):
     131        (WebCore::SVGAttributeAnimationController::calculateAnimatedValue):
     132        (WebCore::SVGAttributeAnimationController::applyResultsToTarget):
     133        (WebCore::SVGAttributeAnimationController::clearAnimatedType):
     134        (WebCore::SVGAttributeAnimationController::calculateDistance):
     135        * svg/SVGAttributeAnimationController.h: Added.
     136        (WebCore::SVGAttributeAnimationController::animatorIfExists const):
     137        * svg/SVGAttributeAnimationControllerBase.cpp: Added.
     138        (WebCore::SVGAttributeAnimationControllerBase::SVGAttributeAnimationControllerBase):
     139        (WebCore::SVGAttributeAnimationControllerBase::determineAnimatedPropertyType):
     140        * svg/SVGAttributeAnimationControllerBase.h: Added.
     141        * svg/SVGElement.cpp:
     142        (WebCore::SVGElement::synchronizeAllAnimatedSVGAttribute):
     143        (WebCore::SVGElement::synchronizeAnimatedSVGAttribute const):
     144        (WebCore::SVGElement::commitPropertyChange):
     145        (WebCore::SVGElement::isAnimatedPropertyAttribute const):
     146        (WebCore::SVGElement::isAnimatedAttribute const):
     147        (WebCore::SVGElement::createAnimator):
     148        * svg/SVGElement.h:
     149        (WebCore::SVGElement::propertyRegistry const):
     150        * svg/SVGFEConvolveMatrixElement.cpp:
     151        (WebCore::SVGFEConvolveMatrixElement::SVGFEConvolveMatrixElement):
     152        (WebCore::SVGFEConvolveMatrixElement::registerAttributes):
     153        (WebCore::SVGFEConvolveMatrixElement::parseAttribute):
     154        (WebCore::SVGFEConvolveMatrixElement::setOrder):
     155        (WebCore::SVGFEConvolveMatrixElement::orderXIdentifier): Deleted.
     156        (WebCore::SVGFEConvolveMatrixElement::orderYIdentifier): Deleted.
     157        * svg/SVGFEConvolveMatrixElement.h:
     158        * svg/SVGFETurbulenceElement.cpp:
     159        (WebCore::SVGFETurbulenceElement::SVGFETurbulenceElement):
     160        (WebCore::SVGFETurbulenceElement::registerAttributes):
     161        (WebCore::SVGFETurbulenceElement::parseAttribute):
     162        (WebCore::SVGFETurbulenceElement::svgAttributeChanged):
     163        * svg/SVGFETurbulenceElement.h:
     164        * svg/SVGFilterElement.h:
     165        * svg/SVGLegacyAttributeAnimationController.cpp: Added.
     166        (WebCore::SVGLegacyAttributeAnimationController::SVGLegacyAttributeAnimationController):
     167        (WebCore::SVGLegacyAttributeAnimationController::animatedTypeAnimator):
     168        (WebCore::SVGLegacyAttributeAnimationController::isAdditive const):
     169        (WebCore::SVGLegacyAttributeAnimationController::hasValidAttributeType const):
     170        (WebCore::SVGLegacyAttributeAnimationController::calculateFromAndToValues):
     171        (WebCore::SVGLegacyAttributeAnimationController::calculateFromAndByValues):
     172        (WebCore::SVGLegacyAttributeAnimationController::calculateToAtEndOfDurationValue):
     173        (WebCore::propertyTypesAreConsistent):
     174        (WebCore::SVGLegacyAttributeAnimationController::resetAnimatedType):
     175        (WebCore::SVGLegacyAttributeAnimationController::calculateAnimatedValue):
     176        (WebCore::applyCSSPropertyToTarget):
     177        (WebCore::removeCSSPropertyFromTarget):
     178        (WebCore::applyCSSPropertyToTargetAndInstances):
     179        (WebCore::removeCSSPropertyFromTargetAndInstances):
     180        (WebCore::notifyTargetAboutAnimValChange):
     181        (WebCore::notifyTargetAndInstancesAboutAnimValChange):
     182        (WebCore::SVGLegacyAttributeAnimationController::applyResultsToTarget):
     183        (WebCore::SVGLegacyAttributeAnimationController::clearAnimatedType):
     184        (WebCore::SVGLegacyAttributeAnimationController::calculateDistance):
     185        * svg/SVGLegacyAttributeAnimationController.h: Added.
     186        * svg/animation/SVGSMILElement.cpp:
     187        (WebCore::SVGSMILElement::hasValidAttributeName const):
     188        (WebCore::SVGSMILElement::hasValidAttributeName): Deleted.
     189        * svg/animation/SVGSMILElement.h:
     190        * svg/properties/SVGAnimatedPrimitiveProperty.h: Added.
     191        (WebCore::SVGAnimatedPrimitiveProperty::create):
     192        (WebCore::SVGAnimatedPrimitiveProperty::setBaseVal):
     193        (WebCore::SVGAnimatedPrimitiveProperty::setBaseValInternal):
     194        (WebCore::SVGAnimatedPrimitiveProperty::baseVal const):
     195        (WebCore::SVGAnimatedPrimitiveProperty::setAnimVal):
     196        (WebCore::SVGAnimatedPrimitiveProperty::animVal const):
     197        (WebCore::SVGAnimatedPrimitiveProperty::animVal):
     198        (WebCore::SVGAnimatedPrimitiveProperty::currentValue const):
     199        (WebCore::SVGAnimatedPrimitiveProperty::SVGAnimatedPrimitiveProperty):
     200        * svg/properties/SVGAnimatedProperty.cpp: Added.
     201        (WebCore::SVGAnimatedProperty::owner const):
     202        (WebCore::SVGAnimatedProperty::commitPropertyChange):
     203        * svg/properties/SVGAnimatedProperty.h: Added.
     204        (WebCore::SVGAnimatedProperty::isAttached const):
     205        (WebCore::SVGAnimatedProperty::detach):
     206        (WebCore::SVGAnimatedProperty::contextElement const):
     207        (WebCore::SVGAnimatedProperty::baseValAsString const):
     208        (WebCore::SVGAnimatedProperty::animValAsString const):
     209        (WebCore::SVGAnimatedProperty::isDirty const):
     210        (WebCore::SVGAnimatedProperty::setDirty):
     211        (WebCore::SVGAnimatedProperty::synchronize):
     212        (WebCore::SVGAnimatedProperty::isAnimating const):
     213        (WebCore::SVGAnimatedProperty::startAnimation):
     214        (WebCore::SVGAnimatedProperty::stopAnimation):
     215        (WebCore::SVGAnimatedProperty::instanceStartAnimation):
     216        (WebCore::SVGAnimatedProperty::instanceStopAnimation):
     217        (WebCore::SVGAnimatedProperty::SVGAnimatedProperty):
     218        * svg/properties/SVGAnimatedPropertyAccessor.h: Added.
     219        * svg/properties/SVGAnimatedPropertyAccessorImpl.h: Added.
     220        * svg/properties/SVGAnimatedPropertyAnimator.h: Added.
     221        (WebCore::SVGAnimatedPropertyAnimator::appendAnimatedInstance):
     222        (WebCore::SVGAnimatedPropertyAnimator::SVGAnimatedPropertyAnimator):
     223        * svg/properties/SVGAnimatedPropertyAnimatorImpl.h: Added.
     224        * svg/properties/SVGAnimatedPropertyImpl.h: Added.
     225        * svg/properties/SVGAnimatedPropertyPairAccessor.h: Added.
     226        (WebCore::SVGAnimatedPropertyPairAccessor::SVGAnimatedPropertyPairAccessor):
     227        (WebCore::SVGAnimatedPropertyPairAccessor::singleton):
     228        (WebCore::SVGAnimatedPropertyPairAccessor::property1 const):
     229        (WebCore::SVGAnimatedPropertyPairAccessor::property2 const):
     230        * svg/properties/SVGAnimatedPropertyPairAccessorImpl.h: Added.
     231        * svg/properties/SVGAnimatedPropertyPairAnimator.h: Added.
     232        (WebCore::SVGAnimatedPropertyPairAnimator::appendAnimatedInstance):
     233        (WebCore::SVGAnimatedPropertyPairAnimator::SVGAnimatedPropertyPairAnimator):
     234        * svg/properties/SVGAnimatedPropertyPairAnimatorImpl.h: Added.
     235        * svg/properties/SVGAnimationAdditiveFunction.h: Added.
     236        (WebCore::SVGAnimationAdditiveFunction::SVGAnimationAdditiveFunction):
     237        (WebCore::SVGAnimationAdditiveFunction::progress):
     238        * svg/properties/SVGAnimationAdditiveValueFunction.h: Added.
     239        (WebCore::SVGAnimationAdditiveValueFunction::toAtEndOfDuration const):
     240        * svg/properties/SVGAnimationAdditiveValueFunctionImpl.h: Added.
     241        (WebCore::SVGAnimationIntegerFunction::progress):
     242        * svg/properties/SVGAnimationFunction.h: Added.
     243        (WebCore::SVGAnimationFunction::isDiscrete const):
     244        (WebCore::SVGAnimationFunction::calculateDistance const):
     245        (WebCore::SVGAnimationFunction::SVGAnimationFunction):
     246        (WebCore::SVGAnimationFunction::addFromAndToValues):
     247        * svg/properties/SVGAttributeAnimator.cpp: Added.
     248        (WebCore::SVGAttributeAnimator::applyAnimatedPropertyChange):
     249        * svg/properties/SVGAttributeAnimator.h: Added.
     250        (WebCore::SVGAttributeAnimator::SVGAttributeAnimator):
     251        (WebCore::SVGAttributeAnimator::isDiscrete const):
     252        (WebCore::SVGAttributeAnimator::setFromAndToValues):
     253        (WebCore::SVGAttributeAnimator::setFromAndByValues):
     254        (WebCore::SVGAttributeAnimator::setToAtEndOfDurationValue):
     255        (WebCore::SVGAttributeAnimator::calculateDistance const):
     256        * svg/properties/SVGAttributeOwnerProxy.cpp:
     257        * svg/properties/SVGAttributeOwnerProxy.h:
     258        * svg/properties/SVGAttributeRegistry.h:
     259        * svg/properties/SVGMemberAccessor.h: Added.
     260        (WebCore::SVGMemberAccessor::detach const):
     261        (WebCore::SVGMemberAccessor::isAnimatedProperty const):
     262        (WebCore::SVGMemberAccessor::isAnimatedLength const):
     263        (WebCore::SVGMemberAccessor::matches const):
     264        (WebCore::SVGMemberAccessor::synchronize const):
     265        (WebCore::SVGMemberAccessor::createAnimator const):
     266        (WebCore::SVGMemberAccessor::appendAnimatedInstance const):
     267        * svg/properties/SVGPointerMemberAccessor.h: Added.
     268        (WebCore::SVGPointerMemberAccessor::SVGPointerMemberAccessor):
     269        (WebCore::SVGPointerMemberAccessor::property const):
     270        (WebCore::SVGPointerMemberAccessor::singleton):
     271        * svg/properties/SVGProperty.h: Added.
     272        * svg/properties/SVGPropertyOwner.h: Added.
     273        (WebCore::SVGPropertyOwner::owner const):
     274        (WebCore::SVGPropertyOwner::attributeContextElement const):
     275        (WebCore::SVGPropertyOwner::commitPropertyChange):
     276        * svg/properties/SVGPropertyOwnerRegistry.h: Added.
     277        (WebCore::SVGPropertyOwnerRegistry::SVGPropertyOwnerRegistry):
     278        (WebCore::SVGPropertyOwnerRegistry::registerProperty):
     279        (WebCore::SVGPropertyOwnerRegistry::enumerateRecursively):
     280        (WebCore::SVGPropertyOwnerRegistry::isKnownAttribute):
     281        (WebCore::SVGPropertyOwnerRegistry::enumerateRecursivelyBaseTypes):
     282        (WebCore::SVGPropertyOwnerRegistry::findAccessor):
     283        * svg/properties/SVGPropertyRegistry.h: Added.
     284
    12852019-03-16  Ryosuke Niwa  <rniwa@webkit.org>
    2286
  • trunk/Source/WebCore/Sources.txt

    r243014 r243036  
    22742274svg/SVGAnimatedColor.cpp
    22752275svg/SVGAnimatedEnumeration.cpp
    2276 svg/SVGAnimatedInteger.cpp
    2277 svg/SVGAnimatedIntegerOptionalInteger.cpp
    22782276svg/SVGAnimatedLength.cpp
    22792277svg/SVGAnimatedLengthList.cpp
     
    22892287svg/SVGAnimatedTypeAnimator.cpp
    22902288svg/SVGAnimationElement.cpp
     2289svg/SVGAttributeAnimationController.cpp
     2290svg/SVGAttributeAnimationControllerBase.cpp
    22912291svg/SVGCircleElement.cpp
    22922292svg/SVGClipPathElement.cpp
     
    23462346svg/SVGImageLoader.cpp
    23472347svg/SVGLangSpace.cpp
     2348svg/SVGLegacyAttributeAnimationController.cpp
    23482349svg/SVGLengthContext.cpp
    23492350svg/SVGLengthListValues.cpp
     
    24252426
    24262427svg/properties/SVGAnimatedPathSegListPropertyTearOff.cpp
     2428svg/properties/SVGAnimatedProperty.cpp
     2429svg/properties/SVGAttributeAnimator.cpp
    24272430svg/properties/SVGAttributeOwnerProxy.cpp
    24282431svg/properties/SVGLegacyAnimatedProperty.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r243014 r243036  
    243243                081AA8DA1111237E002AB06E /* SVGElementRareData.h in Headers */ = {isa = PBXBuildFile; fileRef = 081AA8D91111237E002AB06E /* SVGElementRareData.h */; };
    244244                081EBF3B0FD34F4100DA7559 /* SVGFilterBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 081EBF390FD34F4100DA7559 /* SVGFilterBuilder.h */; };
    245                 0823D159127AD6AC000EBC95 /* SVGAnimatedInteger.h in Headers */ = {isa = PBXBuildFile; fileRef = 0823D158127AD6AC000EBC95 /* SVGAnimatedInteger.h */; };
    246245                08250939128BD4D800E2ED8E /* SVGAnimatedTransformList.h in Headers */ = {isa = PBXBuildFile; fileRef = 08250938128BD4D800E2ED8E /* SVGAnimatedTransformList.h */; };
    247246                082DE42D1292621600D923DF /* SVGPathSegWithContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 082DE42C1292621600D923DF /* SVGPathSegWithContext.h */; };
     
    21372136                71E2183A17359FB8006E6E4D /* PlugInsResources.h in Headers */ = {isa = PBXBuildFile; fileRef = 71E2183817359FB8006E6E4D /* PlugInsResources.h */; };
    21382137                71E2C42621C935280024F8C8 /* AnimationEffectPhase.h in Headers */ = {isa = PBXBuildFile; fileRef = 71E2C42421C9351D0024F8C8 /* AnimationEffectPhase.h */; settings = {ATTRIBUTES = (Private, ); }; };
    2139                 71E623D1151F72A60036E2F4 /* SVGAnimatedIntegerOptionalInteger.h in Headers */ = {isa = PBXBuildFile; fileRef = 71E623CF151F72A60036E2F4 /* SVGAnimatedIntegerOptionalInteger.h */; };
    21402138                71EADCD822087E720065A45F /* PointerID.h in Headers */ = {isa = PBXBuildFile; fileRef = 71EADCD622087E6D0065A45F /* PointerID.h */; settings = {ATTRIBUTES = (Private, ); }; };
    21412139                71EFCEDC202B38A900D7C411 /* AnimationEffect.h in Headers */ = {isa = PBXBuildFile; fileRef = 71EFCED7202B388D00D7C411 /* AnimationEffect.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    56065604                081EBF380FD34F4100DA7559 /* SVGFilterBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGFilterBuilder.cpp; sourceTree = "<group>"; };
    56075605                081EBF390FD34F4100DA7559 /* SVGFilterBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGFilterBuilder.h; sourceTree = "<group>"; };
    5608                 0823D158127AD6AC000EBC95 /* SVGAnimatedInteger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedInteger.h; sourceTree = "<group>"; };
    56095606                08250938128BD4D800E2ED8E /* SVGAnimatedTransformList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedTransformList.h; sourceTree = "<group>"; };
    56105607                082DE42C1292621600D923DF /* SVGPathSegWithContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathSegWithContext.h; sourceTree = "<group>"; };
     
    76937690                43EDD67C1B485DBF00640E75 /* CombinedFiltersAlphabet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CombinedFiltersAlphabet.cpp; sourceTree = "<group>"; };
    76947691                43EDD67D1B485DBF00640E75 /* CombinedFiltersAlphabet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CombinedFiltersAlphabet.h; sourceTree = "<group>"; };
    7695                 43F6FD9513BCD0B100224052 /* SVGAnimatedInteger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedInteger.cpp; sourceTree = "<group>"; };
    76967692                4415292C0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLPlugInImageElement.h; sourceTree = "<group>"; };
    76977693                4415292D0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLPlugInImageElement.cpp; sourceTree = "<group>"; };
     
    86738669                55AF14E31EAAC59B0026EEAA /* UTIRegistry.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = UTIRegistry.cpp; sourceTree = "<group>"; };
    86748670                55AF14E41EAAC59B0026EEAA /* UTIRegistry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UTIRegistry.h; sourceTree = "<group>"; };
     8671                55BE0257223B29C00032F08A /* SVGPropertyRegistry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPropertyRegistry.h; sourceTree = "<group>"; };
     8672                55BE0259223B29C10032F08A /* SVGAnimationAdditiveValueFunctionImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimationAdditiveValueFunctionImpl.h; sourceTree = "<group>"; };
     8673                55BE025A223B29C20032F08A /* SVGPointerMemberAccessor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPointerMemberAccessor.h; sourceTree = "<group>"; };
     8674                55BE025B223B29C20032F08A /* SVGAnimationFunction.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimationFunction.h; sourceTree = "<group>"; };
     8675                55BE025C223B29C30032F08A /* SVGPropertyOwnerRegistry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPropertyOwnerRegistry.h; sourceTree = "<group>"; };
     8676                55BE025D223B29C40032F08A /* SVGAnimatedProperty.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedProperty.cpp; sourceTree = "<group>"; };
     8677                55BE025E223B29C40032F08A /* SVGAnimatedPropertyPairAccessor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyPairAccessor.h; sourceTree = "<group>"; };
     8678                55BE025F223B29C50032F08A /* SVGAnimationAdditiveFunction.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimationAdditiveFunction.h; sourceTree = "<group>"; };
    86758679                55D408F71A7C631800C78450 /* SVGImageClients.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGImageClients.h; sourceTree = "<group>"; };
    86768680                55D70D20223B009100044B8E /* SVGLegacyAnimatedProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGLegacyAnimatedProperty.h; sourceTree = "<group>"; };
     
    86788682                55D70D22223B00EA00044B8E /* SVGLegacyProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGLegacyProperty.h; sourceTree = "<group>"; };
    86798683                55EC95972069C92D007DD0A9 /* PaintFrequencyTracker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PaintFrequencyTracker.h; sourceTree = "<group>"; };
     8684                55EE5354223B29E900FBA944 /* SVGMemberAccessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGMemberAccessor.h; sourceTree = "<group>"; };
     8685                55EE5356223B29F700FBA944 /* SVGAnimatedPropertyAnimatorImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyAnimatorImpl.h; sourceTree = "<group>"; };
     8686                55EE5357223B29F800FBA944 /* SVGAnimatedPrimitiveProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPrimitiveProperty.h; sourceTree = "<group>"; };
     8687                55EE5358223B29F900FBA944 /* SVGAnimatedPropertyAccessorImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyAccessorImpl.h; sourceTree = "<group>"; };
     8688                55EE5359223B29FA00FBA944 /* SVGAnimatedPropertyAccessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyAccessor.h; sourceTree = "<group>"; };
     8689                55EE535A223B29FB00FBA944 /* SVGAnimatedPropertyAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyAnimator.h; sourceTree = "<group>"; };
     8690                55EE535B223B2A0C00FBA944 /* SVGAnimatedPropertyPairAnimatorImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyPairAnimatorImpl.h; sourceTree = "<group>"; };
     8691                55EE535C223B2A0D00FBA944 /* SVGAnimatedPropertyImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyImpl.h; sourceTree = "<group>"; };
     8692                55EE535D223B2A0D00FBA944 /* SVGAnimatedPropertyPairAccessorImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyPairAccessorImpl.h; sourceTree = "<group>"; };
     8693                55EE535E223B2A0E00FBA944 /* SVGAnimationAdditiveValueFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimationAdditiveValueFunction.h; sourceTree = "<group>"; };
     8694                55EE535F223B2A0F00FBA944 /* SVGAnimatedPropertyPairAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyPairAnimator.h; sourceTree = "<group>"; };
     8695                55EE5360223B2A2100FBA944 /* SVGPropertyOwner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPropertyOwner.h; sourceTree = "<group>"; };
     8696                55EE5361223B2A2200FBA944 /* SVGAttributeAnimator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAttributeAnimator.cpp; sourceTree = "<group>"; };
     8697                55EE5362223B2A2300FBA944 /* SVGAnimatedProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedProperty.h; sourceTree = "<group>"; };
     8698                55EE5363223B2A2400FBA944 /* SVGProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGProperty.h; sourceTree = "<group>"; };
     8699                55EE5364223B2A2400FBA944 /* SVGAttributeAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAttributeAnimator.h; sourceTree = "<group>"; };
    86808700                55FA7FEF210FA386005AEFE7 /* SVGAttribute.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAttribute.h; sourceTree = "<group>"; };
    86818701                55FA7FF4210FB688005AEFE7 /* SVGAttributeAccessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAttributeAccessor.h; sourceTree = "<group>"; };
     
    94809500                71E2183917359FB8006E6E4D /* PlugInsResourcesData.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = PlugInsResourcesData.cpp; path = DerivedSources/WebCore/PlugInsResourcesData.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
    94819501                71E2C42421C9351D0024F8C8 /* AnimationEffectPhase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationEffectPhase.h; sourceTree = "<group>"; };
    9482                 71E623CE151F72A60036E2F4 /* SVGAnimatedIntegerOptionalInteger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedIntegerOptionalInteger.cpp; sourceTree = "<group>"; };
    9483                 71E623CF151F72A60036E2F4 /* SVGAnimatedIntegerOptionalInteger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedIntegerOptionalInteger.h; sourceTree = "<group>"; };
    94849502                71EADCD622087E6D0065A45F /* PointerID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PointerID.h; sourceTree = "<group>"; };
    94859503                71EFCED6202B388C00D7C411 /* AnimationEffect.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AnimationEffect.idl; sourceTree = "<group>"; };
     
    94899507                71F936F71DD4F99B00922CC7 /* tracks-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "tracks-support.js"; sourceTree = "<group>"; };
    94909508                71FB967A1383D64600AC8A4C /* SVGAnimatedEnumerationPropertyTearOff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedEnumerationPropertyTearOff.h; sourceTree = "<group>"; };
     9509                723F97BC2238EE08007F079C /* SVGAttributeAnimationController.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAttributeAnimationController.cpp; sourceTree = "<group>"; };
     9510                723F97BD2238EE08007F079C /* SVGAttributeAnimationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAttributeAnimationController.h; sourceTree = "<group>"; };
     9511                723F97BE2239512D007F079C /* SVGLegacyAttributeAnimationController.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SVGLegacyAttributeAnimationController.cpp; sourceTree = "<group>"; };
     9512                723F97BF2239512D007F079C /* SVGLegacyAttributeAnimationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGLegacyAttributeAnimationController.h; sourceTree = "<group>"; };
     9513                723F97C022396B88007F079C /* SVGAttributeAnimationControllerBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAttributeAnimationControllerBase.h; sourceTree = "<group>"; };
     9514                723F97C122397725007F079C /* SVGAttributeAnimationControllerBase.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAttributeAnimationControllerBase.cpp; sourceTree = "<group>"; };
    94919515                724ED3291A3A7E5400F5F13C /* EXTBlendMinMax.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EXTBlendMinMax.cpp; sourceTree = "<group>"; };
    94929516                724ED32A1A3A7E5400F5F13C /* EXTBlendMinMax.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EXTBlendMinMax.h; sourceTree = "<group>"; };
     
    1618716211                                55FA7FFC2110F813005AEFE7 /* SVGAnimatedPathSegListPropertyTearOff.cpp */,
    1618816212                                089A8E06128D8B3D00E7A534 /* SVGAnimatedPathSegListPropertyTearOff.h */,
     16213                                55EE5357223B29F800FBA944 /* SVGAnimatedPrimitiveProperty.h */,
     16214                                55BE025D223B29C40032F08A /* SVGAnimatedProperty.cpp */,
     16215                                55EE5362223B2A2300FBA944 /* SVGAnimatedProperty.h */,
     16216                                55EE5359223B29FA00FBA944 /* SVGAnimatedPropertyAccessor.h */,
     16217                                55EE5358223B29F900FBA944 /* SVGAnimatedPropertyAccessorImpl.h */,
     16218                                55EE535A223B29FB00FBA944 /* SVGAnimatedPropertyAnimator.h */,
     16219                                55EE5356223B29F700FBA944 /* SVGAnimatedPropertyAnimatorImpl.h */,
    1618916220                                088A0DFD126EF1DB00978F7A /* SVGAnimatedPropertyDescription.h */,
     16221                                55EE535C223B2A0D00FBA944 /* SVGAnimatedPropertyImpl.h */,
     16222                                55BE025E223B29C40032F08A /* SVGAnimatedPropertyPairAccessor.h */,
     16223                                55EE535D223B2A0D00FBA944 /* SVGAnimatedPropertyPairAccessorImpl.h */,
     16224                                55EE535F223B2A0F00FBA944 /* SVGAnimatedPropertyPairAnimator.h */,
     16225                                55EE535B223B2A0C00FBA944 /* SVGAnimatedPropertyPairAnimatorImpl.h */,
    1619016226                                088A0DFF126EF1DB00978F7A /* SVGAnimatedPropertyTearOff.h */,
    1619116227                                55FA7FFE21110E6E005AEFE7 /* SVGAnimatedPropertyType.h */,
    1619216228                                08525E621278C00100A84778 /* SVGAnimatedStaticPropertyTearOff.h */,
    1619316229                                085A15921289A8DD002710E3 /* SVGAnimatedTransformListPropertyTearOff.h */,
     16230                                55BE025F223B29C50032F08A /* SVGAnimationAdditiveFunction.h */,
     16231                                55EE535E223B2A0E00FBA944 /* SVGAnimationAdditiveValueFunction.h */,
     16232                                55BE0259223B29C10032F08A /* SVGAnimationAdditiveValueFunctionImpl.h */,
     16233                                55BE025B223B29C20032F08A /* SVGAnimationFunction.h */,
    1619416234                                55FA7FEF210FA386005AEFE7 /* SVGAttribute.h */,
    1619516235                                55FA7FF4210FB688005AEFE7 /* SVGAttributeAccessor.h */,
     16236                                55EE5361223B2A2200FBA944 /* SVGAttributeAnimator.cpp */,
     16237                                55EE5364223B2A2400FBA944 /* SVGAttributeAnimator.h */,
    1619616238                                7A3EBEAC21BF0921000D043D /* SVGAttributeOwnerProxy.cpp */,
    1619716239                                55346AF021150FAF0059BCDD /* SVGAttributeOwnerProxy.h */,
     
    1620416246                                088A0E00126EF1DB00978F7A /* SVGListPropertyTearOff.h */,
    1620516247                                08CA3D4312894A3800FFF260 /* SVGMatrixTearOff.h */,
     16248                                55EE5354223B29E900FBA944 /* SVGMemberAccessor.h */,
     16249                                55BE025A223B29C20032F08A /* SVGPointerMemberAccessor.h */,
     16250                                55EE5363223B2A2400FBA944 /* SVGProperty.h */,
     16251                                55EE5360223B2A2100FBA944 /* SVGPropertyOwner.h */,
     16252                                55BE025C223B29C30032F08A /* SVGPropertyOwnerRegistry.h */,
     16253                                55BE0257223B29C00032F08A /* SVGPropertyRegistry.h */,
    1620616254                                088A0E02126EF1DB00978F7A /* SVGPropertyTearOff.h */,
    1620716255                                088A0E03126EF1DB00978F7A /* SVGPropertyTraits.h */,
     
    2407424122                                08D46CE2127AD5FC0089694B /* SVGAnimatedEnumeration.h */,
    2407524123                                B22277E80D00BF1F0071B782 /* SVGAnimatedEnumeration.idl */,
    24076                                 43F6FD9513BCD0B100224052 /* SVGAnimatedInteger.cpp */,
    24077                                 0823D158127AD6AC000EBC95 /* SVGAnimatedInteger.h */,
    2407824124                                B22277E90D00BF1F0071B782 /* SVGAnimatedInteger.idl */,
    24079                                 71E623CE151F72A60036E2F4 /* SVGAnimatedIntegerOptionalInteger.cpp */,
    24080                                 71E623CF151F72A60036E2F4 /* SVGAnimatedIntegerOptionalInteger.h */,
    2408124125                                4381763A13A697D4007D1187 /* SVGAnimatedLength.cpp */,
    2408224126                                089021A8126EF5DE0092D5EA /* SVGAnimatedLength.h */,
     
    2412724171                                B22278030D00BF1F0071B782 /* SVGAnimationElement.idl */,
    2412824172                                439D334213A6911C00C20F4F /* SVGAnimatorFactory.h */,
     24173                                723F97BC2238EE08007F079C /* SVGAttributeAnimationController.cpp */,
     24174                                723F97BD2238EE08007F079C /* SVGAttributeAnimationController.h */,
     24175                                723F97C122397725007F079C /* SVGAttributeAnimationControllerBase.cpp */,
     24176                                723F97C022396B88007F079C /* SVGAttributeAnimationControllerBase.h */,
    2412924177                                B22278040D00BF1F0071B782 /* svgattrs.in */,
    2413024178                                B22278050D00BF1F0071B782 /* SVGCircleElement.cpp */,
     
    2429624344                                B22278990D00BF200071B782 /* SVGLangSpace.cpp */,
    2429724345                                B222789A0D00BF200071B782 /* SVGLangSpace.h */,
     24346                                723F97BE2239512D007F079C /* SVGLegacyAttributeAnimationController.cpp */,
     24347                                723F97BF2239512D007F079C /* SVGLegacyAttributeAnimationController.h */,
    2429824348                                7CE58D511DD7B09300128552 /* SVGLength.h */,
    2429924349                                B222789E0D00BF200071B782 /* SVGLength.idl */,
     
    3186331913                                08D46CE3127AD5FC0089694B /* SVGAnimatedEnumeration.h in Headers */,
    3186431914                                71FB967B1383D64600AC8A4C /* SVGAnimatedEnumerationPropertyTearOff.h in Headers */,
    31865                                 0823D159127AD6AC000EBC95 /* SVGAnimatedInteger.h in Headers */,
    31866                                 71E623D1151F72A60036E2F4 /* SVGAnimatedIntegerOptionalInteger.h in Headers */,
    3186731915                                089021A9126EF5DE0092D5EA /* SVGAnimatedLength.h in Headers */,
    3186831916                                089021AD126EF5E90092D5EA /* SVGAnimatedLengthList.h in Headers */,
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r242278 r243036  
    25002500    }
    25012501
    2502     $headerIncludes{"$interfaceName.h"} = 1 if $hasParent && $interface->extendedAttributes->{JSGenerateToNativeObject};
    2503 
    25042502    $headerIncludes{"SVGElement.h"} = 1 if $className =~ /^JSSVG/;
    25052503
     
    25132511
    25142512    if ($codeGenerator->IsSVGAnimatedType($interface->type)) {
    2515         $headerIncludes{"$interfaceName.h"} = 1;
     2513        $headerIncludes{"SVGAnimatedPropertyImpl.h"} = 1;
    25162514    } else {
     2515        $headerIncludes{"$interfaceName.h"} = 1 if $hasParent && $interface->extendedAttributes->{JSGenerateToNativeObject};
    25172516        # Implementation class forward declaration
    25182517        if (IsDOMGlobalObject($interface)) {
     
    25642563        push(@headerContent, "    }\n\n"); 
    25652564    } else {
    2566         AddIncludesForImplementationTypeInHeader($implType);
     2565        if (!$codeGenerator->IsSVGAnimatedType($interface->type)) {
     2566            AddIncludesForImplementationTypeInHeader($implType);
     2567        }
    25672568        push(@headerContent, "    static $className* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, Ref<$implType>&& impl)\n");
    25682569        push(@headerContent, "    {\n");
  • trunk/Source/WebCore/svg/SVGAnimateElementBase.cpp

    r242970 r243036  
    22 * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
    4  * Copyright (C) 2008 Apple Inc. All rights reserved.
     4 * Copyright (C) 2008-2019 Apple Inc. All rights reserved.
    55 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
    66 * Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved.
     
    2525#include "SVGAnimateElementBase.h"
    2626
    27 #include "CSSPropertyNames.h"
    28 #include "CSSPropertyParser.h"
    2927#include "QualifiedName.h"
    30 #include "RenderObject.h"
    31 #include "SVGAnimatorFactory.h"
     28#include "SVGAttributeAnimationController.h"
    3229#include "SVGElement.h"
     30#include "SVGLegacyAttributeAnimationController.h"
    3331#include "SVGNames.h"
    34 #include "StyleProperties.h"
    3532#include <wtf/IsoMallocInlines.h>
    3633
     
    4138SVGAnimateElementBase::SVGAnimateElementBase(const QualifiedName& tagName, Document& document)
    4239    : SVGAnimationElement(tagName, document)
    43     , m_animatedPropertyType(AnimatedString)
    4440{
    4541    ASSERT(hasTagName(SVGNames::animateTag) || hasTagName(SVGNames::setTag) || hasTagName(SVGNames::animateColorTag) || hasTagName(SVGNames::animateTransformTag));
     
    4844SVGAnimateElementBase::~SVGAnimateElementBase() = default;
    4945
    50 bool SVGAnimateElementBase::hasValidAttributeType()
     46SVGAttributeAnimationControllerBase& SVGAnimateElementBase::attributeAnimationController()
    5147{
    52     if (!this->targetElement())
     48    ASSERT(targetElement());
     49    ASSERT(!hasInvalidCSSAttributeType());
     50
     51    if (!m_attributeAnimationController) {
     52        if (targetElement()->isAnimatedPropertyAttribute(attributeName()))
     53            m_attributeAnimationController = std::make_unique<SVGAttributeAnimationController>(*this, *targetElement());
     54        else
     55            m_attributeAnimationController = std::make_unique<SVGLegacyAttributeAnimationController>(*this, *targetElement());
     56    }
     57
     58    return *m_attributeAnimationController;
     59}
     60
     61bool SVGAnimateElementBase::hasValidAttributeType() const
     62{
     63    if (!targetElement() || hasInvalidCSSAttributeType())
    5364        return false;
    5465
    55     return m_animatedPropertyType != AnimatedUnknown && !hasInvalidCSSAttributeType();
     66    if (determineAnimatedPropertyType(*targetElement()) != AnimatedUnknown)
     67        return true;
     68
     69    return targetElement()->isAnimatedPropertyAttribute(attributeName());
    5670}
    5771
    5872AnimatedPropertyType SVGAnimateElementBase::determineAnimatedPropertyType(SVGElement& targetElement) const
    5973{
    60     auto propertyTypes = targetElement.animatedPropertyTypesForAttribute(attributeName());
    61     if (propertyTypes.isEmpty())
    62         return AnimatedUnknown;
    63 
    64     ASSERT(propertyTypes.size() <= 2);
    65     AnimatedPropertyType type = propertyTypes[0];
    66     if (hasTagName(SVGNames::animateColorTag) && type != AnimatedColor)
    67         return AnimatedUnknown;
    68 
    69     // Animations of transform lists are not allowed for <animate> or <set>
    70     // http://www.w3.org/TR/SVG/animate.html#AnimationAttributesAndProperties
    71     if (type == AnimatedTransformList && !hasTagName(SVGNames::animateTransformTag))
    72         return AnimatedUnknown;
    73 
    74     // Fortunately there's just one special case needed here: SVGMarkerElements orientAttr, which
    75     // corresponds to SVGAnimatedAngle orientAngle and SVGAnimatedEnumeration orientType. We have to
    76     // figure out whose value to change here.
    77     if (targetElement.hasTagName(SVGNames::markerTag) && type == AnimatedAngle) {
    78         ASSERT(propertyTypes.size() == 2);
    79         ASSERT(propertyTypes[0] == AnimatedAngle);
    80         ASSERT(propertyTypes[1] == AnimatedEnumeration);
    81     } else if (propertyTypes.size() == 2)
    82         ASSERT(propertyTypes[0] == propertyTypes[1]);
    83 
    84     return type;
     74    return SVGAttributeAnimationControllerBase::determineAnimatedPropertyType(*this, targetElement, attributeName());
    8575}
    8676
    8777void SVGAnimateElementBase::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGSMILElement* resultElement)
    8878{
    89     ASSERT(resultElement);
    90     auto targetElement = makeRefPtr(this->targetElement());
    91     if (!targetElement)
     79    if (!targetElement())
    9280        return;
    93 
    94     const QualifiedName& attributeName = this->attributeName();
    95     ShouldApplyAnimation shouldApply = shouldApplyAnimation(targetElement.get(), attributeName);
    96    
    97     if (shouldApply == DontApplyAnimation)
    98         return;
    99 
    100     ASSERT(m_animatedPropertyType == determineAnimatedPropertyType(*targetElement));
    101 
    102     ASSERT(percentage >= 0 && percentage <= 1);
    103     ASSERT(m_animatedPropertyType != AnimatedTransformList || hasTagName(SVGNames::animateTransformTag));
    104     ASSERT(m_animatedPropertyType != AnimatedUnknown);
    105     ASSERT(m_animator);
    106     ASSERT(m_animator->type() == m_animatedPropertyType);
    107     ASSERT(m_fromType);
    108     ASSERT(m_fromType->type() == m_animatedPropertyType);
    109     ASSERT(m_toType);
    110 
    111     if (shouldApply == ApplyXMLAnimation || shouldApply == ApplyXMLandCSSAnimation) {
    112         // SVG DOM animVal animation code-path.
    113         if (m_animator->findAnimatedPropertiesForAttributeName(*targetElement, attributeName).isEmpty())
    114             return;
    115     }
    116 
    117     SVGAnimateElementBase& resultAnimationElement = downcast<SVGAnimateElementBase>(*resultElement);
    118     ASSERT(resultAnimationElement.m_animatedType);
    119     ASSERT(resultAnimationElement.m_animatedPropertyType == m_animatedPropertyType);
    120 
    121     if (hasTagName(SVGNames::setTag))
    122         percentage = 1;
    123 
    124     if (calcMode() == CalcMode::Discrete)
    125         percentage = percentage < 0.5 ? 0 : 1;
    126 
    127     // Target element might have changed.
    128     m_animator->setContextElement(targetElement.get());
    129 
    130     // Be sure to detach list wrappers before we modfiy their underlying value. If we'd do
    131     // if after calculateAnimatedValue() ran the cached pointers in the list propery tear
    132     // offs would point nowhere, and we couldn't create copies of those values anymore,
    133     // while detaching. This is covered by assertions, moving this down would fire them.
    134     if (!m_animatedProperties.isEmpty())
    135         m_animator->animValWillChange(m_animatedProperties);
    136 
    137     // Values-animation accumulates using the last values entry corresponding to the end of duration time.
    138     SVGAnimatedType* toAtEndOfDurationType = m_toAtEndOfDurationType ? m_toAtEndOfDurationType.get() : m_toType.get();
    139     m_animator->calculateAnimatedValue(percentage, repeatCount, m_fromType.get(), m_toType.get(), toAtEndOfDurationType, resultAnimationElement.m_animatedType.get());
     81    attributeAnimationController().calculateAnimatedValue(percentage, repeatCount, resultElement);
    14082}
    14183
    14284bool SVGAnimateElementBase::calculateToAtEndOfDurationValue(const String& toAtEndOfDurationString)
    14385{
    144     if (toAtEndOfDurationString.isEmpty())
     86    if (!targetElement())
    14587        return false;
    146     m_toAtEndOfDurationType = ensureAnimator()->constructFromString(toAtEndOfDurationString);
    147     return true;
     88    return attributeAnimationController().calculateToAtEndOfDurationValue(toAtEndOfDurationString);
    14889}
    14990
    15091bool SVGAnimateElementBase::calculateFromAndToValues(const String& fromString, const String& toString)
    15192{
    152     if (!this->targetElement())
     93    if (!targetElement())
    15394        return false;
    154 
    155     determinePropertyValueTypes(fromString, toString);
    156     ensureAnimator()->calculateFromAndToValues(m_fromType, m_toType, fromString, toString);
    157     ASSERT(m_animatedPropertyType == m_animator->type());
    158     return true;
     95    return attributeAnimationController().calculateFromAndToValues(fromString, toString);
    15996}
    16097
     
    163100    if (!this->targetElement())
    164101        return false;
    165 
    166     if (animationMode() == AnimationMode::By && !isAdditive())
    167         return false;
    168 
    169     // from-by animation may only be used with attributes that support addition (e.g. most numeric attributes).
    170     if (animationMode() == AnimationMode::FromBy && !animatedPropertyTypeSupportsAddition())
    171         return false;
    172 
    173     ASSERT(!hasTagName(SVGNames::setTag));
    174 
    175     determinePropertyValueTypes(fromString, byString);
    176     ensureAnimator()->calculateFromAndByValues(m_fromType, m_toType, fromString, byString);
    177     ASSERT(m_animatedPropertyType == m_animator->type());
    178     return true;
     102    return attributeAnimationController().calculateFromAndByValues(fromString, byString);
    179103}
    180 
    181 #ifndef NDEBUG
    182 static inline bool propertyTypesAreConsistent(AnimatedPropertyType expectedPropertyType, const SVGElementAnimatedPropertyList& animatedTypes)
    183 {
    184     for (auto& type : animatedTypes) {
    185         for (auto& property : type.properties) {
    186             if (expectedPropertyType != property->animatedPropertyType()) {
    187                 // This is the only allowed inconsistency. SVGAnimatedAngleAnimator handles both SVGAnimatedAngle & SVGAnimatedEnumeration for markers orient attribute.
    188                 if (expectedPropertyType == AnimatedAngle && property->animatedPropertyType() == AnimatedEnumeration)
    189                     return true;
    190                 return false;
    191             }
    192         }
    193     }
    194 
    195     return true;
    196 }
    197 #endif
    198104
    199105void SVGAnimateElementBase::resetAnimatedType()
    200106{
    201     SVGAnimatedTypeAnimator* animator = ensureAnimator();
    202     ASSERT(m_animatedPropertyType == animator->type());
    203 
    204     auto targetElement = makeRefPtr(this->targetElement());
    205     if (!targetElement)
     107    if (!targetElement())
    206108        return;
    207 
    208     const QualifiedName& attributeName = this->attributeName();
    209     ShouldApplyAnimation shouldApply = shouldApplyAnimation(targetElement.get(), attributeName);
    210 
    211     if (shouldApply == DontApplyAnimation)
    212         return;
    213 
    214     if (shouldApply == ApplyXMLAnimation || shouldApply == ApplyXMLandCSSAnimation) {
    215         // SVG DOM animVal animation code-path.
    216         m_animatedProperties = animator->findAnimatedPropertiesForAttributeName(*targetElement, attributeName);
    217         if (m_animatedProperties.isEmpty())
    218             return;
    219 
    220         ASSERT(propertyTypesAreConsistent(m_animatedPropertyType, m_animatedProperties));
    221         if (!m_animatedType)
    222             m_animatedType = animator->startAnimValAnimation(m_animatedProperties);
    223         else {
    224             animator->resetAnimValToBaseVal(m_animatedProperties, *m_animatedType);
    225             animator->animValDidChange(m_animatedProperties);
    226         }
    227         return;
    228     }
    229 
    230     // CSS properties animation code-path.
    231     ASSERT(m_animatedProperties.isEmpty());
    232     String baseValue;
    233 
    234     if (shouldApply == ApplyCSSAnimation) {
    235         ASSERT(SVGAnimationElement::isTargetAttributeCSSProperty(targetElement.get(), attributeName));
    236         computeCSSPropertyValue(targetElement.get(), cssPropertyID(attributeName.localName()), baseValue);
    237     }
    238 
    239     if (!m_animatedType)
    240         m_animatedType = animator->constructFromString(baseValue);
    241     else
    242         m_animatedType->setValueAsString(attributeName, baseValue);
    243 }
    244 
    245 static inline void applyCSSPropertyToTarget(SVGElement& targetElement, CSSPropertyID id, const String& value)
    246 {
    247     ASSERT(!targetElement.m_deletionHasBegun);
    248 
    249     if (!targetElement.ensureAnimatedSMILStyleProperties().setProperty(id, value, false))
    250         return;
    251 
    252     targetElement.invalidateStyle();
    253 }
    254 
    255 static inline void removeCSSPropertyFromTarget(SVGElement& targetElement, CSSPropertyID id)
    256 {
    257     ASSERT(!targetElement.m_deletionHasBegun);
    258     targetElement.ensureAnimatedSMILStyleProperties().removeProperty(id);
    259     targetElement.invalidateStyle();
    260 }
    261 
    262 static inline void applyCSSPropertyToTargetAndInstances(SVGElement& targetElement, const QualifiedName& attributeName, const String& valueAsString)
    263 {
    264     // FIXME: Do we really need to check both isConnected and !parentNode?
    265     if (attributeName == anyQName() || !targetElement.isConnected() || !targetElement.parentNode())
    266         return;
    267 
    268     CSSPropertyID id = cssPropertyID(attributeName.localName());
    269 
    270     SVGElement::InstanceUpdateBlocker blocker(targetElement);
    271     applyCSSPropertyToTarget(targetElement, id, valueAsString);
    272 
    273     // If the target element has instances, update them as well, w/o requiring the <use> tree to be rebuilt.
    274     for (auto* instance : targetElement.instances())
    275         applyCSSPropertyToTarget(*instance, id, valueAsString);
    276 }
    277 
    278 static inline void removeCSSPropertyFromTargetAndInstances(SVGElement& targetElement, const QualifiedName& attributeName)
    279 {
    280     // FIXME: Do we really need to check both isConnected and !parentNode?
    281     if (attributeName == anyQName() || !targetElement.isConnected() || !targetElement.parentNode())
    282         return;
    283 
    284     CSSPropertyID id = cssPropertyID(attributeName.localName());
    285 
    286     SVGElement::InstanceUpdateBlocker blocker(targetElement);
    287     removeCSSPropertyFromTarget(targetElement, id);
    288 
    289     // If the target element has instances, update them as well, w/o requiring the <use> tree to be rebuilt.
    290     for (auto* instance : targetElement.instances())
    291         removeCSSPropertyFromTarget(*instance, id);
    292 }
    293 
    294 static inline void notifyTargetAboutAnimValChange(SVGElement& targetElement, const QualifiedName& attributeName)
    295 {
    296     ASSERT(!targetElement.m_deletionHasBegun);
    297     targetElement.svgAttributeChanged(attributeName);
    298 }
    299 
    300 static inline void notifyTargetAndInstancesAboutAnimValChange(SVGElement& targetElement, const QualifiedName& attributeName)
    301 {
    302     if (attributeName == anyQName() || !targetElement.isConnected() || !targetElement.parentNode())
    303         return;
    304 
    305     SVGElement::InstanceUpdateBlocker blocker(targetElement);
    306     notifyTargetAboutAnimValChange(targetElement, attributeName);
    307 
    308     // If the target element has instances, update them as well, w/o requiring the <use> tree to be rebuilt.
    309     for (auto* instance : targetElement.instances())
    310         notifyTargetAboutAnimValChange(*instance, attributeName);
     109    attributeAnimationController().resetAnimatedType();
    311110}
    312111
    313112void SVGAnimateElementBase::clearAnimatedType(SVGElement* targetElement)
    314113{
    315     if (!m_animatedType)
     114    if (!targetElement)
    316115        return;
    317116
    318     // If the SVGAnimatedType is a list type, e.g. SVGLengthListValues, the wrappers of the
    319     // animated properties have to be detached from the items in the list before it's deleted.
    320     if (!m_animatedProperties.isEmpty())
    321         m_animator->animValWillChange(m_animatedProperties);
    322 
    323     if (!targetElement) {
    324         m_animatedType = nullptr;
    325         return;
    326     }
    327 
    328     if (m_animatedProperties.isEmpty()) {
    329         // CSS properties animation code-path.
    330         removeCSSPropertyFromTargetAndInstances(*targetElement, attributeName());
    331         m_animatedType = nullptr;
    332         return;
    333     }
    334 
    335     ShouldApplyAnimation shouldApply = shouldApplyAnimation(targetElement, attributeName());
    336     if (shouldApply == ApplyXMLandCSSAnimation)
    337         removeCSSPropertyFromTargetAndInstances(*targetElement, attributeName());
    338 
    339     // SVG DOM animVal animation code-path.
    340     if (m_animator) {
    341         m_animator->stopAnimValAnimation(m_animatedProperties);
    342         notifyTargetAndInstancesAboutAnimValChange(*targetElement, attributeName());
    343     }
    344 
    345     m_animatedProperties.clear();
    346     m_animatedType = nullptr;
     117    if (auto* controller = attributeAnimationControllerIfExists())
     118        controller->clearAnimatedType(targetElement);
    347119}
    348120
    349121void SVGAnimateElementBase::applyResultsToTarget()
    350122{
    351     ASSERT(m_animatedPropertyType != AnimatedTransformList || hasTagName(SVGNames::animateTransformTag));
    352     ASSERT(m_animatedPropertyType != AnimatedUnknown);
    353     ASSERT(m_animator);
    354 
    355     // Early exit if our animated type got destroyed by a previous endedActiveInterval().
    356     if (!m_animatedType)
     123    if (!targetElement())
    357124        return;
    358 
    359     auto targetElement = makeRefPtr(this->targetElement());
    360     const QualifiedName& attributeName = this->attributeName();
    361 
    362     ASSERT(targetElement);
    363 
    364     if (m_animatedProperties.isEmpty()) {
    365         // CSS properties animation code-path.
    366         // Convert the result of the animation to a String and apply it as CSS property on the target & all instances.
    367         applyCSSPropertyToTargetAndInstances(*targetElement, attributeName, m_animatedType->valueAsString());
    368         return;
    369     }
    370 
    371     // We do update the style and the animation property independent of each other.
    372     ShouldApplyAnimation shouldApply = shouldApplyAnimation(targetElement.get(), attributeName);
    373     if (shouldApply == ApplyXMLandCSSAnimation)
    374         applyCSSPropertyToTargetAndInstances(*targetElement, attributeName, m_animatedType->valueAsString());
    375 
    376     // SVG DOM animVal animation code-path.
    377     // At this point the SVG DOM values are already changed, unlike for CSS.
    378     // We only have to trigger update notifications here.
    379     m_animator->animValDidChange(m_animatedProperties);
    380     notifyTargetAndInstancesAboutAnimValChange(*targetElement, attributeName);
    381 }
    382 
    383 bool SVGAnimateElementBase::animatedPropertyTypeSupportsAddition() const
    384 {
    385     // Spec: http://www.w3.org/TR/SVG/animate.html#AnimationAttributesAndProperties.
    386     switch (m_animatedPropertyType) {
    387     case AnimatedBoolean:
    388     case AnimatedEnumeration:
    389     case AnimatedPreserveAspectRatio:
    390     case AnimatedString:
    391     case AnimatedUnknown:
    392         return false;
    393     case AnimatedAngle:
    394     case AnimatedColor:
    395     case AnimatedInteger:
    396     case AnimatedIntegerOptionalInteger:
    397     case AnimatedLength:
    398     case AnimatedLengthList:
    399     case AnimatedNumber:
    400     case AnimatedNumberList:
    401     case AnimatedNumberOptionalNumber:
    402     case AnimatedPath:
    403     case AnimatedPoints:
    404     case AnimatedRect:
    405     case AnimatedTransformList:
    406         return true;
    407     default:
    408         RELEASE_ASSERT_NOT_REACHED();
    409         return true;
    410     }
     125    attributeAnimationController().applyResultsToTarget();
    411126}
    412127
     
    414129{
    415130    if (animationMode() == AnimationMode::By || animationMode() == AnimationMode::FromBy) {
    416         if (!animatedPropertyTypeSupportsAddition())
    417             return false;
     131        if (auto* controller = attributeAnimationControllerIfExists()) {
     132            if (!controller->isAdditive())
     133                return false;
     134        }
    418135    }
    419136
     
    424141{
    425142    // FIXME: A return value of float is not enough to support paced animations on lists.
    426     if (!this->targetElement())
     143    if (!targetElement())
    427144        return -1;
    428145
    429     return ensureAnimator()->calculateDistance(fromString, toString);
     146    return attributeAnimationController().calculateDistance(fromString, toString);
    430147}
    431148
     
    433150{
    434151    SVGAnimationElement::setTargetElement(target);
    435     resetAnimatedPropertyType();
     152    resetAnimation();
    436153}
    437154
     
    439156{
    440157    SVGSMILElement::setAttributeName(attributeName);
    441     checkInvalidCSSAttributeType(targetElement());
    442     resetAnimatedPropertyType();
     158    resetAnimation();
    443159}
    444160
    445 void SVGAnimateElementBase::resetAnimatedPropertyType()
     161void SVGAnimateElementBase::resetAnimation()
    446162{
    447     SVGAnimationElement::resetAnimatedPropertyType();
    448     ASSERT(!m_animatedType);
    449     m_fromType = nullptr;
    450     m_toType = nullptr;
    451     m_toAtEndOfDurationType = nullptr;
    452     m_animator = nullptr;
    453     m_animatedPropertyType = targetElement() ? determineAnimatedPropertyType(*targetElement()) : AnimatedString;
     163    SVGAnimationElement::resetAnimation();
     164    m_attributeAnimationController = nullptr;
     165    m_hasInvalidCSSAttributeType = WTF::nullopt;
    454166}
    455167
    456 SVGAnimatedTypeAnimator* SVGAnimateElementBase::ensureAnimator()
     168bool SVGAnimateElementBase::hasInvalidCSSAttributeType() const
    457169{
    458     if (!m_animator)
    459         m_animator = SVGAnimatorFactory::create(this, targetElement(), m_animatedPropertyType);
    460     ASSERT(m_animatedPropertyType == m_animator->type());
    461     return m_animator.get();
     170    if (!targetElement())
     171        return false;
     172
     173    if (!m_hasInvalidCSSAttributeType)
     174        m_hasInvalidCSSAttributeType = hasValidAttributeName() && attributeType() == AttributeType::CSS && !isTargetAttributeCSSProperty(targetElement(), attributeName());
     175
     176    return m_hasInvalidCSSAttributeType.value();
    462177}
    463178
  • trunk/Source/WebCore/svg/SVGAnimateElementBase.h

    r229694 r243036  
    2424#pragma once
    2525
    26 #include "SVGAnimatedType.h"
    27 #include "SVGAnimatedTypeAnimator.h"
    2826#include "SVGAnimationElement.h"
    2927#include "SVGNames.h"
    3028
    3129namespace WebCore {
     30
     31class SVGAttributeAnimationControllerBase;
    3232
    3333class SVGAnimateElementBase : public SVGAnimationElement {
     
    3636    virtual ~SVGAnimateElementBase();
    3737
     38    SVGAttributeAnimationControllerBase& attributeAnimationController();
     39    SVGAttributeAnimationControllerBase* attributeAnimationControllerIfExists() const { return m_attributeAnimationController.get(); }
     40
    3841    AnimatedPropertyType determineAnimatedPropertyType(SVGElement&) const;
    3942
    4043protected:
    4144    SVGAnimateElementBase(const QualifiedName&, Document&);
     45
     46    bool hasValidAttributeType() const override;
    4247
    4348    void resetAnimatedType() override;
     
    5459    void setTargetElement(SVGElement*) override;
    5560    void setAttributeName(const QualifiedName&) override;
    56     void resetAnimatedPropertyType() override;
    57 
    58     AnimatedPropertyType m_animatedPropertyType;
     61    void resetAnimation() override;
    5962
    6063private:
    61     SVGAnimatedTypeAnimator* ensureAnimator();
    62     bool animatedPropertyTypeSupportsAddition() const;
     64    bool hasInvalidCSSAttributeType() const;
    6365
    64     bool hasValidAttributeType() override;
    65 
    66     std::unique_ptr<SVGAnimatedType> m_fromType;
    67     std::unique_ptr<SVGAnimatedType> m_toType;
    68     std::unique_ptr<SVGAnimatedType> m_toAtEndOfDurationType;
    69     std::unique_ptr<SVGAnimatedType> m_animatedType;
    70 
    71     SVGElementAnimatedPropertyList m_animatedProperties;
    72     std::unique_ptr<SVGAnimatedTypeAnimator> m_animator;
     66    mutable Optional<bool> m_hasInvalidCSSAttributeType;
     67    std::unique_ptr<SVGAttributeAnimationControllerBase> m_attributeAnimationController;
    7368};
    7469
  • trunk/Source/WebCore/svg/SVGAnimateMotionElement.cpp

    r242970 r243036  
    5858}
    5959
    60 bool SVGAnimateMotionElement::hasValidAttributeType()
     60bool SVGAnimateMotionElement::hasValidAttributeType() const
    6161{
    6262    auto targetElement = makeRefPtr(this->targetElement());
     
    9191}
    9292
    93 bool SVGAnimateMotionElement::hasValidAttributeName()
     93bool SVGAnimateMotionElement::hasValidAttributeName() const
    9494{
    9595    // AnimateMotion does not use attributeName so it is always valid.
  • trunk/Source/WebCore/svg/SVGAnimateMotionElement.h

    r229694 r243036  
    3737    SVGAnimateMotionElement(const QualifiedName&, Document&);
    3838
    39     bool hasValidAttributeType() override;
    40     bool hasValidAttributeName() override;
     39    bool hasValidAttributeType() const override;
     40    bool hasValidAttributeName() const override;
    4141
    4242    void parseAttribute(const QualifiedName&, const AtomicString&) override;
  • trunk/Source/WebCore/svg/SVGAnimateTransformElement.cpp

    r229694 r243036  
    4444}
    4545
    46 bool SVGAnimateTransformElement::hasValidAttributeType()
     46bool SVGAnimateTransformElement::hasValidAttributeType() const
    4747{
    4848    if (!this->targetElement())
     
    5252        return false;
    5353
    54     return m_animatedPropertyType == AnimatedTransformList;
     54    return SVGAnimateElementBase::hasValidAttributeType();
    5555}
    5656
  • trunk/Source/WebCore/svg/SVGAnimateTransformElement.h

    r229694 r243036  
    4040    SVGAnimateTransformElement(const QualifiedName&, Document&);
    4141   
    42     bool hasValidAttributeType() final;
     42    bool hasValidAttributeType() const final;
    4343    void parseAttribute(const QualifiedName&, const AtomicString&) final;
    4444
  • trunk/Source/WebCore/svg/SVGAnimatedPointList.h

    r234620 r243036  
    2323#include "SVGAnimatedListPropertyTearOff.h"
    2424#include "SVGAnimatedTypeAnimator.h"
     25#include "SVGAttribute.h"
     26#include "SVGAttributeAccessor.h"
    2527#include "SVGPointList.h"
    2628
  • trunk/Source/WebCore/svg/SVGAnimationElement.cpp

    r242970 r243036  
    306306    else
    307307        m_attributeType = AttributeType::Auto;
    308     checkInvalidCSSAttributeType(targetElement());
    309308}
    310309
     
    668667        m_toPropertyValueType = InheritValue;
    669668}
    670 void SVGAnimationElement::resetAnimatedPropertyType()
     669void SVGAnimationElement::resetAnimation()
    671670{
    672671    m_lastValuesAnimationFrom = String();
     
    674673}
    675674
    676 void SVGAnimationElement::setTargetElement(SVGElement* target)
    677 {
    678     SVGSMILElement::setTargetElement(target);
    679     checkInvalidCSSAttributeType(target);
    680 }
    681 
    682 void SVGAnimationElement::checkInvalidCSSAttributeType(SVGElement* target)
    683 {
    684     m_hasInvalidCSSAttributeType = target && hasValidAttributeName() && attributeType() == AttributeType::CSS && !isTargetAttributeCSSProperty(target, attributeName());
    685 }
    686 
    687 }
     675}
  • trunk/Source/WebCore/svg/SVGAnimationElement.h

    r242970 r243036  
    3737class TimeContainer;
    3838
    39 enum class AnimationMode : uint8_t {
    40     None,
    41     FromTo,
    42     FromBy,
    43     To,
    44     By,
    45     Values,
    46     Path // Used by AnimateMotion.
    47 };
    48 
    4939// If we have 'currentColor' or 'inherit' as animation value, we need to grab
    5040// the value during the animation since the value can be animated itself.
    5141enum AnimatedPropertyValueType { RegularPropertyValue, CurrentColorValue, InheritValue };
    52 
    53 enum class CalcMode : uint8_t { Discrete, Linear, Paced, Spline };
    5442
    5543class SVGAnimationElement : public SVGSMILElement, public SVGExternalResourcesRequired, public SVGTests {
     
    147135    }
    148136
     137    enum class AttributeType : uint8_t { CSS, XML, Auto };
     138    AttributeType attributeType() const { return m_attributeType; }
     139
     140    void computeCSSPropertyValue(SVGElement*, CSSPropertyID, String& value);
     141    virtual void determinePropertyValueTypes(const String& from, const String& to);
     142
    149143protected:
    150144    SVGAnimationElement(const QualifiedName&, Document&);
     
    154148    const SVGAttributeOwnerProxy& attributeOwnerProxy() const override { return m_attributeOwnerProxy; }
    155149
    156     void computeCSSPropertyValue(SVGElement*, CSSPropertyID, String& value);
    157     virtual void determinePropertyValueTypes(const String& from, const String& to);
    158     virtual void resetAnimatedPropertyType();
     150    virtual void resetAnimation();
    159151
    160152    static bool isSupportedAttribute(const QualifiedName&);
     
    162154    void svgAttributeChanged(const QualifiedName&) override;
    163155
    164     enum class AttributeType { CSS, XML, Auto };
    165     AttributeType attributeType() const { return m_attributeType; }
    166 
    167156    String toValue() const;
    168157    String byValue() const;
     
    178167    AnimatedPropertyValueType m_toPropertyValueType { RegularPropertyValue };
    179168
    180     void setTargetElement(SVGElement*) override;
    181169    void setAttributeName(const QualifiedName&) override { }
    182     bool hasInvalidCSSAttributeType() const { return m_hasInvalidCSSAttributeType; }
    183     void checkInvalidCSSAttributeType(SVGElement*);
    184170
    185171    virtual void updateAnimationMode();
     
    219205    String m_lastValuesAnimationFrom;
    220206    String m_lastValuesAnimationTo;
    221     bool m_hasInvalidCSSAttributeType { false };
    222207    CalcMode m_calcMode { CalcMode::Linear };
    223208    AnimationMode m_animationMode { AnimationMode::None };
  • trunk/Source/WebCore/svg/SVGAnimatorFactory.h

    r208668 r243036  
    2424#include "SVGAnimatedColor.h"
    2525#include "SVGAnimatedEnumeration.h"
    26 #include "SVGAnimatedInteger.h"
    27 #include "SVGAnimatedIntegerOptionalInteger.h"
    2826#include "SVGAnimatedLength.h"
    2927#include "SVGAnimatedLengthList.h"
     
    5957            return std::make_unique<SVGAnimatedEnumerationAnimator>(animationElement, contextElement);
    6058        case AnimatedInteger:
    61             return std::make_unique<SVGAnimatedIntegerAnimator>(animationElement, contextElement);
     59            return nullptr;
    6260        case AnimatedIntegerOptionalInteger:
    63             return std::make_unique<SVGAnimatedIntegerOptionalIntegerAnimator>(animationElement, contextElement);
     61            return nullptr;
    6462        case AnimatedLength:
    6563            return std::make_unique<SVGAnimatedLengthAnimator>(animationElement, contextElement);
  • trunk/Source/WebCore/svg/SVGAttributeAnimationController.h

    r243035 r243036  
    11/*
    2  * Copyright (C) 2018 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2018-2019 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
    28 #include "SVGAnimatedPropertyType.h"
    29 #include <wtf/WeakPtr.h>
     28#include "SVGAttributeAnimationControllerBase.h"
    3029
    3130namespace WebCore {
    3231
    33 class SVGAttribute;
     32class SVGAnimationElement;
    3433class SVGElement;
    35 class SVGLegacyAnimatedProperty;
     34class SVGSMILElement;
    3635
    37 class SVGAttributeOwnerProxy {
     36class SVGAttributeAnimationController : public SVGAttributeAnimationControllerBase {
    3837public:
    39     SVGAttributeOwnerProxy(SVGElement&);
     38    SVGAttributeAnimationController(SVGAnimationElement&, SVGElement&);
     39   
     40private:
     41    SVGAttributeAnimator* animator() const;
     42    SVGAttributeAnimator* animatorIfExists() const { return m_animator.get(); }
    4043
    41     virtual ~SVGAttributeOwnerProxy() = default;
     44    void resetAnimatedType() override;
     45    void clearAnimatedType(SVGElement* targetElement) override;
     46   
     47    bool calculateFromAndToValues(const String& fromString, const String& toString) override;
     48    bool calculateFromAndByValues(const String& fromString, const String& byString) override;
     49    bool calculateToAtEndOfDurationValue(const String& toAtEndOfDurationString) override;
    4250
    43     SVGElement& element() const;
     51    void calculateAnimatedValue(float percentage, unsigned repeatCount, SVGSMILElement* resultElement) override;
    4452
    45     virtual void synchronizeAttributes() const = 0;
    46     virtual void synchronizeAttribute(const QualifiedName&) const = 0;
     53    void applyResultsToTarget() override;
     54    float calculateDistance(const String& fromString, const String& toString) override;
     55   
     56    bool isAdditive() const override;
     57    bool hasValidAttributeType() const override;
    4758
    48     virtual Vector<AnimatedPropertyType> animatedTypes(const QualifiedName&) const = 0;
     59    bool isDiscreteAnimator() const;
    4960
    50     virtual RefPtr<SVGLegacyAnimatedProperty> lookupOrCreateAnimatedProperty(const SVGAttribute&) const = 0;
    51     virtual RefPtr<SVGLegacyAnimatedProperty> lookupAnimatedProperty(const SVGAttribute&) const = 0;
    52     virtual Vector<RefPtr<SVGLegacyAnimatedProperty>> lookupOrCreateAnimatedProperties(const QualifiedName&) const = 0;
    53 
    54 protected:
    55     WeakPtr<SVGElement> m_element;
     61    mutable std::unique_ptr<SVGAttributeAnimator> m_animator;
    5662};
    5763
    58 }
     64} // namespace WebCore
  • trunk/Source/WebCore/svg/SVGAttributeAnimationControllerBase.h

    r243035 r243036  
    11/*
    2  * Copyright (C) 2018 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2018-2019 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
    28 #include "SVGAnimatedPropertyType.h"
    29 #include <wtf/WeakPtr.h>
    30 
    3128namespace WebCore {
    3229
    33 class SVGAttribute;
     30class SVGAnimationElement;
    3431class SVGElement;
    35 class SVGLegacyAnimatedProperty;
     32class SVGSMILElement;
    3633
    37 class SVGAttributeOwnerProxy {
     34class SVGAttributeAnimationControllerBase {
    3835public:
    39     SVGAttributeOwnerProxy(SVGElement&);
     36    SVGAttributeAnimationControllerBase(SVGAnimationElement&, SVGElement&);
     37    virtual ~SVGAttributeAnimationControllerBase() = default;
    4038
    41     virtual ~SVGAttributeOwnerProxy() = default;
     39    static AnimatedPropertyType determineAnimatedPropertyType(const SVGAnimationElement&, SVGElement&, const QualifiedName&);
    4240
    43     SVGElement& element() const;
     41    virtual bool isAdditive() const = 0;
     42    virtual bool hasValidAttributeType() const = 0;
     43   
     44    virtual void resetAnimatedType() = 0;
     45    virtual void clearAnimatedType(SVGElement* targetElement) = 0;
     46   
     47    virtual bool calculateFromAndToValues(const String& fromString, const String& toString) = 0;
     48    virtual bool calculateFromAndByValues(const String& fromString, const String& byString) = 0;
     49    virtual bool calculateToAtEndOfDurationValue(const String& toAtEndOfDurationString) = 0;
    4450
    45     virtual void synchronizeAttributes() const = 0;
    46     virtual void synchronizeAttribute(const QualifiedName&) const = 0;
    47 
    48     virtual Vector<AnimatedPropertyType> animatedTypes(const QualifiedName&) const = 0;
    49 
    50     virtual RefPtr<SVGLegacyAnimatedProperty> lookupOrCreateAnimatedProperty(const SVGAttribute&) const = 0;
    51     virtual RefPtr<SVGLegacyAnimatedProperty> lookupAnimatedProperty(const SVGAttribute&) const = 0;
    52     virtual Vector<RefPtr<SVGLegacyAnimatedProperty>> lookupOrCreateAnimatedProperties(const QualifiedName&) const = 0;
    53 
     51    virtual void calculateAnimatedValue(float percentage, unsigned repeatCount, SVGSMILElement* resultElement) = 0;
     52    virtual void applyResultsToTarget() = 0;
     53   
     54    virtual float calculateDistance(const String& fromString, const String& toString) = 0;
     55   
    5456protected:
    55     WeakPtr<SVGElement> m_element;
     57    SVGAnimationElement& m_animationElement;
     58    SVGElement& m_targetElement;
    5659};
    5760
    58 }
     61} // namespace WebCore
     62
  • trunk/Source/WebCore/svg/SVGElement.cpp

    r240305 r243036  
    701701    svgElement->synchronizeAttributes();
    702702    svgElement->elementData()->setAnimatedSVGAttributesAreDirty(false);
     703   
     704    // FIXME: Delete the SVG tear off properties code from this function
     705   
     706    // SVGPropertyRegistry::synchronizeAllAttributes() returns the new values of
     707    // the properties which have changed but not committed yet.
     708    auto map = svgElement->propertyRegistry().synchronizeAllAttributes();
     709    for (const auto& entry : map)
     710        svgElement->setSynchronizedLazyAttribute(entry.key, entry.value);
    703711}
    704712
     
    707715    if (!elementData() || !elementData()->animatedSVGAttributesAreDirty())
    708716        return;
     717
     718    // FIXME: Delete the SVG tear off properties code from this function
    709719
    710720    SVGElement* nonConstThis = const_cast<SVGElement*>(this);
    711721    if (name == anyQName())
    712722        synchronizeAllAnimatedSVGAttribute(nonConstThis);
    713     else
     723    else if (isAnimatedPropertyAttribute(name)) {
     724        // If the value of the property has changed, serialize the new value to the attribute.
     725        if (auto value = propertyRegistry().synchronize(name))
     726            nonConstThis->setSynchronizedLazyAttribute(name, *value);
     727    } else
    714728        nonConstThis->synchronizeAttribute(name);
     729}
     730
     731void SVGElement::commitPropertyChange(SVGAnimatedProperty& animatedProperty)
     732{
     733    QualifiedName attributeName = propertyRegistry().animatedPropertyAttributeName(animatedProperty);
     734    setSynchronizedLazyAttribute(attributeName, animatedProperty.baseValAsString());
     735
     736    invalidateSVGAttributes();
     737    svgAttributeChanged(attributeName);
     738}
     739
     740bool SVGElement::isAnimatedPropertyAttribute(const QualifiedName& attributeName) const
     741{
     742    return propertyRegistry().isAnimatedPropertyAttribute(attributeName);
     743}
     744
     745bool SVGElement::isAnimatedAttribute(const QualifiedName& attributeName) const
     746{
     747    return isAnimatedPropertyAttribute(attributeName);
     748}
     749
     750std::unique_ptr<SVGAttributeAnimator> SVGElement::createAnimator(const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive)
     751{
     752    auto animator = propertyRegistry().createAnimator(attributeName, animationMode, calcMode, isAccumulated, isAdditive);
     753    if (!animator)
     754        return animator;
     755    for (auto* instance : instances())
     756        instance->propertyRegistry().appendAnimatedInstance(attributeName, *animator);
     757    return animator;
    715758}
    716759
  • trunk/Source/WebCore/svg/SVGElement.h

    r242978 r243036  
    2323#pragma once
    2424
    25 #include "SVGAnimatedString.h"
     25#include "SVGAnimatedPropertyImpl.h"
    2626#include "SVGAttributeOwnerProxy.h"
    2727#include "SVGLangSpace.h"
     
    2929#include "SVGNames.h"
    3030#include "SVGParsingError.h"
     31#include "SVGPropertyOwnerRegistry.h"
    3132#include "StyledElement.h"
    3233#include <wtf/HashMap.h>
     
    4748void mapAttributeToCSSProperty(HashMap<AtomicStringImpl*, CSSPropertyID>* propertyNameToIdMap, const QualifiedName& attrName);
    4849
    49 class SVGElement : public StyledElement, public SVGLangSpace, public CanMakeWeakPtr<SVGElement> {
     50class SVGElement : public StyledElement, public SVGLangSpace, public SVGPropertyOwner, public CanMakeWeakPtr<SVGElement> {
    5051    WTF_MAKE_ISO_ALLOCATED(SVGElement);
    5152public:
     
    151152    Vector<RefPtr<SVGLegacyAnimatedProperty>> lookupOrCreateAnimatedProperties(const QualifiedName& name) { return attributeOwnerProxy().lookupOrCreateAnimatedProperties(name); }
    152153
     154    using PropertyRegistry = SVGPropertyOwnerRegistry<SVGElement>;
     155    virtual const SVGPropertyRegistry& propertyRegistry() const { return m_propertyRegistry; }
     156
     157    bool isAnimatedPropertyAttribute(const QualifiedName&) const;
     158    bool isAnimatedAttribute(const QualifiedName&) const;
     159
     160    void commitPropertyChange() override { }
     161    void commitPropertyChange(SVGAnimatedProperty&);
     162
     163    const SVGElement* attributeContextElement() const override { return this; }
     164    std::unique_ptr<SVGAttributeAnimator> createAnimator(const QualifiedName&, AnimationMode, CalcMode, bool isAccumulated, bool isAdditive);
     165
    153166    // These are needed for the RenderTree, animation and DOM.
    154167    const auto& className() const { return m_className.currentValue(attributeOwnerProxy()); }
     
    205218    AttributeOwnerProxy m_attributeOwnerProxy { *this };
    206219    SVGAnimatedStringAttribute m_className;
     220   
     221    PropertyRegistry m_propertyRegistry { *this };
    207222};
    208223
  • trunk/Source/WebCore/svg/SVGFEConvolveMatrixElement.cpp

    r234620 r243036  
    11/*
    22 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
    3  * Copyright (C) 2018 Apple Inc. All rights reserved.
     3 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
    44 *
    55 * This library is free software; you can redistribute it and/or
     
    4141    ASSERT(hasTagName(SVGNames::feConvolveMatrixTag));
    4242    registerAttributes();
     43
     44    static std::once_flag onceFlag;
     45    std::call_once(onceFlag, [] {
     46        PropertyRegistry::registerProperty<SVGNames::orderAttr, &SVGFEConvolveMatrixElement::m_orderX, &SVGFEConvolveMatrixElement::m_orderY>();
     47        PropertyRegistry::registerProperty<SVGNames::targetXAttr, &SVGFEConvolveMatrixElement::m_targetX>();
     48        PropertyRegistry::registerProperty<SVGNames::targetYAttr, &SVGFEConvolveMatrixElement::m_targetY>();
     49    });
    4350}
    4451
     
    6067}
    6168
    62 const AtomicString& SVGFEConvolveMatrixElement::orderXIdentifier()
    63 {
    64     static NeverDestroyed<AtomicString> s_identifier("SVGOrderX", AtomicString::ConstructFromLiteral);
    65     return s_identifier;
    66 }
    67 
    68 const AtomicString& SVGFEConvolveMatrixElement::orderYIdentifier()
    69 {
    70     static NeverDestroyed<AtomicString> s_identifier("SVGOrderY", AtomicString::ConstructFromLiteral);
    71     return s_identifier;
    72 }
    73 
    7469void SVGFEConvolveMatrixElement::registerAttributes()
    7570{
     
    7873        return;
    7974    registry.registerAttribute<SVGNames::inAttr, &SVGFEConvolveMatrixElement::m_in1>();
    80     registry.registerAttribute<SVGNames::orderAttr,
    81         &SVGFEConvolveMatrixElement::orderXIdentifier, &SVGFEConvolveMatrixElement::m_orderX,
    82         &SVGFEConvolveMatrixElement::orderYIdentifier, &SVGFEConvolveMatrixElement::m_orderY>();
    8375    registry.registerAttribute<SVGNames::kernelMatrixAttr, &SVGFEConvolveMatrixElement::m_kernelMatrix>();
    8476    registry.registerAttribute<SVGNames::divisorAttr, &SVGFEConvolveMatrixElement::m_divisor>();
    8577    registry.registerAttribute<SVGNames::biasAttr, &SVGFEConvolveMatrixElement::m_bias>();
    86     registry.registerAttribute<SVGNames::targetXAttr, &SVGFEConvolveMatrixElement::m_targetX>();
    87     registry.registerAttribute<SVGNames::targetYAttr, &SVGFEConvolveMatrixElement::m_targetY>();
    8878    registry.registerAttribute<SVGNames::edgeModeAttr, EdgeModeType, &SVGFEConvolveMatrixElement::m_edgeMode>();
    8979    registry.registerAttribute<SVGNames::kernelUnitLengthAttr,
     
    10393        float x, y;
    10494        if (parseNumberOptionalNumber(value, x, y) && x >= 1 && y >= 1) {
    105             m_orderX.setValue(x);
    106             m_orderY.setValue(y);
     95            m_orderX->setBaseValInternal(x);
     96            m_orderY->setBaseValInternal(y);
    10797        } else
    10898            document().accessSVGExtensions().reportWarning("feConvolveMatrix: problem parsing order=\"" + value + "\". Filtered element will not be displayed.");
     
    142132
    143133    if (name == SVGNames::targetXAttr) {
    144         m_targetX.setValue(value.string().toUIntStrict());
     134        m_targetX->setBaseValInternal(value.string().toUIntStrict());
    145135        return;
    146136    }
    147137
    148138    if (name == SVGNames::targetYAttr) {
    149         m_targetY.setValue(value.string().toUIntStrict());
     139        m_targetY->setBaseValInternal(value.string().toUIntStrict());
    150140        return;
    151141    }
     
    198188void SVGFEConvolveMatrixElement::setOrder(float x, float y)
    199189{
    200     m_orderX.setValue(x);
    201     m_orderY.setValue(y);
     190    m_orderX->setBaseValInternal(x);
     191    m_orderY->setBaseValInternal(y);
    202192    invalidate();
    203193}
  • trunk/Source/WebCore/svg/SVGFEConvolveMatrixElement.h

    r234620 r243036  
    2222
    2323#include "FEConvolveMatrix.h"
    24 #include "SVGAnimatedBoolean.h"
    25 #include "SVGAnimatedEnumeration.h"
    26 #include "SVGAnimatedInteger.h"
    27 #include "SVGAnimatedNumber.h"
    28 #include "SVGAnimatedNumberList.h"
    2924#include "SVGFilterPrimitiveStandardAttributes.h"
    3025
     
    7469
    7570    String in1() const { return m_in1.currentValue(attributeOwnerProxy()); }
    76     int orderX() const { return m_orderX.currentValue(attributeOwnerProxy()); }
    77     int orderY() const { return m_orderY.currentValue(attributeOwnerProxy()); }
     71    int orderX() const { return m_orderX->currentValue(); }
     72    int orderY() const { return m_orderY->currentValue(); }
    7873    const SVGNumberListValues& kernelMatrix() const { return m_kernelMatrix.currentValue(attributeOwnerProxy()); }
    7974    float divisor() const { return m_divisor.currentValue(attributeOwnerProxy()); }
    8075    float bias() const { return m_bias.currentValue(attributeOwnerProxy()); }
    81     int targetX() const { return m_targetX.currentValue(attributeOwnerProxy()); }
    82     int targetY() const { return m_targetY.currentValue(attributeOwnerProxy()); }
     76    int targetX() const { return m_targetX->currentValue(); }
     77    int targetY() const { return m_targetY->currentValue(); }
    8378    EdgeModeType edgeMode() const { return m_edgeMode.currentValue(attributeOwnerProxy()); }
    8479    float kernelUnitLengthX() const { return m_kernelUnitLengthX.currentValue(attributeOwnerProxy()); }
     
    8782
    8883    RefPtr<SVGAnimatedString> in1Animated() { return m_in1.animatedProperty(attributeOwnerProxy()); }
    89     RefPtr<SVGAnimatedInteger> orderXAnimated() { return m_orderX.animatedProperty(attributeOwnerProxy()); }
    90     RefPtr<SVGAnimatedInteger> orderYAnimated() { return m_orderY.animatedProperty(attributeOwnerProxy()); }
     84    SVGAnimatedInteger& orderXAnimated() { return m_orderX; }
     85    SVGAnimatedInteger& orderYAnimated() { return m_orderY; }
    9186    RefPtr<SVGAnimatedNumberList> kernelMatrixAnimated() { return m_kernelMatrix.animatedProperty(attributeOwnerProxy()); }
    9287    RefPtr<SVGAnimatedNumber> divisorAnimated() { return m_divisor.animatedProperty(attributeOwnerProxy()); }
    9388    RefPtr<SVGAnimatedNumber> biasAnimated() { return m_bias.animatedProperty(attributeOwnerProxy()); }
    94     RefPtr<SVGAnimatedInteger> targetXAnimated() { return m_targetX.animatedProperty(attributeOwnerProxy()); }
    95     RefPtr<SVGAnimatedInteger> targetYAnimated() { return m_targetY.animatedProperty(attributeOwnerProxy()); }
     89    SVGAnimatedInteger& targetXAnimated() { return m_targetX; }
     90    SVGAnimatedInteger& targetYAnimated() { return m_targetY; }
    9691    RefPtr<SVGAnimatedEnumeration> edgeModeAnimated() { return m_edgeMode.animatedProperty(attributeOwnerProxy()); }
    9792    RefPtr<SVGAnimatedNumber> kernelUnitLengthXAnimated() { return m_kernelUnitLengthX.animatedProperty(attributeOwnerProxy()); }
     
    106101    static bool isKnownAttribute(const QualifiedName& attributeName) { return AttributeOwnerProxy::isKnownAttribute(attributeName); }
    107102    static void registerAttributes();
     103   
     104    using PropertyRegistry = SVGPropertyOwnerRegistry<SVGFEConvolveMatrixElement, SVGFilterPrimitiveStandardAttributes>;
     105    const SVGPropertyRegistry& propertyRegistry() const final { return m_propertyRegistry; }
    108106
    109107    const SVGAttributeOwnerProxy& attributeOwnerProxy() const final { return m_attributeOwnerProxy; }
     
    114112    RefPtr<FilterEffect> build(SVGFilterBuilder*, Filter&) override;
    115113
    116     static const AtomicString& orderXIdentifier();
    117     static const AtomicString& orderYIdentifier();
    118114    static const AtomicString& kernelUnitLengthXIdentifier();
    119115    static const AtomicString& kernelUnitLengthYIdentifier();
    120116
    121117    AttributeOwnerProxy m_attributeOwnerProxy { *this };
     118    PropertyRegistry m_propertyRegistry { *this };
     119
    122120    SVGAnimatedStringAttribute m_in1;
    123     SVGAnimatedIntegerAttribute m_orderX;
    124     SVGAnimatedIntegerAttribute m_orderY;
     121    Ref<SVGAnimatedInteger> m_orderX { SVGAnimatedInteger::create(this) };
     122    Ref<SVGAnimatedInteger> m_orderY { SVGAnimatedInteger::create(this) };
    125123    SVGAnimatedNumberListAttribute m_kernelMatrix;
    126124    SVGAnimatedNumberAttribute m_divisor;
    127125    SVGAnimatedNumberAttribute m_bias;
    128     SVGAnimatedIntegerAttribute m_targetX;
    129     SVGAnimatedIntegerAttribute m_targetY;
     126    Ref<SVGAnimatedInteger> m_targetX { SVGAnimatedInteger::create(this) };
     127    Ref<SVGAnimatedInteger> m_targetY { SVGAnimatedInteger::create(this) };
    130128    SVGAnimatedEnumerationAttribute<EdgeModeType> m_edgeMode { EDGEMODE_DUPLICATE };
    131129    SVGAnimatedNumberAttribute m_kernelUnitLengthX;
  • trunk/Source/WebCore/svg/SVGFETurbulenceElement.cpp

    r234620 r243036  
    3636    ASSERT(hasTagName(SVGNames::feTurbulenceTag));
    3737    registerAttributes();
     38   
     39    static std::once_flag onceFlag;
     40    std::call_once(onceFlag, [] {
     41        PropertyRegistry::registerProperty<SVGNames::numOctavesAttr, &SVGFETurbulenceElement::m_numOctaves>();
     42    });
    3843}
    3944
     
    6368        &SVGFETurbulenceElement::baseFrequencyXIdentifier, &SVGFETurbulenceElement::m_baseFrequencyX,
    6469        &SVGFETurbulenceElement::baseFrequencyYIdentifier, &SVGFETurbulenceElement::m_baseFrequencyY>();
    65     registry.registerAttribute<SVGNames::numOctavesAttr, &SVGFETurbulenceElement::m_numOctaves>();
    6670    registry.registerAttribute<SVGNames::seedAttr, &SVGFETurbulenceElement::m_seed>();
    6771    registry.registerAttribute<SVGNames::stitchTilesAttr, SVGStitchOptions, &SVGFETurbulenceElement::m_stitchTiles>();
     
    100104
    101105    if (name == SVGNames::numOctavesAttr) {
    102         m_numOctaves.setValue(value.string().toUIntStrict());
     106        m_numOctaves->setBaseValInternal(value.string().toUIntStrict());
    103107        return;
    104108    }
     
    127131void SVGFETurbulenceElement::svgAttributeChanged(const QualifiedName& attrName)
    128132{
    129     if (isKnownAttribute(attrName)) {
     133    if (isKnownAttribute(attrName) || PropertyRegistry::isKnownAttribute(attrName)) {
    130134        InstanceInvalidationGuard guard(*this);
    131135        primitiveAttributeChanged(attrName);
  • trunk/Source/WebCore/svg/SVGFETurbulenceElement.h

    r234620 r243036  
    22 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
    33 * Copyright (C) 2004, 2005, 2006 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 "FETurbulence.h"
    2525#include "SVGAnimatedEnumeration.h"
    26 #include "SVGAnimatedInteger.h"
    2726#include "SVGAnimatedNumber.h"
    2827#include "SVGFilterPrimitiveStandardAttributes.h"
     
    101100    float baseFrequencyX() const { return m_baseFrequencyX.currentValue(attributeOwnerProxy()); }
    102101    float baseFrequencyY() const { return m_baseFrequencyY.currentValue(attributeOwnerProxy()); }
    103     int numOctaves() const { return m_numOctaves.currentValue(attributeOwnerProxy()); }
     102    int numOctaves() const { return m_numOctaves->currentValue(); }
    104103    float seed() const { return m_seed.currentValue(attributeOwnerProxy()); }
    105104    SVGStitchOptions stitchTiles() const { return m_stitchTiles.currentValue(attributeOwnerProxy()); }
     
    108107    RefPtr<SVGAnimatedNumber> baseFrequencyXAnimated() { return m_baseFrequencyX.animatedProperty(attributeOwnerProxy()); }
    109108    RefPtr<SVGAnimatedNumber> baseFrequencyYAnimated() { return m_baseFrequencyY.animatedProperty(attributeOwnerProxy()); }
    110     RefPtr<SVGAnimatedInteger> numOctavesAnimated() { return m_numOctaves.animatedProperty(attributeOwnerProxy()); }
     109    SVGAnimatedInteger& numOctavesAnimated() { return m_numOctaves; }
    111110    RefPtr<SVGAnimatedNumber> seedAnimated() { return m_seed.animatedProperty(attributeOwnerProxy()); }
    112111    RefPtr<SVGAnimatedEnumeration> stitchTilesAnimated() { return m_stitchTiles.animatedProperty(attributeOwnerProxy()); }
     
    120119    static bool isKnownAttribute(const QualifiedName& attributeName) { return AttributeOwnerProxy::isKnownAttribute(attributeName); }
    121120    static void registerAttributes();
     121   
     122    using PropertyRegistry = SVGPropertyOwnerRegistry<SVGFETurbulenceElement, SVGFilterPrimitiveStandardAttributes>;
     123    const SVGPropertyRegistry& propertyRegistry() const final { return m_propertyRegistry; }
    122124
    123125    const SVGAttributeOwnerProxy& attributeOwnerProxy() const final { return m_attributeOwnerProxy; }
     
    132134
    133135    AttributeOwnerProxy m_attributeOwnerProxy { *this };
     136    PropertyRegistry m_propertyRegistry { *this };
    134137    SVGAnimatedNumberAttribute m_baseFrequencyX;
    135138    SVGAnimatedNumberAttribute m_baseFrequencyY;
    136     SVGAnimatedIntegerAttribute m_numOctaves { 1 };
     139    Ref<SVGAnimatedInteger> m_numOctaves { SVGAnimatedInteger::create(this, 1) };
    137140    SVGAnimatedNumberAttribute m_seed;
    138141    SVGAnimatedEnumerationAttribute<SVGStitchOptions> m_stitchTiles { SVG_STITCHTYPE_NOSTITCH };
  • trunk/Source/WebCore/svg/SVGFilterElement.h

    r236447 r243036  
    2525
    2626#include "SVGAnimatedEnumeration.h"
    27 #include "SVGAnimatedInteger.h"
    2827#include "SVGAnimatedLength.h"
    2928#include "SVGElement.h"
  • trunk/Source/WebCore/svg/SVGLegacyAttributeAnimationController.cpp

    r243035 r243036  
    11/*
    2  * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
    3  * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
    4  * Copyright (C) 2008 Apple Inc. All rights reserved.
    5  * Copyright (C) Research In Motion Limited 2011. All rights reserved.
    6  * Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved.
     2 * Copyright (C) 2018-2019 Apple Inc.  All rights reserved.
    73 *
    8  * This library is free software; you can redistribute it and/or
    9  * modify it under the terms of the GNU Library General Public
    10  * License as published by the Free Software Foundation; either
    11  * version 2 of the License, or (at your option) any later version.
     4 * Redistribution and use in source and binary forms, with or without
     5 * modification, are permitted provided that the following conditions
     6 * are met:
     7 * 1. Redistributions of source code must retain the above copyright
     8 *    notice, this list of conditions and the following disclaimer.
     9 * 2. Redistributions in binary form must reproduce the above copyright
     10 *    notice, this list of conditions and the following disclaimer in the
     11 *    documentation and/or other materials provided with the distribution.
    1212 *
    13  * This library is distributed in the hope that it will be useful,
    14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    16  * Library General Public License for more details.
    17  *
    18  * You should have received a copy of the GNU Library General Public License
    19  * along with this library; see the file COPYING.LIB.  If not, write to
    20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    21  * Boston, MA 02110-1301, USA.
     13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
     14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     16 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
     17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
     21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2224 */
    2325
    2426#include "config.h"
    25 #include "SVGAnimateElementBase.h"
     27#include "SVGLegacyAttributeAnimationController.h"
    2628
    2729#include "CSSPropertyNames.h"
    2830#include "CSSPropertyParser.h"
    2931#include "QualifiedName.h"
    30 #include "RenderObject.h"
     32#include "SVGAnimateElementBase.h"
     33#include "SVGAnimationElement.h"
    3134#include "SVGAnimatorFactory.h"
    3235#include "SVGElement.h"
     
    3740namespace WebCore {
    3841
    39 WTF_MAKE_ISO_ALLOCATED_IMPL(SVGAnimateElementBase);
    40 
    41 SVGAnimateElementBase::SVGAnimateElementBase(const QualifiedName& tagName, Document& document)
    42     : SVGAnimationElement(tagName, document)
    43     , m_animatedPropertyType(AnimatedString)
    44 {
    45     ASSERT(hasTagName(SVGNames::animateTag) || hasTagName(SVGNames::setTag) || hasTagName(SVGNames::animateColorTag) || hasTagName(SVGNames::animateTransformTag));
    46 }
    47 
    48 SVGAnimateElementBase::~SVGAnimateElementBase() = default;
    49 
    50 bool SVGAnimateElementBase::hasValidAttributeType()
    51 {
    52     if (!this->targetElement())
    53         return false;
    54 
    55     return m_animatedPropertyType != AnimatedUnknown && !hasInvalidCSSAttributeType();
    56 }
    57 
    58 AnimatedPropertyType SVGAnimateElementBase::determineAnimatedPropertyType(SVGElement& targetElement) const
    59 {
    60     auto propertyTypes = targetElement.animatedPropertyTypesForAttribute(attributeName());
    61     if (propertyTypes.isEmpty())
    62         return AnimatedUnknown;
    63 
    64     ASSERT(propertyTypes.size() <= 2);
    65     AnimatedPropertyType type = propertyTypes[0];
    66     if (hasTagName(SVGNames::animateColorTag) && type != AnimatedColor)
    67         return AnimatedUnknown;
    68 
    69     // Animations of transform lists are not allowed for <animate> or <set>
    70     // http://www.w3.org/TR/SVG/animate.html#AnimationAttributesAndProperties
    71     if (type == AnimatedTransformList && !hasTagName(SVGNames::animateTransformTag))
    72         return AnimatedUnknown;
    73 
    74     // Fortunately there's just one special case needed here: SVGMarkerElements orientAttr, which
    75     // corresponds to SVGAnimatedAngle orientAngle and SVGAnimatedEnumeration orientType. We have to
    76     // figure out whose value to change here.
    77     if (targetElement.hasTagName(SVGNames::markerTag) && type == AnimatedAngle) {
    78         ASSERT(propertyTypes.size() == 2);
    79         ASSERT(propertyTypes[0] == AnimatedAngle);
    80         ASSERT(propertyTypes[1] == AnimatedEnumeration);
    81     } else if (propertyTypes.size() == 2)
    82         ASSERT(propertyTypes[0] == propertyTypes[1]);
    83 
    84     return type;
    85 }
    86 
    87 void SVGAnimateElementBase::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGSMILElement* resultElement)
    88 {
    89     ASSERT(resultElement);
    90     auto targetElement = makeRefPtr(this->targetElement());
    91     if (!targetElement)
    92         return;
    93 
    94     const QualifiedName& attributeName = this->attributeName();
    95     ShouldApplyAnimation shouldApply = shouldApplyAnimation(targetElement.get(), attributeName);
    96    
    97     if (shouldApply == DontApplyAnimation)
    98         return;
    99 
    100     ASSERT(m_animatedPropertyType == determineAnimatedPropertyType(*targetElement));
    101 
    102     ASSERT(percentage >= 0 && percentage <= 1);
    103     ASSERT(m_animatedPropertyType != AnimatedTransformList || hasTagName(SVGNames::animateTransformTag));
    104     ASSERT(m_animatedPropertyType != AnimatedUnknown);
    105     ASSERT(m_animator);
    106     ASSERT(m_animator->type() == m_animatedPropertyType);
    107     ASSERT(m_fromType);
    108     ASSERT(m_fromType->type() == m_animatedPropertyType);
    109     ASSERT(m_toType);
    110 
    111     if (shouldApply == ApplyXMLAnimation || shouldApply == ApplyXMLandCSSAnimation) {
    112         // SVG DOM animVal animation code-path.
    113         if (m_animator->findAnimatedPropertiesForAttributeName(*targetElement, attributeName).isEmpty())
    114             return;
    115     }
    116 
    117     SVGAnimateElementBase& resultAnimationElement = downcast<SVGAnimateElementBase>(*resultElement);
    118     ASSERT(resultAnimationElement.m_animatedType);
    119     ASSERT(resultAnimationElement.m_animatedPropertyType == m_animatedPropertyType);
    120 
    121     if (hasTagName(SVGNames::setTag))
    122         percentage = 1;
    123 
    124     if (calcMode() == CalcMode::Discrete)
    125         percentage = percentage < 0.5 ? 0 : 1;
    126 
    127     // Target element might have changed.
    128     m_animator->setContextElement(targetElement.get());
    129 
    130     // Be sure to detach list wrappers before we modfiy their underlying value. If we'd do
    131     // if after calculateAnimatedValue() ran the cached pointers in the list propery tear
    132     // offs would point nowhere, and we couldn't create copies of those values anymore,
    133     // while detaching. This is covered by assertions, moving this down would fire them.
    134     if (!m_animatedProperties.isEmpty())
    135         m_animator->animValWillChange(m_animatedProperties);
    136 
    137     // Values-animation accumulates using the last values entry corresponding to the end of duration time.
    138     SVGAnimatedType* toAtEndOfDurationType = m_toAtEndOfDurationType ? m_toAtEndOfDurationType.get() : m_toType.get();
    139     m_animator->calculateAnimatedValue(percentage, repeatCount, m_fromType.get(), m_toType.get(), toAtEndOfDurationType, resultAnimationElement.m_animatedType.get());
    140 }
    141 
    142 bool SVGAnimateElementBase::calculateToAtEndOfDurationValue(const String& toAtEndOfDurationString)
    143 {
    144     if (toAtEndOfDurationString.isEmpty())
    145         return false;
    146     m_toAtEndOfDurationType = ensureAnimator()->constructFromString(toAtEndOfDurationString);
    147     return true;
    148 }
    149 
    150 bool SVGAnimateElementBase::calculateFromAndToValues(const String& fromString, const String& toString)
    151 {
    152     if (!this->targetElement())
    153         return false;
    154 
    155     determinePropertyValueTypes(fromString, toString);
    156     ensureAnimator()->calculateFromAndToValues(m_fromType, m_toType, fromString, toString);
     42SVGLegacyAttributeAnimationController::SVGLegacyAttributeAnimationController(SVGAnimationElement& animationElement, SVGElement& targetElement)
     43    : SVGAttributeAnimationControllerBase(animationElement, targetElement)
     44    , m_animatedPropertyType(determineAnimatedPropertyType(animationElement, targetElement, animationElement.attributeName()))
     45{
     46}
     47
     48SVGAnimatedTypeAnimator& SVGLegacyAttributeAnimationController::animatedTypeAnimator()
     49{
     50    if (!m_animator)
     51        m_animator = SVGAnimatorFactory::create(&m_animationElement, &m_targetElement, m_animatedPropertyType);
    15752    ASSERT(m_animatedPropertyType == m_animator->type());
    158     return true;
    159 }
    160 
    161 bool SVGAnimateElementBase::calculateFromAndByValues(const String& fromString, const String& byString)
    162 {
    163     if (!this->targetElement())
    164         return false;
    165 
    166     if (animationMode() == AnimationMode::By && !isAdditive())
    167         return false;
    168 
    169     // from-by animation may only be used with attributes that support addition (e.g. most numeric attributes).
    170     if (animationMode() == AnimationMode::FromBy && !animatedPropertyTypeSupportsAddition())
    171         return false;
    172 
    173     ASSERT(!hasTagName(SVGNames::setTag));
    174 
    175     determinePropertyValueTypes(fromString, byString);
    176     ensureAnimator()->calculateFromAndByValues(m_fromType, m_toType, fromString, byString);
    177     ASSERT(m_animatedPropertyType == m_animator->type());
    178     return true;
    179 }
    180 
    181 #ifndef NDEBUG
    182 static inline bool propertyTypesAreConsistent(AnimatedPropertyType expectedPropertyType, const SVGElementAnimatedPropertyList& animatedTypes)
    183 {
    184     for (auto& type : animatedTypes) {
    185         for (auto& property : type.properties) {
    186             if (expectedPropertyType != property->animatedPropertyType()) {
    187                 // This is the only allowed inconsistency. SVGAnimatedAngleAnimator handles both SVGAnimatedAngle & SVGAnimatedEnumeration for markers orient attribute.
    188                 if (expectedPropertyType == AnimatedAngle && property->animatedPropertyType() == AnimatedEnumeration)
    189                     return true;
    190                 return false;
    191             }
    192         }
    193     }
    194 
    195     return true;
    196 }
    197 #endif
    198 
    199 void SVGAnimateElementBase::resetAnimatedType()
    200 {
    201     SVGAnimatedTypeAnimator* animator = ensureAnimator();
    202     ASSERT(m_animatedPropertyType == animator->type());
    203 
    204     auto targetElement = makeRefPtr(this->targetElement());
    205     if (!targetElement)
    206         return;
    207 
    208     const QualifiedName& attributeName = this->attributeName();
    209     ShouldApplyAnimation shouldApply = shouldApplyAnimation(targetElement.get(), attributeName);
    210 
    211     if (shouldApply == DontApplyAnimation)
    212         return;
    213 
    214     if (shouldApply == ApplyXMLAnimation || shouldApply == ApplyXMLandCSSAnimation) {
    215         // SVG DOM animVal animation code-path.
    216         m_animatedProperties = animator->findAnimatedPropertiesForAttributeName(*targetElement, attributeName);
    217         if (m_animatedProperties.isEmpty())
    218             return;
    219 
    220         ASSERT(propertyTypesAreConsistent(m_animatedPropertyType, m_animatedProperties));
    221         if (!m_animatedType)
    222             m_animatedType = animator->startAnimValAnimation(m_animatedProperties);
    223         else {
    224             animator->resetAnimValToBaseVal(m_animatedProperties, *m_animatedType);
    225             animator->animValDidChange(m_animatedProperties);
    226         }
    227         return;
    228     }
    229 
    230     // CSS properties animation code-path.
    231     ASSERT(m_animatedProperties.isEmpty());
    232     String baseValue;
    233 
    234     if (shouldApply == ApplyCSSAnimation) {
    235         ASSERT(SVGAnimationElement::isTargetAttributeCSSProperty(targetElement.get(), attributeName));
    236         computeCSSPropertyValue(targetElement.get(), cssPropertyID(attributeName.localName()), baseValue);
    237     }
    238 
    239     if (!m_animatedType)
    240         m_animatedType = animator->constructFromString(baseValue);
    241     else
    242         m_animatedType->setValueAsString(attributeName, baseValue);
    243 }
    244 
    245 static inline void applyCSSPropertyToTarget(SVGElement& targetElement, CSSPropertyID id, const String& value)
    246 {
    247     ASSERT(!targetElement.m_deletionHasBegun);
    248 
    249     if (!targetElement.ensureAnimatedSMILStyleProperties().setProperty(id, value, false))
    250         return;
    251 
    252     targetElement.invalidateStyle();
    253 }
    254 
    255 static inline void removeCSSPropertyFromTarget(SVGElement& targetElement, CSSPropertyID id)
    256 {
    257     ASSERT(!targetElement.m_deletionHasBegun);
    258     targetElement.ensureAnimatedSMILStyleProperties().removeProperty(id);
    259     targetElement.invalidateStyle();
    260 }
    261 
    262 static inline void applyCSSPropertyToTargetAndInstances(SVGElement& targetElement, const QualifiedName& attributeName, const String& valueAsString)
    263 {
    264     // FIXME: Do we really need to check both isConnected and !parentNode?
    265     if (attributeName == anyQName() || !targetElement.isConnected() || !targetElement.parentNode())
    266         return;
    267 
    268     CSSPropertyID id = cssPropertyID(attributeName.localName());
    269 
    270     SVGElement::InstanceUpdateBlocker blocker(targetElement);
    271     applyCSSPropertyToTarget(targetElement, id, valueAsString);
    272 
    273     // If the target element has instances, update them as well, w/o requiring the <use> tree to be rebuilt.
    274     for (auto* instance : targetElement.instances())
    275         applyCSSPropertyToTarget(*instance, id, valueAsString);
    276 }
    277 
    278 static inline void removeCSSPropertyFromTargetAndInstances(SVGElement& targetElement, const QualifiedName& attributeName)
    279 {
    280     // FIXME: Do we really need to check both isConnected and !parentNode?
    281     if (attributeName == anyQName() || !targetElement.isConnected() || !targetElement.parentNode())
    282         return;
    283 
    284     CSSPropertyID id = cssPropertyID(attributeName.localName());
    285 
    286     SVGElement::InstanceUpdateBlocker blocker(targetElement);
    287     removeCSSPropertyFromTarget(targetElement, id);
    288 
    289     // If the target element has instances, update them as well, w/o requiring the <use> tree to be rebuilt.
    290     for (auto* instance : targetElement.instances())
    291         removeCSSPropertyFromTarget(*instance, id);
    292 }
    293 
    294 static inline void notifyTargetAboutAnimValChange(SVGElement& targetElement, const QualifiedName& attributeName)
    295 {
    296     ASSERT(!targetElement.m_deletionHasBegun);
    297     targetElement.svgAttributeChanged(attributeName);
    298 }
    299 
    300 static inline void notifyTargetAndInstancesAboutAnimValChange(SVGElement& targetElement, const QualifiedName& attributeName)
    301 {
    302     if (attributeName == anyQName() || !targetElement.isConnected() || !targetElement.parentNode())
    303         return;
    304 
    305     SVGElement::InstanceUpdateBlocker blocker(targetElement);
    306     notifyTargetAboutAnimValChange(targetElement, attributeName);
    307 
    308     // If the target element has instances, update them as well, w/o requiring the <use> tree to be rebuilt.
    309     for (auto* instance : targetElement.instances())
    310         notifyTargetAboutAnimValChange(*instance, attributeName);
    311 }
    312 
    313 void SVGAnimateElementBase::clearAnimatedType(SVGElement* targetElement)
    314 {
    315     if (!m_animatedType)
    316         return;
    317 
    318     // If the SVGAnimatedType is a list type, e.g. SVGLengthListValues, the wrappers of the
    319     // animated properties have to be detached from the items in the list before it's deleted.
    320     if (!m_animatedProperties.isEmpty())
    321         m_animator->animValWillChange(m_animatedProperties);
    322 
    323     if (!targetElement) {
    324         m_animatedType = nullptr;
    325         return;
    326     }
    327 
    328     if (m_animatedProperties.isEmpty()) {
    329         // CSS properties animation code-path.
    330         removeCSSPropertyFromTargetAndInstances(*targetElement, attributeName());
    331         m_animatedType = nullptr;
    332         return;
    333     }
    334 
    335     ShouldApplyAnimation shouldApply = shouldApplyAnimation(targetElement, attributeName());
    336     if (shouldApply == ApplyXMLandCSSAnimation)
    337         removeCSSPropertyFromTargetAndInstances(*targetElement, attributeName());
    338 
    339     // SVG DOM animVal animation code-path.
    340     if (m_animator) {
    341         m_animator->stopAnimValAnimation(m_animatedProperties);
    342         notifyTargetAndInstancesAboutAnimValChange(*targetElement, attributeName());
    343     }
    344 
    345     m_animatedProperties.clear();
    346     m_animatedType = nullptr;
    347 }
    348 
    349 void SVGAnimateElementBase::applyResultsToTarget()
    350 {
    351     ASSERT(m_animatedPropertyType != AnimatedTransformList || hasTagName(SVGNames::animateTransformTag));
    352     ASSERT(m_animatedPropertyType != AnimatedUnknown);
    353     ASSERT(m_animator);
    354 
    355     // Early exit if our animated type got destroyed by a previous endedActiveInterval().
    356     if (!m_animatedType)
    357         return;
    358 
    359     auto targetElement = makeRefPtr(this->targetElement());
    360     const QualifiedName& attributeName = this->attributeName();
    361 
    362     ASSERT(targetElement);
    363 
    364     if (m_animatedProperties.isEmpty()) {
    365         // CSS properties animation code-path.
    366         // Convert the result of the animation to a String and apply it as CSS property on the target & all instances.
    367         applyCSSPropertyToTargetAndInstances(*targetElement, attributeName, m_animatedType->valueAsString());
    368         return;
    369     }
    370 
    371     // We do update the style and the animation property independent of each other.
    372     ShouldApplyAnimation shouldApply = shouldApplyAnimation(targetElement.get(), attributeName);
    373     if (shouldApply == ApplyXMLandCSSAnimation)
    374         applyCSSPropertyToTargetAndInstances(*targetElement, attributeName, m_animatedType->valueAsString());
    375 
    376     // SVG DOM animVal animation code-path.
    377     // At this point the SVG DOM values are already changed, unlike for CSS.
    378     // We only have to trigger update notifications here.
    379     m_animator->animValDidChange(m_animatedProperties);
    380     notifyTargetAndInstancesAboutAnimValChange(*targetElement, attributeName);
    381 }
    382 
    383 bool SVGAnimateElementBase::animatedPropertyTypeSupportsAddition() const
     53    return *m_animator;
     54}
     55
     56bool SVGLegacyAttributeAnimationController::isAdditive() const
    38457{
    38558    // Spec: http://www.w3.org/TR/SVG/animate.html#AnimationAttributesAndProperties.
     
    41184}
    41285
    413 bool SVGAnimateElementBase::isAdditive() const
    414 {
    415     if (animationMode() == AnimationMode::By || animationMode() == AnimationMode::FromBy) {
    416         if (!animatedPropertyTypeSupportsAddition())
    417             return false;
    418     }
    419 
    420     return SVGAnimationElement::isAdditive();
    421 }
    422 
    423 float SVGAnimateElementBase::calculateDistance(const String& fromString, const String& toString)
    424 {
    425     // FIXME: A return value of float is not enough to support paced animations on lists.
    426     if (!this->targetElement())
    427         return -1;
    428 
    429     return ensureAnimator()->calculateDistance(fromString, toString);
    430 }
    431 
    432 void SVGAnimateElementBase::setTargetElement(SVGElement* target)
    433 {
    434     SVGAnimationElement::setTargetElement(target);
    435     resetAnimatedPropertyType();
    436 }
    437 
    438 void SVGAnimateElementBase::setAttributeName(const QualifiedName& attributeName)
    439 {
    440     SVGSMILElement::setAttributeName(attributeName);
    441     checkInvalidCSSAttributeType(targetElement());
    442     resetAnimatedPropertyType();
    443 }
    444 
    445 void SVGAnimateElementBase::resetAnimatedPropertyType()
    446 {
    447     SVGAnimationElement::resetAnimatedPropertyType();
    448     ASSERT(!m_animatedType);
    449     m_fromType = nullptr;
    450     m_toType = nullptr;
    451     m_toAtEndOfDurationType = nullptr;
    452     m_animator = nullptr;
    453     m_animatedPropertyType = targetElement() ? determineAnimatedPropertyType(*targetElement()) : AnimatedString;
    454 }
    455 
    456 SVGAnimatedTypeAnimator* SVGAnimateElementBase::ensureAnimator()
    457 {
    458     if (!m_animator)
    459         m_animator = SVGAnimatorFactory::create(this, targetElement(), m_animatedPropertyType);
     86bool SVGLegacyAttributeAnimationController::hasValidAttributeType() const
     87{
     88    return m_animatedPropertyType != AnimatedUnknown;
     89}
     90
     91bool SVGLegacyAttributeAnimationController::calculateFromAndToValues(const String& fromString, const String& toString)
     92{
     93    m_animationElement.determinePropertyValueTypes(fromString, toString);
     94    animatedTypeAnimator().calculateFromAndToValues(m_fromType, m_toType, fromString, toString);
    46095    ASSERT(m_animatedPropertyType == m_animator->type());
    461     return m_animator.get();
    462 }
    463 
    464 } // namespace WebCore
     96    return true;
     97}
     98
     99bool SVGLegacyAttributeAnimationController::calculateFromAndByValues(const String& fromString, const String& byString)
     100{
     101    if (m_animationElement.animationMode() == AnimationMode::By && !isAdditive())
     102        return false;
     103
     104    // from-by animation may only be used with attributes that support addition (e.g. most numeric attributes).
     105    if (m_animationElement.animationMode() == AnimationMode::FromBy && !isAdditive())
     106        return false;
     107
     108    m_animationElement.determinePropertyValueTypes(fromString, byString);
     109    animatedTypeAnimator().calculateFromAndByValues(m_fromType, m_toType, fromString, byString);
     110    ASSERT(m_animatedPropertyType == m_animator->type());
     111    return true;
     112}
     113
     114bool SVGLegacyAttributeAnimationController::calculateToAtEndOfDurationValue(const String& toAtEndOfDurationString)
     115{
     116    if (toAtEndOfDurationString.isEmpty())
     117        return false;
     118    m_toAtEndOfDurationType = animatedTypeAnimator().constructFromString(toAtEndOfDurationString);
     119    return true;
     120}
     121
     122#ifndef NDEBUG
     123static inline bool propertyTypesAreConsistent(AnimatedPropertyType expectedPropertyType, const SVGElementAnimatedPropertyList& animatedTypes)
     124{
     125    for (auto& type : animatedTypes) {
     126        for (auto& property : type.properties) {
     127            if (expectedPropertyType != property->animatedPropertyType()) {
     128                // This is the only allowed inconsistency. SVGAnimatedAngleAnimator handles both SVGAnimatedAngle & SVGAnimatedEnumeration for markers orient attribute.
     129                if (expectedPropertyType == AnimatedAngle && property->animatedPropertyType() == AnimatedEnumeration)
     130                    return true;
     131                return false;
     132            }
     133        }
     134    }
     135
     136    return true;
     137}
     138#endif
     139
     140void SVGLegacyAttributeAnimationController::resetAnimatedType()
     141{
     142    SVGAnimatedTypeAnimator& animator = animatedTypeAnimator();
     143    ASSERT(m_animatedPropertyType == animator.type());
     144
     145    const QualifiedName& attributeName = m_animationElement.attributeName();
     146    SVGAnimationElement::ShouldApplyAnimation shouldApply = m_animationElement.shouldApplyAnimation(&m_targetElement, attributeName);
     147
     148    if (shouldApply == SVGAnimationElement::DontApplyAnimation)
     149        return;
     150
     151    if (shouldApply == SVGAnimationElement::ApplyXMLAnimation || shouldApply == SVGAnimationElement::ApplyXMLandCSSAnimation) {
     152        // SVG DOM animVal animation code-path.
     153        m_animatedProperties = animator.findAnimatedPropertiesForAttributeName(m_targetElement, attributeName);
     154        if (m_animatedProperties.isEmpty())
     155            return;
     156
     157        ASSERT(propertyTypesAreConsistent(m_animatedPropertyType, m_animatedProperties));
     158        if (!m_animatedType)
     159            m_animatedType = animator.startAnimValAnimation(m_animatedProperties);
     160        else {
     161            animator.resetAnimValToBaseVal(m_animatedProperties, *m_animatedType);
     162            animator.animValDidChange(m_animatedProperties);
     163        }
     164        return;
     165    }
     166
     167    // CSS properties animation code-path.
     168    ASSERT(m_animatedProperties.isEmpty());
     169    String baseValue;
     170
     171    if (shouldApply == SVGAnimationElement::ApplyCSSAnimation) {
     172        ASSERT(SVGAnimationElement::isTargetAttributeCSSProperty(&m_targetElement, attributeName));
     173        m_animationElement.computeCSSPropertyValue(&m_targetElement, cssPropertyID(attributeName.localName()), baseValue);
     174    }
     175
     176    if (!m_animatedType)
     177        m_animatedType = animator.constructFromString(baseValue);
     178    else
     179        m_animatedType->setValueAsString(attributeName, baseValue);
     180}
     181
     182void SVGLegacyAttributeAnimationController::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGSMILElement* resultElement)
     183{
     184    ASSERT(resultElement);
     185
     186    const QualifiedName& attributeName = m_animationElement.attributeName();
     187    SVGAnimationElement::ShouldApplyAnimation shouldApply = m_animationElement.shouldApplyAnimation(&m_targetElement, attributeName);
     188   
     189    if (shouldApply == SVGAnimationElement::DontApplyAnimation)
     190        return;
     191
     192    ASSERT(m_animatedPropertyType == determineAnimatedPropertyType(m_animationElement, m_targetElement, attributeName));
     193
     194    ASSERT(percentage >= 0 && percentage <= 1);
     195    ASSERT(m_animatedPropertyType != AnimatedTransformList || m_animationElement.hasTagName(SVGNames::animateTransformTag));
     196    ASSERT(m_animatedPropertyType != AnimatedUnknown);
     197    ASSERT(m_animator);
     198    ASSERT(m_animator->type() == m_animatedPropertyType);
     199    ASSERT(m_fromType);
     200    ASSERT(m_fromType->type() == m_animatedPropertyType);
     201    ASSERT(m_toType);
     202
     203    if (shouldApply == SVGAnimationElement::ApplyXMLAnimation || shouldApply == SVGAnimationElement::ApplyXMLandCSSAnimation) {
     204        // SVG DOM animVal animation code-path.
     205        if (m_animator->findAnimatedPropertiesForAttributeName(m_targetElement, attributeName).isEmpty())
     206            return;
     207    }
     208
     209    SVGAnimateElementBase& resultAnimationElement = downcast<SVGAnimateElementBase>(*resultElement);
     210    SVGLegacyAttributeAnimationController& resultAnimationController = static_cast<SVGLegacyAttributeAnimationController&>(resultAnimationElement.attributeAnimationController());
     211   
     212    ASSERT(resultAnimationController.m_animatedType);
     213    ASSERT(resultAnimationController.m_animatedPropertyType == m_animatedPropertyType);
     214
     215    if (m_animationElement.hasTagName(SVGNames::setTag))
     216        percentage = 1;
     217
     218    if (m_animationElement.calcMode() == CalcMode::Discrete)
     219        percentage = percentage < 0.5 ? 0 : 1;
     220
     221    // Target element might have changed.
     222    m_animator->setContextElement(&m_targetElement);
     223
     224    // Be sure to detach list wrappers before we modfiy their underlying value. If we'd do
     225    // if after calculateAnimatedValue() ran the cached pointers in the list propery tear
     226    // offs would point nowhere, and we couldn't create copies of those values anymore,
     227    // while detaching. This is covered by assertions, moving this down would fire them.
     228    if (!m_animatedProperties.isEmpty())
     229        m_animator->animValWillChange(m_animatedProperties);
     230
     231    // Values-animation accumulates using the last values entry corresponding to the end of duration time.
     232    SVGAnimatedType* toAtEndOfDurationType = m_toAtEndOfDurationType ? m_toAtEndOfDurationType.get() : m_toType.get();
     233    m_animator->calculateAnimatedValue(percentage, repeatCount, m_fromType.get(), m_toType.get(), toAtEndOfDurationType, resultAnimationController.m_animatedType.get());
     234}
     235
     236static inline void applyCSSPropertyToTarget(SVGElement& targetElement, CSSPropertyID id, const String& value)
     237{
     238    ASSERT(!targetElement.m_deletionHasBegun);
     239
     240    if (!targetElement.ensureAnimatedSMILStyleProperties().setProperty(id, value, false))
     241        return;
     242
     243    targetElement.invalidateStyle();
     244}
     245
     246static inline void removeCSSPropertyFromTarget(SVGElement& targetElement, CSSPropertyID id)
     247{
     248    ASSERT(!targetElement.m_deletionHasBegun);
     249    targetElement.ensureAnimatedSMILStyleProperties().removeProperty(id);
     250    targetElement.invalidateStyle();
     251}
     252
     253static inline void applyCSSPropertyToTargetAndInstances(SVGElement& targetElement, const QualifiedName& attributeName, const String& valueAsString)
     254{
     255    // FIXME: Do we really need to check both isConnected and !parentNode?
     256    if (attributeName == anyQName() || !targetElement.isConnected() || !targetElement.parentNode())
     257        return;
     258
     259    CSSPropertyID id = cssPropertyID(attributeName.localName());
     260
     261    SVGElement::InstanceUpdateBlocker blocker(targetElement);
     262    applyCSSPropertyToTarget(targetElement, id, valueAsString);
     263
     264    // If the target element has instances, update them as well, w/o requiring the <use> tree to be rebuilt.
     265    for (auto* instance : targetElement.instances())
     266        applyCSSPropertyToTarget(*instance, id, valueAsString);
     267}
     268
     269static inline void removeCSSPropertyFromTargetAndInstances(SVGElement& targetElement, const QualifiedName& attributeName)
     270{
     271    // FIXME: Do we really need to check both isConnected and !parentNode?
     272    if (attributeName == anyQName() || !targetElement.isConnected() || !targetElement.parentNode())
     273        return;
     274
     275    CSSPropertyID id = cssPropertyID(attributeName.localName());
     276
     277    SVGElement::InstanceUpdateBlocker blocker(targetElement);
     278    removeCSSPropertyFromTarget(targetElement, id);
     279
     280    // If the target element has instances, update them as well, w/o requiring the <use> tree to be rebuilt.
     281    for (auto* instance : targetElement.instances())
     282        removeCSSPropertyFromTarget(*instance, id);
     283}
     284
     285static inline void notifyTargetAboutAnimValChange(SVGElement& targetElement, const QualifiedName& attributeName)
     286{
     287    ASSERT(!targetElement.m_deletionHasBegun);
     288    targetElement.svgAttributeChanged(attributeName);
     289}
     290
     291static inline void notifyTargetAndInstancesAboutAnimValChange(SVGElement& targetElement, const QualifiedName& attributeName)
     292{
     293    if (attributeName == anyQName() || !targetElement.isConnected() || !targetElement.parentNode())
     294        return;
     295
     296    SVGElement::InstanceUpdateBlocker blocker(targetElement);
     297    notifyTargetAboutAnimValChange(targetElement, attributeName);
     298
     299    // If the target element has instances, update them as well, w/o requiring the <use> tree to be rebuilt.
     300    for (auto* instance : targetElement.instances())
     301        notifyTargetAboutAnimValChange(*instance, attributeName);
     302}
     303
     304void SVGLegacyAttributeAnimationController::applyResultsToTarget()
     305{
     306    ASSERT(m_animatedPropertyType != AnimatedTransformList || m_animationElement.hasTagName(SVGNames::animateTransformTag));
     307    ASSERT(m_animatedPropertyType != AnimatedUnknown);
     308    ASSERT(m_animator);
     309
     310    // Early exit if our animated type got destroyed by a previous endedActiveInterval().
     311    if (!m_animatedType)
     312        return;
     313
     314    const QualifiedName& attributeName = m_animationElement.attributeName();
     315
     316    if (m_animatedProperties.isEmpty()) {
     317        // CSS properties animation code-path.
     318        // Convert the result of the animation to a String and apply it as CSS property on the target & all instances.
     319        applyCSSPropertyToTargetAndInstances(m_targetElement, attributeName, m_animatedType->valueAsString());
     320        return;
     321    }
     322
     323    // We do update the style and the animation property independent of each other.
     324    SVGAnimationElement::ShouldApplyAnimation shouldApply = m_animationElement.shouldApplyAnimation(&m_targetElement, attributeName);
     325    if (shouldApply == SVGAnimationElement::ApplyXMLandCSSAnimation)
     326        applyCSSPropertyToTargetAndInstances(m_targetElement, attributeName, m_animatedType->valueAsString());
     327
     328    // SVG DOM animVal animation code-path.
     329    // At this point the SVG DOM values are already changed, unlike for CSS.
     330    // We only have to trigger update notifications here.
     331    m_animator->animValDidChange(m_animatedProperties);
     332    notifyTargetAndInstancesAboutAnimValChange(m_targetElement, attributeName);
     333}
     334
     335void SVGLegacyAttributeAnimationController::clearAnimatedType(SVGElement* targetElement)
     336{
     337    if (!m_animatedType)
     338        return;
     339
     340    // If the SVGAnimatedType is a list type, e.g. SVGLengthListValues, the wrappers of the
     341    // animated properties have to be detached from the items in the list before it's deleted.
     342    if (!m_animatedProperties.isEmpty())
     343        m_animator->animValWillChange(m_animatedProperties);
     344
     345    if (!targetElement) {
     346        m_animatedType = nullptr;
     347        return;
     348    }
     349
     350    const QualifiedName& attributeName = m_animationElement.attributeName();
     351
     352    if (m_animatedProperties.isEmpty()) {
     353        // CSS properties animation code-path.
     354        removeCSSPropertyFromTargetAndInstances(*targetElement, m_animationElement.attributeName());
     355        m_animatedType = nullptr;
     356        return;
     357    }
     358
     359    SVGAnimationElement::ShouldApplyAnimation shouldApply = m_animationElement.shouldApplyAnimation(targetElement, attributeName);
     360    if (shouldApply == SVGAnimationElement::ApplyXMLandCSSAnimation)
     361        removeCSSPropertyFromTargetAndInstances(*targetElement, attributeName);
     362
     363    // SVG DOM animVal animation code-path.
     364    if (m_animator) {
     365        m_animator->stopAnimValAnimation(m_animatedProperties);
     366        notifyTargetAndInstancesAboutAnimValChange(*targetElement, attributeName);
     367    }
     368
     369    m_animatedProperties.clear();
     370    m_animatedType = nullptr;
     371}
     372
     373float SVGLegacyAttributeAnimationController::calculateDistance(const String& fromString, const String& toString)
     374{
     375    return animatedTypeAnimator().calculateDistance(fromString, toString);
     376}
     377
     378}
     379
  • trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp

    r240237 r243036  
    310310}
    311311
    312 bool SVGSMILElement::hasValidAttributeName()
     312bool SVGSMILElement::hasValidAttributeName() const
    313313{
    314314    return attributeName() != anyQName();
  • trunk/Source/WebCore/svg/animation/SVGSMILElement.h

    r229694 r243036  
    5252    void removedFromAncestor(RemovalType, ContainerNode&) override;
    5353   
    54     virtual bool hasValidAttributeType() = 0;
    55     virtual bool hasValidAttributeName();
     54    virtual bool hasValidAttributeType() const = 0;
     55    virtual bool hasValidAttributeName() const;
    5656    virtual void animationAttributeChanged() = 0;
    5757
  • trunk/Source/WebCore/svg/properties/SVGAnimatedProperty.cpp

    r243035 r243036  
    11/*
    2  * Copyright (C) 2018 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2018-2019 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2525
    2626#include "config.h"
    27 #include "SVGAttributeOwnerProxy.h"
     27#include "SVGAnimatedProperty.h"
     28
     29#include "SVGElement.h"
    2830
    2931namespace WebCore {
    3032
    31 SVGAttributeOwnerProxy::SVGAttributeOwnerProxy(SVGElement& element)
    32     : m_element(makeWeakPtr(element))
     33SVGPropertyOwner* SVGAnimatedProperty::owner() const
    3334{
     35    return m_contextElement;
    3436}
    3537
    36 SVGElement& SVGAttributeOwnerProxy::element() const
     38void SVGAnimatedProperty::commitPropertyChange()
    3739{
    38     return *m_element;
     40    if (!m_contextElement)
     41        return;
     42    m_contextElement->commitPropertyChange(*this);
    3943}
    4044
  • trunk/Source/WebCore/svg/properties/SVGAnimatedPropertyAccessor.h

    r243035 r243036  
    11/*
    2  * Copyright (C) 2018 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2018-2019 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #include "config.h"
    27 #include "SVGAttributeOwnerProxy.h"
     26#pragma once
     27
     28#include "SVGPointerMemberAccessor.h"
    2829
    2930namespace WebCore {
    3031
    31 SVGAttributeOwnerProxy::SVGAttributeOwnerProxy(SVGElement& element)
    32     : m_element(makeWeakPtr(element))
    33 {
    34 }
     32template<typename OwnerType, typename AnimatedPropertyType>
     33class SVGAnimatedPropertyAccessor : public SVGPointerMemberAccessor<OwnerType, AnimatedPropertyType> {
     34    using Base = SVGPointerMemberAccessor<OwnerType, AnimatedPropertyType>;
    3535
    36 SVGElement& SVGAttributeOwnerProxy::element() const
    37 {
    38     return *m_element;
    39 }
     36public:
     37    using Base::Base;
     38    using Base::singleton;
     39    using Base::property;
     40    using AnimatedProperty = AnimatedPropertyType;
     41
     42    bool matches(const OwnerType& owner, const SVGAnimatedProperty& animatedProperty) const override
     43    {
     44        return property(owner).ptr() == &animatedProperty;
     45    }
     46
     47private:
     48    bool isAnimatedProperty() const override { return true; }
     49};
    4050
    4151}
  • trunk/Source/WebCore/svg/properties/SVGAnimatedPropertyAccessorImpl.h

    r243035 r243036  
    11/*
    2  * Copyright (C) 2018 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2018-2019 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
    28 #include "SVGAnimatedPropertyType.h"
    29 #include <wtf/WeakPtr.h>
     28#include "SVGAnimatedPropertyAccessor.h"
     29#include "SVGAnimatedPropertyAnimatorImpl.h"
     30#include "SVGAnimatedPropertyImpl.h"
     31#include "SVGNames.h"
    3032
    3133namespace WebCore {
    3234
    33 class SVGAttribute;
    34 class SVGElement;
    35 class SVGLegacyAnimatedProperty;
     35template<typename OwnerType>
     36class SVGAnimatedIntegerAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedInteger> {
     37    using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedInteger>;
    3638
    37 class SVGAttributeOwnerProxy {
    3839public:
    39     SVGAttributeOwnerProxy(SVGElement&);
     40    using Base::Base;
     41    using Base::property;
     42    template<Ref<SVGAnimatedInteger> OwnerType::*property>
     43    constexpr static const SVGMemberAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedIntegerAccessor, property>(); }
    4044
    41     virtual ~SVGAttributeOwnerProxy() = default;
     45private:
     46    std::unique_ptr<SVGAttributeAnimator> createAnimator(OwnerType& owner, const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) const final
     47    {
     48        return SVGAnimatedIntegerAnimator::create(attributeName, property(owner), animationMode, calcMode, isAccumulated, isAdditive);
     49    }
    4250
    43     SVGElement& element() const;
    44 
    45     virtual void synchronizeAttributes() const = 0;
    46     virtual void synchronizeAttribute(const QualifiedName&) const = 0;
    47 
    48     virtual Vector<AnimatedPropertyType> animatedTypes(const QualifiedName&) const = 0;
    49 
    50     virtual RefPtr<SVGLegacyAnimatedProperty> lookupOrCreateAnimatedProperty(const SVGAttribute&) const = 0;
    51     virtual RefPtr<SVGLegacyAnimatedProperty> lookupAnimatedProperty(const SVGAttribute&) const = 0;
    52     virtual Vector<RefPtr<SVGLegacyAnimatedProperty>> lookupOrCreateAnimatedProperties(const QualifiedName&) const = 0;
    53 
    54 protected:
    55     WeakPtr<SVGElement> m_element;
     51    void appendAnimatedInstance(OwnerType& owner, SVGAttributeAnimator& animator) const final
     52    {
     53        static_cast<SVGAnimatedIntegerAnimator&>(animator).appendAnimatedInstance(property(owner));
     54    }
    5655};
    5756
  • trunk/Source/WebCore/svg/properties/SVGAnimatedPropertyAnimatorImpl.h

    r243035 r243036  
    11/*
    2  * Copyright (C) 2018 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2018-2019 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
    28 #include "SVGAnimatedPropertyType.h"
    29 #include <wtf/WeakPtr.h>
     28#include "SVGAnimatedPropertyAnimator.h"
     29#include "SVGAnimatedPropertyImpl.h"
     30#include "SVGAnimationAdditiveValueFunctionImpl.h"
    3031
    3132namespace WebCore {
    3233
    33 class SVGAttribute;
    34 class SVGElement;
    35 class SVGLegacyAnimatedProperty;
     34class SVGAnimatedIntegerPairAnimator;
    3635
    37 class SVGAttributeOwnerProxy {
     36template<typename AnimatedPropertyAnimator1, typename AnimatedPropertyAnimator2>
     37class SVGAnimatedPropertyPairAnimator;
     38
     39class SVGAnimatedIntegerAnimator final : public SVGAnimatedPropertyAnimator<SVGAnimatedInteger, SVGAnimationIntegerFunction> {
     40    friend class SVGAnimatedPropertyPairAnimator<SVGAnimatedIntegerAnimator, SVGAnimatedIntegerAnimator>;
     41    friend class SVGAnimatedIntegerPairAnimator;
     42    using Base = SVGAnimatedPropertyAnimator<SVGAnimatedInteger, SVGAnimationIntegerFunction>;
     43    using Base::Base;
     44
    3845public:
    39     SVGAttributeOwnerProxy(SVGElement&);
     46    static auto create(const QualifiedName& attributeName, Ref<SVGAnimatedInteger>& animated, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive)
     47    {
     48        return std::unique_ptr<SVGAnimatedIntegerAnimator>(new SVGAnimatedIntegerAnimator(attributeName, animated, animationMode, calcMode, isAccumulated, isAdditive));
     49    }
    4050
    41     virtual ~SVGAttributeOwnerProxy() = default;
    42 
    43     SVGElement& element() const;
    44 
    45     virtual void synchronizeAttributes() const = 0;
    46     virtual void synchronizeAttribute(const QualifiedName&) const = 0;
    47 
    48     virtual Vector<AnimatedPropertyType> animatedTypes(const QualifiedName&) const = 0;
    49 
    50     virtual RefPtr<SVGLegacyAnimatedProperty> lookupOrCreateAnimatedProperty(const SVGAttribute&) const = 0;
    51     virtual RefPtr<SVGLegacyAnimatedProperty> lookupAnimatedProperty(const SVGAttribute&) const = 0;
    52     virtual Vector<RefPtr<SVGLegacyAnimatedProperty>> lookupOrCreateAnimatedProperties(const QualifiedName&) const = 0;
    53 
    54 protected:
    55     WeakPtr<SVGElement> m_element;
     51private:
     52    void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) final
     53    {
     54        m_function.progress(targetElement, percentage, repeatCount, m_animated->animVal());
     55    }
    5656};
    5757
  • trunk/Source/WebCore/svg/properties/SVGAnimatedPropertyImpl.h

    r243035 r243036  
    11/*
    2  * Copyright (C) 2018 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2018-2019 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #include "config.h"
    27 #include "SVGAttributeOwnerProxy.h"
     26#pragma once
     27
     28#include "SVGAnimatedAngle.h"
     29#include "SVGAnimatedBoolean.h"
     30#include "SVGAnimatedEnumeration.h"
     31#include "SVGAnimatedLength.h"
     32#include "SVGAnimatedLengthList.h"
     33#include "SVGAnimatedNumber.h"
     34#include "SVGAnimatedNumberList.h"
     35#include "SVGAnimatedPointList.h"
     36#include "SVGAnimatedPreserveAspectRatio.h"
     37#include "SVGAnimatedPrimitiveProperty.h"
     38#include "SVGAnimatedRect.h"
     39#include "SVGAnimatedString.h"
     40#include "SVGAnimatedTransformList.h"
    2841
    2942namespace WebCore {
    3043
    31 SVGAttributeOwnerProxy::SVGAttributeOwnerProxy(SVGElement& element)
    32     : m_element(makeWeakPtr(element))
    33 {
    34 }
    35 
    36 SVGElement& SVGAttributeOwnerProxy::element() const
    37 {
    38     return *m_element;
    39 }
     44using SVGAnimatedInteger = SVGAnimatedPrimitiveProperty<int>;
    4045
    4146}
  • trunk/Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunction.h

    r243035 r243036  
    11/*
    2  * Copyright (C) 2018 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2018-2019 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #include "config.h"
    27 #include "SVGAttributeOwnerProxy.h"
     26#pragma once
     27
     28#include "SVGAnimationAdditiveFunction.h"
    2829
    2930namespace WebCore {
    3031
    31 SVGAttributeOwnerProxy::SVGAttributeOwnerProxy(SVGElement& element)
    32     : m_element(makeWeakPtr(element))
    33 {
    34 }
     32template<typename ValueType>
     33class SVGAnimationAdditiveValueFunction : public SVGAnimationAdditiveFunction {
     34public:
     35    using SVGAnimationAdditiveFunction::SVGAnimationAdditiveFunction;
     36   
     37protected:
     38    ValueType toAtEndOfDuration() const { return m_toAtEndOfDuration ? *m_toAtEndOfDuration : m_to; }
    3539
    36 SVGElement& SVGAttributeOwnerProxy::element() const
    37 {
    38     return *m_element;
    39 }
     40    ValueType m_from;
     41    ValueType m_to;
     42    Optional<ValueType> m_toAtEndOfDuration;
     43};
    4044
    4145}
  • trunk/Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunctionImpl.h

    r243035 r243036  
    11/*
    2  * Copyright (C) 2018 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2018-2019 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
    28 #include "SVGAnimatedPropertyType.h"
    29 #include <wtf/WeakPtr.h>
     28#include "SVGAnimationAdditiveValueFunction.h"
     29#include "SVGPropertyTraits.h"
    3030
    3131namespace WebCore {
    3232
    33 class SVGAttribute;
    34 class SVGElement;
    35 class SVGLegacyAnimatedProperty;
     33class SVGAnimationIntegerFunction : public SVGAnimationAdditiveValueFunction<int> {
     34    friend class SVGAnimatedIntegerPairAnimator;
    3635
    37 class SVGAttributeOwnerProxy {
    3836public:
    39     SVGAttributeOwnerProxy(SVGElement&);
     37    using Base = SVGAnimationAdditiveValueFunction<int>;
     38    using Base::Base;
    4039
    41     virtual ~SVGAttributeOwnerProxy() = default;
     40    void setFromAndToValues(SVGElement*, const String& from, const String& to) override
     41    {
     42        m_from = SVGPropertyTraits<int>::fromString(from);
     43        m_to = SVGPropertyTraits<int>::fromString(to);
     44    }
    4245
    43     SVGElement& element() const;
     46    void setToAtEndOfDurationValue(const String& toAtEndOfDuration) override
     47    {
     48        m_toAtEndOfDuration = SVGPropertyTraits<int>::fromString(toAtEndOfDuration);
     49    }
    4450
    45     virtual void synchronizeAttributes() const = 0;
    46     virtual void synchronizeAttribute(const QualifiedName&) const = 0;
     51    void progress(SVGElement*, float percentage, unsigned repeatCount, int& animated)
     52    {
     53        animated = static_cast<int>(roundf(Base::progress(percentage, repeatCount, m_from, m_to, toAtEndOfDuration(), animated)));
     54    }
    4755
    48     virtual Vector<AnimatedPropertyType> animatedTypes(const QualifiedName&) const = 0;
     56    float calculateDistance(SVGElement*, const String& from, const String& to) const override
     57    {
     58        return std::abs(to.toIntStrict() - from.toIntStrict());
     59    }
    4960
    50     virtual RefPtr<SVGLegacyAnimatedProperty> lookupOrCreateAnimatedProperty(const SVGAttribute&) const = 0;
    51     virtual RefPtr<SVGLegacyAnimatedProperty> lookupAnimatedProperty(const SVGAttribute&) const = 0;
    52     virtual Vector<RefPtr<SVGLegacyAnimatedProperty>> lookupOrCreateAnimatedProperties(const QualifiedName&) const = 0;
    53 
    54 protected:
    55     WeakPtr<SVGElement> m_element;
     61private:
     62    void addFromAndToValues(SVGElement*) override
     63    {
     64        m_to += m_from;
     65    }
    5666};
    5767
  • trunk/Source/WebCore/svg/properties/SVGAnimationFunction.h

    r243035 r243036  
    11/*
    2  * Copyright (C) 2018 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2018-2019 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #include "config.h"
    27 #include "SVGAttributeOwnerProxy.h"
     26#pragma once
    2827
    2928namespace WebCore {
    3029
    31 SVGAttributeOwnerProxy::SVGAttributeOwnerProxy(SVGElement& element)
    32     : m_element(makeWeakPtr(element))
    33 {
    34 }
     30class SVGAnimationFunction {
     31public:
     32    virtual ~SVGAnimationFunction() = default;
    3533
    36 SVGElement& SVGAttributeOwnerProxy::element() const
    37 {
    38     return *m_element;
    39 }
     34    virtual bool isDiscrete() const { return false; }
     35
     36    virtual void setFromAndToValues(SVGElement* targetElement, const String&, const String&) = 0;
     37    virtual void setFromAndByValues(SVGElement* targetElement, const String&, const String&) = 0;
     38    virtual void setToAtEndOfDurationValue(const String&) = 0;
     39
     40    virtual float calculateDistance(SVGElement*, const String&, const String&) const { return -1; }
     41protected:
     42    SVGAnimationFunction(AnimationMode animationMode)
     43        : m_animationMode(animationMode)
     44    {
     45    }
     46
     47    virtual void addFromAndToValues(SVGElement*) { }
     48
     49    AnimationMode m_animationMode;
     50};
    4051
    4152}
  • trunk/Source/WebCore/svg/properties/SVGAttributeAnimator.cpp

    r243035 r243036  
    11/*
    2  * Copyright (C) 2018 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2018-2019 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2525
    2626#include "config.h"
    27 #include "SVGAttributeOwnerProxy.h"
     27#include "SVGAttributeAnimator.h"
     28
     29#include "CSSComputedStyleDeclaration.h"
     30#include "CSSPropertyParser.h"
     31#include "SVGElement.h"
    2832
    2933namespace WebCore {
    3034
    31 SVGAttributeOwnerProxy::SVGAttributeOwnerProxy(SVGElement& element)
    32     : m_element(makeWeakPtr(element))
     35void SVGAttributeAnimator::applyAnimatedPropertyChange(SVGElement* element, const QualifiedName& attributeName)
    3336{
     37    ASSERT(!element->m_deletionHasBegun);
     38    element->svgAttributeChanged(attributeName);
    3439}
    3540
    36 SVGElement& SVGAttributeOwnerProxy::element() const
     41void SVGAttributeAnimator::applyAnimatedPropertyChange(SVGElement* targetElement)
    3742{
    38     return *m_element;
     43    ASSERT(targetElement);
     44    ASSERT(m_attributeName != anyQName());
     45
     46    // FIXME: Do we really need to check both isConnected and !parentNode?
     47    if (!targetElement->isConnected() || !targetElement->parentNode())
     48        return;
     49
     50    SVGElement::InstanceUpdateBlocker blocker(*targetElement);
     51    applyAnimatedPropertyChange(targetElement, m_attributeName);
     52
     53    // If the target element has instances, update them as well, w/o requiring the <use> tree to be rebuilt.
     54    for (auto* instance : targetElement->instances())
     55        applyAnimatedPropertyChange(instance, m_attributeName);
    3956}
    4057
  • trunk/Source/WebCore/svg/properties/SVGAttributeAnimator.h

    r243035 r243036  
    11/*
    2  * Copyright (C) 2018 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2018-2019 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
    28 #include "SVGAnimatedPropertyType.h"
    29 #include <wtf/WeakPtr.h>
     28#include "CSSPropertyNames.h"
     29#include "QualifiedName.h"
     30#include <wtf/RefCounted.h>
     31#include <wtf/StdLibExtras.h>
    3032
    3133namespace WebCore {
    3234
    33 class SVGAttribute;
    3435class SVGElement;
    35 class SVGLegacyAnimatedProperty;
    3636
    37 class SVGAttributeOwnerProxy {
     37enum class AnimationMode : uint8_t {
     38    None,
     39    FromTo,
     40    FromBy,
     41    To,
     42    By,
     43    Values,
     44    Path
     45};
     46
     47enum class CalcMode : uint8_t {
     48    Discrete,
     49    Linear,
     50    Paced,
     51    Spline
     52};
     53
     54class SVGAttributeAnimator {
    3855public:
    39     SVGAttributeOwnerProxy(SVGElement&);
     56    SVGAttributeAnimator(const QualifiedName& attributeName)
     57        : m_attributeName(attributeName)
     58    {
     59    }
    4060
    41     virtual ~SVGAttributeOwnerProxy() = default;
     61    virtual ~SVGAttributeAnimator() = default;
    4262
    43     SVGElement& element() const;
     63    virtual bool isDiscrete() const { return false; }
    4464
    45     virtual void synchronizeAttributes() const = 0;
    46     virtual void synchronizeAttribute(const QualifiedName&) const = 0;
     65    virtual void setFromAndToValues(SVGElement*, const String&, const String&) { }
     66    virtual void setFromAndByValues(SVGElement*, const String&, const String&) { }
     67    virtual void setToAtEndOfDurationValue(const String&) { }
    4768
    48     virtual Vector<AnimatedPropertyType> animatedTypes(const QualifiedName&) const = 0;
     69    virtual void start(SVGElement*) = 0;
     70    virtual void progress(SVGElement*, float, unsigned) = 0;
     71    virtual void apply(SVGElement*) = 0;
     72    virtual void stop(SVGElement* targetElement) = 0;
    4973
    50     virtual RefPtr<SVGLegacyAnimatedProperty> lookupOrCreateAnimatedProperty(const SVGAttribute&) const = 0;
    51     virtual RefPtr<SVGLegacyAnimatedProperty> lookupAnimatedProperty(const SVGAttribute&) const = 0;
    52     virtual Vector<RefPtr<SVGLegacyAnimatedProperty>> lookupOrCreateAnimatedProperties(const QualifiedName&) const = 0;
     74    virtual float calculateDistance(SVGElement*, const String&, const String&) const { return -1; }
    5375
    5476protected:
    55     WeakPtr<SVGElement> m_element;
     77    static void applyAnimatedPropertyChange(SVGElement*, const QualifiedName&);
     78
     79    void applyAnimatedPropertyChange(SVGElement*);
     80
     81    const QualifiedName& m_attributeName;
    5682};
    5783
  • trunk/Source/WebCore/svg/properties/SVGAttributeOwnerProxy.cpp

    r239490 r243036  
    2727#include "SVGAttributeOwnerProxy.h"
    2828
     29#include "SVGElement.h"
     30
    2931namespace WebCore {
    3032
  • trunk/Source/WebCore/svg/properties/SVGAttributeOwnerProxy.h

    r242978 r243036  
    2626#pragma once
    2727
     28#include "QualifiedName.h"
    2829#include "SVGAnimatedPropertyType.h"
    2930#include <wtf/WeakPtr.h>
  • trunk/Source/WebCore/svg/properties/SVGAttributeRegistry.h

    r242978 r243036  
    2828#include "SVGAnimatedBoolean.h"
    2929#include "SVGAnimatedEnumeration.h"
    30 #include "SVGAnimatedInteger.h"
    3130#include "SVGAnimatedLength.h"
    3231#include "SVGAnimatedLengthList.h"
     
    8180    }
    8281
    83     template<const LazyNeverDestroyed<const QualifiedName>& attributeName, SVGAnimatedIntegerAttribute OwnerType::*attribute>
    84     void registerAttribute()
    85     {
    86         registerAttribute(SVGAnimatedIntegerAttributeAccessor<OwnerType>::template singleton<attributeName, attribute>());
    87     }
    88 
    89     template<const LazyNeverDestroyed<const QualifiedName>& attributeName,
    90         const AtomicString& (*identifier)(), SVGAnimatedIntegerAttribute OwnerType::*attribute,
    91         const AtomicString& (*optionalIdentifier)(), SVGAnimatedIntegerAttribute OwnerType::*optionalAttribute>
    92     void registerAttribute()
    93     {
    94         registerAttribute(SVGAnimatedOptionalIntegerAttributeAccessor<OwnerType>::template singleton<attributeName, identifier, attribute, optionalIdentifier, optionalAttribute>());
    95     }
    96 
    9782    template<const LazyNeverDestroyed<const QualifiedName>& attributeName, SVGAnimatedLengthAttribute OwnerType::*attribute>
    9883    void registerAttribute()
  • trunk/Source/WebCore/svg/properties/SVGMemberAccessor.h

    r243035 r243036  
    11/*
    2  * Copyright (C) 2018 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2018-2019 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
    28 #include "SVGAnimatedPropertyType.h"
    29 #include <wtf/WeakPtr.h>
     28#include "QualifiedName.h"
     29#include "SVGAttributeAnimator.h"
    3030
    3131namespace WebCore {
    3232
    33 class SVGAttribute;
    34 class SVGElement;
    35 class SVGLegacyAnimatedProperty;
     33class SVGAnimatedProperty;
    3634
    37 class SVGAttributeOwnerProxy {
     35template<typename OwnerType>
     36class SVGMemberAccessor {
     37    WTF_MAKE_FAST_ALLOCATED;
    3838public:
    39     SVGAttributeOwnerProxy(SVGElement&);
     39    virtual ~SVGMemberAccessor() = default;
    4040
    41     virtual ~SVGAttributeOwnerProxy() = default;
     41    virtual void detach(const OwnerType&) const { }
     42    virtual bool isAnimatedProperty() const { return false; }
     43    virtual bool isAnimatedLength() const { return false; }
    4244
    43     SVGElement& element() const;
     45    virtual bool matches(const OwnerType&, const SVGAnimatedProperty&) const { return false; }
     46    virtual Optional<String> synchronize(const OwnerType&) const { return WTF::nullopt; }
    4447
    45     virtual void synchronizeAttributes() const = 0;
    46     virtual void synchronizeAttribute(const QualifiedName&) const = 0;
    47 
    48     virtual Vector<AnimatedPropertyType> animatedTypes(const QualifiedName&) const = 0;
    49 
    50     virtual RefPtr<SVGLegacyAnimatedProperty> lookupOrCreateAnimatedProperty(const SVGAttribute&) const = 0;
    51     virtual RefPtr<SVGLegacyAnimatedProperty> lookupAnimatedProperty(const SVGAttribute&) const = 0;
    52     virtual Vector<RefPtr<SVGLegacyAnimatedProperty>> lookupOrCreateAnimatedProperties(const QualifiedName&) const = 0;
     48    virtual std::unique_ptr<SVGAttributeAnimator> createAnimator(OwnerType&, const QualifiedName&, AnimationMode, CalcMode, bool, bool) const { return nullptr; }
     49    virtual void appendAnimatedInstance(OwnerType&, SVGAttributeAnimator&) const { }
    5350
    5451protected:
    55     WeakPtr<SVGElement> m_element;
     52    SVGMemberAccessor() = default;
    5653};
    5754
    58 }
     55} // namespace WebCore
  • trunk/Source/WebCore/svg/properties/SVGPointerMemberAccessor.h

    r243035 r243036  
    11/*
    2  * Copyright (C) 2018 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2018-2019 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
    28 #include "SVGAnimatedPropertyType.h"
    29 #include <wtf/WeakPtr.h>
     28#include "SVGMemberAccessor.h"
    3029
    3130namespace WebCore {
    3231
    33 class SVGAttribute;
    34 class SVGElement;
    35 class SVGLegacyAnimatedProperty;
     32template<typename OwnerType, typename PropertyType>
     33class SVGPointerMemberAccessor : public SVGMemberAccessor<OwnerType> {
     34    using Base = SVGMemberAccessor<OwnerType>;
    3635
    37 class SVGAttributeOwnerProxy {
    3836public:
    39     SVGAttributeOwnerProxy(SVGElement&);
     37    SVGPointerMemberAccessor(Ref<PropertyType> OwnerType::*property)
     38        : m_property(property)
     39    {
     40    }
    4041
    41     virtual ~SVGAttributeOwnerProxy() = default;
     42    Ref<PropertyType>& property(OwnerType& owner) const { return owner.*m_property; }
     43    const Ref<PropertyType>& property(const OwnerType& owner) const { return owner.*m_property; }
    4244
    43     SVGElement& element() const;
     45    void detach(const OwnerType& owner) const override
     46    {
     47        property(owner)->detach();
     48    }
    4449
    45     virtual void synchronizeAttributes() const = 0;
    46     virtual void synchronizeAttribute(const QualifiedName&) const = 0;
    47 
    48     virtual Vector<AnimatedPropertyType> animatedTypes(const QualifiedName&) const = 0;
    49 
    50     virtual RefPtr<SVGLegacyAnimatedProperty> lookupOrCreateAnimatedProperty(const SVGAttribute&) const = 0;
    51     virtual RefPtr<SVGLegacyAnimatedProperty> lookupAnimatedProperty(const SVGAttribute&) const = 0;
    52     virtual Vector<RefPtr<SVGLegacyAnimatedProperty>> lookupOrCreateAnimatedProperties(const QualifiedName&) const = 0;
     50    Optional<String> synchronize(const OwnerType& owner) const override
     51    {
     52        return property(owner)->synchronize();
     53    }
    5354
    5455protected:
    55     WeakPtr<SVGElement> m_element;
     56    template<typename AccessorType, Ref<PropertyType> OwnerType::*property>
     57    static const SVGMemberAccessor<OwnerType>& singleton()
     58    {
     59        static NeverDestroyed<AccessorType> propertyAccessor { property };
     60        return propertyAccessor;
     61    }
     62
     63    Ref<PropertyType> OwnerType::*m_property;
    5664};
    5765
  • trunk/Source/WebCore/svg/properties/SVGPropertyOwner.h

    r243035 r243036  
    11/*
    2  * Copyright (C) 2018 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2018-2019 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #include "config.h"
    27 #include "SVGAttributeOwnerProxy.h"
     26#pragma once
    2827
    2928namespace WebCore {
    3029
    31 SVGAttributeOwnerProxy::SVGAttributeOwnerProxy(SVGElement& element)
    32     : m_element(makeWeakPtr(element))
    33 {
    34 }
     30class SVGPropertyOwner {
     31public:
     32    virtual ~SVGPropertyOwner() = default;
    3533
    36 SVGElement& SVGAttributeOwnerProxy::element() const
    37 {
    38     return *m_element;
    39 }
     34    virtual SVGPropertyOwner* owner() const { return nullptr; }
     35   
     36    virtual const SVGElement* attributeContextElement() const
     37    {
     38        if (!owner())
     39            return nullptr;
     40        return owner()->attributeContextElement();
     41    }
     42   
     43    virtual void commitPropertyChange()
     44    {
     45        if (!owner())
     46            return;
     47        owner()->commitPropertyChange();
     48    }
     49   
     50protected:
     51    SVGPropertyOwner() = default;
     52};
    4053
    4154}
  • trunk/Source/WebCore/svg/properties/SVGPropertyRegistry.h

    r243035 r243036  
    11/*
    2  * Copyright (C) 2018 Apple Inc.  All rights reserved.
     2 * Copyright (C) 2018-2019 Apple Inc.  All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #include "config.h"
    27 #include "SVGAttributeOwnerProxy.h"
     26#pragma once
     27
     28#include "SVGAttributeAnimator.h"
    2829
    2930namespace WebCore {
    3031
    31 SVGAttributeOwnerProxy::SVGAttributeOwnerProxy(SVGElement& element)
    32     : m_element(makeWeakPtr(element))
    33 {
    34 }
     32class SVGAnimatedProperty;
    3533
    36 SVGElement& SVGAttributeOwnerProxy::element() const
    37 {
    38     return *m_element;
    39 }
     34class SVGPropertyRegistry {
     35public:
     36    SVGPropertyRegistry() = default;
     37    virtual ~SVGPropertyRegistry() = default;
     38
     39    virtual void detachAllProperties() const = 0;
     40    virtual QualifiedName animatedPropertyAttributeName(const SVGAnimatedProperty&) const = 0;
     41    virtual Optional<String> synchronize(const QualifiedName&) const = 0;
     42    virtual HashMap<QualifiedName, String> synchronizeAllAttributes() const = 0;
     43
     44    virtual bool isAnimatedPropertyAttribute(const QualifiedName&) const = 0;
     45    virtual std::unique_ptr<SVGAttributeAnimator> createAnimator(const QualifiedName&, AnimationMode, CalcMode, bool isAccumulated, bool isAdditive) const = 0;
     46    virtual void appendAnimatedInstance(const QualifiedName& attributeName, SVGAttributeAnimator&) const = 0;
     47};
    4048
    4149}
Note: See TracChangeset for help on using the changeset viewer.