Source/WebCore/ChangeLog

 12019-03-13 Said Abou-Hallawa <said@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 NOBODY (OOPS!).
 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 matches the C++ header file.
 12
 13 When the DOM requesting 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() which will depend 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 SVGAccessor and links to the associated attribute. The function
 21 of the SVGAccessor is to retrieve the value of the property given a pointer
 22 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 SVGAnimator for this property.
 33
 34 SVGAnimator is just a connection between the animated property and
 35 SVGAnimationFunction. SVGAnimationFunction calculates the values of the
 36 animated property within a time interval. SVGAnimator updates animVal
 37 of the animated property and invalidates the associated SVGElement and
 38 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. To get the code complied and linked,
 43 some code has to be moved around and new classes have to have awkward
 44 names till the tear off properties code is completely deleted.
 45
 46 Things to consider when reviewing this patch:
 47
 48 -- SVGNewProperty.h will replace SVGProperty.h
 49
 50 -- SVGNewAnimatedProperty.h will replace SVGAnimatedProperty.h
 51
 52 -- SVGAnimatedElementBase was re-factored to use SVGAnimationControllerBase
 53 which is inherited by SVGAnimationController and SVGNewAnimationController.
 54 The tear-off properties code which uses SVGAnimatedType now lives in
 55 SVGAnimationController. The new code was added to SVGNewAnimationController.
 56 The plan is to remove the three animation controllers and to move the code
 57 of SVGNewAnimationController to SVGAnimatedElementBase when all the tear
 58 off code is removed.
 59
 60 -- SVGElement now keeps two registries one for the tear-off world and the
 61 other for the new world. Eventually we need to get rid of tear-off registry.
 62
 63 -- SVGElement will differentiate between the type of the property by the
 64 the method isAnimatedAttribute().
 65
 66 * Sources.txt:
 67 * WebCore.xcodeproj/project.pbxproj:
 68 * bindings/scripts/CodeGeneratorJS.pm:
 69 (GenerateHeader):
 70 * svg/SVGAnimateElementBase.cpp:
 71 (WebCore::SVGAnimateElementBase::SVGAnimateElementBase):
 72 (WebCore::SVGAnimateElementBase::ensureController):
 73 (WebCore::SVGAnimateElementBase::hasValidAttributeType const):
 74 (WebCore::SVGAnimateElementBase::determineAnimatedPropertyType const):
 75 (WebCore::SVGAnimateElementBase::calculateAnimatedValue):
 76 (WebCore::SVGAnimateElementBase::calculateToAtEndOfDurationValue):
 77 (WebCore::SVGAnimateElementBase::calculateFromAndToValues):
 78 (WebCore::SVGAnimateElementBase::calculateFromAndByValues):
 79 (WebCore::SVGAnimateElementBase::resetAnimatedType):
 80 (WebCore::SVGAnimateElementBase::clearAnimatedType):
 81 (WebCore::SVGAnimateElementBase::applyResultsToTarget):
 82 (WebCore::SVGAnimateElementBase::isAdditive const):
 83 (WebCore::SVGAnimateElementBase::calculateDistance):
 84 (WebCore::SVGAnimateElementBase::setTargetElement):
 85 (WebCore::SVGAnimateElementBase::setAttributeName):
 86 (WebCore::SVGAnimateElementBase::resetAnimation):
 87 (WebCore::SVGAnimateElementBase::hasInvalidCSSAttributeType const):
 88 (WebCore::SVGAnimateElementBase::hasValidAttributeType): Deleted.
 89 (WebCore::propertyTypesAreConsistent): Deleted.
 90 (WebCore::applyCSSPropertyToTarget): Deleted.
 91 (WebCore::removeCSSPropertyFromTarget): Deleted.
 92 (WebCore::applyCSSPropertyToTargetAndInstances): Deleted.
 93 (WebCore::removeCSSPropertyFromTargetAndInstances): Deleted.
 94 (WebCore::notifyTargetAboutAnimValChange): Deleted.
 95 (WebCore::notifyTargetAndInstancesAboutAnimValChange): Deleted.
 96 (WebCore::SVGAnimateElementBase::animatedPropertyTypeSupportsAddition const): Deleted.
 97 (WebCore::SVGAnimateElementBase::resetAnimatedPropertyType): Deleted.
 98 (WebCore::SVGAnimateElementBase::ensureAnimator): Deleted.
 99 * svg/SVGAnimateElementBase.h:
 100 * svg/SVGAnimateMotionElement.cpp:
 101 (WebCore::SVGAnimateMotionElement::hasValidAttributeType const):
 102 (WebCore::SVGAnimateMotionElement::hasValidAttributeName const):
 103 (WebCore::SVGAnimateMotionElement::calculateFromAndByValues):
 104 (WebCore::SVGAnimateMotionElement::calculateAnimatedValue):
 105 (WebCore::SVGAnimateMotionElement::updateAnimationMode):
 106 (WebCore::SVGAnimateMotionElement::hasValidAttributeType): Deleted.
 107 (WebCore::SVGAnimateMotionElement::hasValidAttributeName): Deleted.
 108 * svg/SVGAnimateMotionElement.h:
 109 * svg/SVGAnimateTransformElement.cpp:
 110 (WebCore::SVGAnimateTransformElement::hasValidAttributeType const):
 111 (WebCore::SVGAnimateTransformElement::hasValidAttributeType): Deleted.
 112 * svg/SVGAnimateTransformElement.h:
 113 * svg/SVGAnimatedAngle.cpp:
 114 (WebCore::SVGAnimatedAngleAnimator::calculateAnimatedValue):
 115 * svg/SVGAnimatedBoolean.cpp:
 116 (WebCore::SVGAnimatedBooleanAnimator::calculateAnimatedValue):
 117 * svg/SVGAnimatedColor.cpp:
 118 (WebCore::SVGAnimatedColorAnimator::calculateAnimatedValue):
 119 * svg/SVGAnimatedEnumeration.cpp:
 120 (WebCore::SVGAnimatedEnumerationAnimator::calculateAnimatedValue):
 121 * svg/SVGAnimatedInteger.cpp: Removed.
 122 * svg/SVGAnimatedInteger.h: Removed.
 123 * svg/SVGAnimatedIntegerOptionalInteger.cpp: Removed.
 124 * svg/SVGAnimatedIntegerOptionalInteger.h: Removed.
 125 * svg/SVGAnimatedLength.cpp:
 126 (WebCore::SVGAnimatedLengthAnimator::calculateAnimatedValue):
 127 * svg/SVGAnimatedLengthList.cpp:
 128 (WebCore::SVGAnimatedLengthListAnimator::calculateAnimatedValue):
 129 * svg/SVGAnimatedNumber.cpp:
 130 (WebCore::SVGAnimatedNumberAnimator::calculateAnimatedValue):
 131 * svg/SVGAnimatedNumberList.cpp:
 132 (WebCore::SVGAnimatedNumberListAnimator::calculateAnimatedValue):
 133 * svg/SVGAnimatedNumberOptionalNumber.cpp:
 134 (WebCore::SVGAnimatedNumberOptionalNumberAnimator::calculateAnimatedValue):
 135 * svg/SVGAnimatedPath.cpp:
 136 (WebCore::SVGAnimatedPathAnimator::calculateAnimatedValue):
 137 * svg/SVGAnimatedPointList.cpp:
 138 (WebCore::SVGAnimatedPointListAnimator::calculateAnimatedValue):
 139 * svg/SVGAnimatedPointList.h:
 140 * svg/SVGAnimatedPreserveAspectRatio.cpp:
 141 (WebCore::SVGAnimatedPreserveAspectRatioAnimator::calculateAnimatedValue):
 142 * svg/SVGAnimatedRect.cpp:
 143 (WebCore::SVGAnimatedRectAnimator::calculateAnimatedValue):
 144 * svg/SVGAnimatedTransformList.cpp:
 145 (WebCore::SVGAnimatedTransformListAnimator::calculateAnimatedValue):
 146 * svg/SVGAnimationController.cpp: Copied from Source/WebCore/svg/SVGAnimateElementBase.cpp.
 147 (WebCore::SVGAnimationController::SVGAnimationController):
 148 (WebCore::SVGAnimationController::ensureAnimator):
 149 (WebCore::SVGAnimationController::isAdditive const):
 150 (WebCore::SVGAnimationController::hasValidAttributeType const):
 151 (WebCore::SVGAnimationController::calculateFromAndToValues):
 152 (WebCore::SVGAnimationController::calculateFromAndByValues):
 153 (WebCore::SVGAnimationController::calculateToAtEndOfDurationValue):
 154 (WebCore::propertyTypesAreConsistent):
 155 (WebCore::SVGAnimationController::resetAnimatedType):
 156 (WebCore::SVGAnimationController::calculateAnimatedValue):
 157 (WebCore::applyCSSPropertyToTarget):
 158 (WebCore::removeCSSPropertyFromTarget):
 159 (WebCore::applyCSSPropertyToTargetAndInstances):
 160 (WebCore::removeCSSPropertyFromTargetAndInstances):
 161 (WebCore::notifyTargetAboutAnimValChange):
 162 (WebCore::notifyTargetAndInstancesAboutAnimValChange):
 163 (WebCore::SVGAnimationController::applyResultsToTarget):
 164 (WebCore::SVGAnimationController::clearAnimatedType):
 165 (WebCore::SVGAnimationController::calculateDistance):
 166 * svg/SVGAnimationController.h: Added.
 167 * svg/SVGAnimationControllerBase.cpp: Added.
 168 (WebCore::SVGAnimationControllerBase::SVGAnimationControllerBase):
 169 (WebCore::SVGAnimationControllerBase::determineAnimatedPropertyType):
 170 * svg/SVGAnimationControllerBase.h: Copied from Source/WebCore/svg/properties/SVGAttributeOwnerProxy.h.
 171 * svg/SVGAnimationElement.cpp:
 172 (WebCore::SVGAnimationElement::updateAnimationMode):
 173 (WebCore::SVGAnimationElement::setAttributeType):
 174 (WebCore::SVGAnimationElement::isAdditive const):
 175 (WebCore::SVGAnimationElement::isAccumulated const):
 176 (WebCore::SVGAnimationElement::calculateKeyTimesForCalcModePaced):
 177 (WebCore::SVGAnimationElement::startedActiveInterval):
 178 (WebCore::SVGAnimationElement::updateAnimation):
 179 (WebCore::SVGAnimationElement::resetAnimation):
 180 (WebCore::SVGAnimationElement::resetAnimatedPropertyType): Deleted.
 181 (WebCore::SVGAnimationElement::setTargetElement): Deleted.
 182 (WebCore::SVGAnimationElement::checkInvalidCSSAttributeType): Deleted.
 183 * svg/SVGAnimationElement.h:
 184 (WebCore::SVGAnimationElement::adjustFromToListValues):
 185 (WebCore::SVGAnimationElement::animateDiscreteType):
 186 (WebCore::SVGAnimationElement::animateAdditiveNumber):
 187 (WebCore::SVGAnimationElement::attributeType const):
 188 (WebCore::SVGAnimationElement::hasInvalidCSSAttributeType const): Deleted.
 189 * svg/SVGAnimatorFactory.h:
 190 (WebCore::SVGAnimatorFactory::create):
 191 * svg/SVGElement.cpp:
 192 (WebCore::SVGElement::synchronizeAllAnimatedSVGAttribute):
 193 (WebCore::SVGElement::synchronizeAnimatedSVGAttribute const):
 194 (WebCore::SVGElement::commitPropertyChange):
 195 (WebCore::SVGElement::isAnimatedPropertyAttribute const):
 196 (WebCore::SVGElement::isAnimatedAttribute const):
 197 (WebCore::SVGElement::createAnimator):
 198 * svg/SVGElement.h:
 199 (WebCore::SVGElement::propertyRegistry const):
 200 * svg/SVGFEConvolveMatrixElement.cpp:
 201 (WebCore::SVGFEConvolveMatrixElement::SVGFEConvolveMatrixElement):
 202 (WebCore::SVGFEConvolveMatrixElement::registerAttributes):
 203 (WebCore::SVGFEConvolveMatrixElement::parseAttribute):
 204 (WebCore::SVGFEConvolveMatrixElement::setOrder):
 205 (WebCore::SVGFEConvolveMatrixElement::orderXIdentifier): Deleted.
 206 (WebCore::SVGFEConvolveMatrixElement::orderYIdentifier): Deleted.
 207 * svg/SVGFEConvolveMatrixElement.h:
 208 * svg/SVGFETurbulenceElement.cpp:
 209 (WebCore::SVGFETurbulenceElement::SVGFETurbulenceElement):
 210 (WebCore::SVGFETurbulenceElement::registerAttributes):
 211 (WebCore::SVGFETurbulenceElement::parseAttribute):
 212 * svg/SVGFETurbulenceElement.h:
 213 * svg/SVGFilterElement.h:
 214 * svg/SVGNewAnimationController.cpp: Added.
 215 (WebCore::SVGNewAnimationController::SVGNewAnimationController):
 216 (WebCore::SVGNewAnimationController::createAnimator const):
 217 (WebCore::SVGNewAnimationController::isDiscreteAnimator const):
 218 (WebCore::SVGNewAnimationController::isAdditive const):
 219 (WebCore::SVGNewAnimationController::hasValidAttributeType const):
 220 (WebCore::SVGNewAnimationController::calculateFromAndToValues):
 221 (WebCore::SVGNewAnimationController::calculateFromAndByValues):
 222 (WebCore::SVGNewAnimationController::calculateToAtEndOfDurationValue):
 223 (WebCore::SVGNewAnimationController::resetAnimatedType):
 224 (WebCore::SVGNewAnimationController::calculateAnimatedValue):
 225 (WebCore::SVGNewAnimationController::applyResultsToTarget):
 226 (WebCore::SVGNewAnimationController::clearAnimatedType):
 227 (WebCore::SVGNewAnimationController::calculateDistance):
 228 * svg/SVGNewAnimationController.h: Copied from Source/WebCore/svg/properties/SVGAttributeOwnerProxy.h.
 229 * svg/SVGSetElement.cpp:
 230 (WebCore::SVGSetElement::SVGSetElement):
 231 * svg/animation/SVGSMILElement.cpp:
 232 (WebCore::SVGSMILElement::hasValidAttributeName const):
 233 (WebCore::SVGSMILElement::hasValidAttributeName): Deleted.
 234 * svg/animation/SVGSMILElement.h:
 235 * svg/properties/SVGAccessor.h: Copied from Source/WebCore/svg/properties/SVGAttributeOwnerProxy.h.
 236 (WebCore::SVGAccessor::detach const):
 237 (WebCore::SVGAccessor::isAnimatedProperty const):
 238 (WebCore::SVGAccessor::isAnimatedLength const):
 239 (WebCore::SVGAccessor::matches const):
 240 (WebCore::SVGAccessor::synchronize const):
 241 (WebCore::SVGAccessor::createAnimator const):
 242 (WebCore::SVGAccessor::appendAnimatedInstance const):
 243 * svg/properties/SVGAccessorPtr.h: Copied from Source/WebCore/svg/properties/SVGAttributeOwnerProxy.h.
 244 (WebCore::SVGAccessorPtr::SVGAccessorPtr):
 245 (WebCore::SVGAccessorPtr::property const):
 246 (WebCore::SVGAccessorPtr::singleton):
 247 * svg/properties/SVGAnimatedPrimitiveProperty.h: Added.
 248 (WebCore::SVGAnimatedPrimitiveProperty::create):
 249 (WebCore::SVGAnimatedPrimitiveProperty::setBaseVal):
 250 (WebCore::SVGAnimatedPrimitiveProperty::setBaseValInternal):
 251 (WebCore::SVGAnimatedPrimitiveProperty::baseVal const):
 252 (WebCore::SVGAnimatedPrimitiveProperty::setAnimVal):
 253 (WebCore::SVGAnimatedPrimitiveProperty::animVal const):
 254 (WebCore::SVGAnimatedPrimitiveProperty::animVal):
 255 (WebCore::SVGAnimatedPrimitiveProperty::currentValue const):
 256 (WebCore::SVGAnimatedPrimitiveProperty::SVGAnimatedPrimitiveProperty):
 257 * svg/properties/SVGAnimatedPropertyAccessor.h: Copied from Source/WebCore/svg/properties/SVGAttributeOwnerProxy.cpp.
 258 * svg/properties/SVGAnimatedPropertyAccessorImpl.h: Copied from Source/WebCore/svg/properties/SVGAttributeOwnerProxy.h.
 259 * svg/properties/SVGAnimatedPropertyAnimator.h: Added.
 260 (WebCore::SVGAnimatedPropertyAnimator::appendAnimatedInstance):
 261 (WebCore::SVGAnimatedPropertyAnimator::SVGAnimatedPropertyAnimator):
 262 * svg/properties/SVGAnimatedPropertyAnimatorImpl.h: Copied from Source/WebCore/svg/properties/SVGAttributeOwnerProxy.h.
 263 * svg/properties/SVGAnimatedPropertyImpl.h: Copied from Source/WebCore/svg/properties/SVGAttributeOwnerProxy.cpp.
 264 * svg/properties/SVGAnimatedPropertyPairAccessor.h: Added.
 265 (WebCore::SVGAnimatedPropertyPairAccessor::SVGAnimatedPropertyPairAccessor):
 266 (WebCore::SVGAnimatedPropertyPairAccessor::singleton):
 267 (WebCore::SVGAnimatedPropertyPairAccessor::property1 const):
 268 (WebCore::SVGAnimatedPropertyPairAccessor::property2 const):
 269 * svg/properties/SVGAnimatedPropertyPairAccessorImpl.h: Added.
 270 * svg/properties/SVGAnimatedPropertyPairAnimator.h: Added.
 271 (WebCore::SVGAnimatedPropertyPairAnimator::appendAnimatedInstance):
 272 (WebCore::SVGAnimatedPropertyPairAnimator::SVGAnimatedPropertyPairAnimator):
 273 * svg/properties/SVGAnimatedPropertyPairAnimatorImpl.h: Added.
 274 * svg/properties/SVGAnimationAdditiveFunction.h: Added.
 275 (WebCore::SVGAnimationAdditiveFunction::SVGAnimationAdditiveFunction):
 276 (WebCore::SVGAnimationAdditiveFunction::progress):
 277 * svg/properties/SVGAnimationAdditiveValueFunction.h: Copied from Source/WebCore/svg/properties/SVGAttributeOwnerProxy.cpp.
 278 (WebCore::SVGAnimationAdditiveValueFunction::toAtEndOfDuration const):
 279 * svg/properties/SVGAnimationAdditiveValueFunctionImpl.h: Copied from Source/WebCore/svg/properties/SVGAttributeOwnerProxy.h.
 280 (WebCore::SVGAnimationIntegerFunction::progress):
 281 * svg/properties/SVGAnimationFunction.h: Copied from Source/WebCore/svg/properties/SVGAttributeOwnerProxy.cpp.
 282 (WebCore::SVGAnimationFunction::isDiscrete const):
 283 (WebCore::SVGAnimationFunction::calculateDistance const):
 284 (WebCore::SVGAnimationFunction::SVGAnimationFunction):
 285 (WebCore::SVGAnimationFunction::addFromAndToValues):
 286 * svg/properties/SVGAnimator.cpp: Copied from Source/WebCore/svg/properties/SVGAttributeOwnerProxy.cpp.
 287 (WebCore::SVGAnimator::applyAnimatedPropertyChange):
 288 * svg/properties/SVGAnimator.h: Added.
 289 (WebCore::SVGAnimator::SVGAnimator):
 290 (WebCore::SVGAnimator::isDiscrete const):
 291 (WebCore::SVGAnimator::setFromAndToValues):
 292 (WebCore::SVGAnimator::setFromAndByValues):
 293 (WebCore::SVGAnimator::setToAtEndOfDurationValue):
 294 (WebCore::SVGAnimator::calculateDistance const):
 295 (WebCore::SVGAnimator::createSibling):
 296 * svg/properties/SVGAttributeOwnerProxy.cpp:
 297 * svg/properties/SVGAttributeOwnerProxy.h:
 298 * svg/properties/SVGAttributeRegistry.h:
 299 * svg/properties/SVGNewAnimatedProperty.cpp: Copied from Source/WebCore/svg/properties/SVGAttributeOwnerProxy.cpp.
 300 (WebCore::SVGNewAnimatedProperty::owner const):
 301 (WebCore::SVGNewAnimatedProperty::commitPropertyChange):
 302 * svg/properties/SVGNewAnimatedProperty.h: Added.
 303 (WebCore::SVGNewAnimatedProperty::isAttached const):
 304 (WebCore::SVGNewAnimatedProperty::detach):
 305 (WebCore::SVGNewAnimatedProperty::contextElement const):
 306 (WebCore::SVGNewAnimatedProperty::baseValAsString const):
 307 (WebCore::SVGNewAnimatedProperty::animValAsString const):
 308 (WebCore::SVGNewAnimatedProperty::isDirty const):
 309 (WebCore::SVGNewAnimatedProperty::setDirty):
 310 (WebCore::SVGNewAnimatedProperty::synchronize):
 311 (WebCore::SVGNewAnimatedProperty::isAnimating const):
 312 (WebCore::SVGNewAnimatedProperty::startAnimation):
 313 (WebCore::SVGNewAnimatedProperty::stopAnimation):
 314 (WebCore::SVGNewAnimatedProperty::instanceStartAnimation):
 315 (WebCore::SVGNewAnimatedProperty::instanceStopAnimation):
 316 (WebCore::SVGNewAnimatedProperty::SVGNewAnimatedProperty):
 317 * svg/properties/SVGNewProperty.h: Added.
 318 * svg/properties/SVGPropertyOwner.h: Copied from Source/WebCore/svg/properties/SVGAttributeOwnerProxy.cpp.
 319 (WebCore::SVGPropertyOwner::owner const):
 320 (WebCore::SVGPropertyOwner::attributeContextElement const):
 321 (WebCore::SVGPropertyOwner::commitPropertyChange):
 322 * svg/properties/SVGPropertyOwnerRegistry.h: Added.
 323 (WebCore::SVGPropertyOwnerRegistry::SVGPropertyOwnerRegistry):
 324 (WebCore::SVGPropertyOwnerRegistry::registerProperty):
 325 (WebCore::SVGPropertyOwnerRegistry::enumerateRecursively):
 326 (WebCore::SVGPropertyOwnerRegistry::isKnownAttribute):
 327 (WebCore::SVGPropertyOwnerRegistry::enumerateRecursivelyBaseTypes):
 328 (WebCore::SVGPropertyOwnerRegistry::findAccessor):
 329 * svg/properties/SVGPropertyRegistry.h: Copied from Source/WebCore/svg/properties/SVGAttributeOwnerProxy.cpp.
 330
13312019-03-12 Zalan Bujtas <zalan@apple.com>
2332
3333 [ContentChangeObserver] Reset state when touchStart does not turn into click.

Source/WebCore/Sources.txt

@@svg/SVGAnimatedAngle.cpp
22692269svg/SVGAnimatedBoolean.cpp
22702270svg/SVGAnimatedColor.cpp
22712271svg/SVGAnimatedEnumeration.cpp
2272 svg/SVGAnimatedInteger.cpp
2273 svg/SVGAnimatedIntegerOptionalInteger.cpp
22742272svg/SVGAnimatedLength.cpp
22752273svg/SVGAnimatedLengthList.cpp
22762274svg/SVGAnimatedNumber.cpp

@@svg/SVGAnimatedString.cpp
22842282svg/SVGAnimatedTransformList.cpp
22852283svg/SVGAnimatedTypeAnimator.cpp
22862284svg/SVGAnimationElement.cpp
 2285svg/SVGAnimationController.cpp
 2286svg/SVGAnimationControllerBase.cpp
22872287svg/SVGCircleElement.cpp
22882288svg/SVGClipPathElement.cpp
22892289svg/SVGComponentTransferFunctionElement.cpp

@@svg/SVGMarkerElement.cpp
23522352svg/SVGMaskElement.cpp
23532353svg/SVGMetadataElement.cpp
23542354svg/SVGMissingGlyphElement.cpp
 2355svg/SVGNewAnimationController.cpp
23552356svg/SVGNumberListValues.cpp
23562357svg/SVGParserUtilities.cpp
23572358svg/SVGPathBlender.cpp

@@svg/graphics/filters/SVGFilterBuilder.cpp
24212422
24222423svg/properties/SVGAnimatedPathSegListPropertyTearOff.cpp
24232424svg/properties/SVGAnimatedProperty.cpp
 2425svg/properties/SVGAnimator.cpp
24242426svg/properties/SVGAttributeOwnerProxy.cpp
 2427svg/properties/SVGNewAnimatedProperty.cpp
24252428
24262429workers/AbstractWorker.cpp
24272430workers/DedicatedWorkerGlobalScope.cpp

Source/WebCore/WebCore.xcodeproj/project.pbxproj

242242 081668DA125603D5006F25DE /* SVGTextLayoutEngine.h in Headers */ = {isa = PBXBuildFile; fileRef = 081668D8125603D5006F25DE /* SVGTextLayoutEngine.h */; };
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 */; };
248247 083DAEA70F01A7FB00342754 /* RenderTextControlMultiLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 083DAEA30F01A7FB00342754 /* RenderTextControlMultiLine.h */; };

21342133 71DCB7021568197600862271 /* JSSVGZoomAndPan.h in Headers */ = {isa = PBXBuildFile; fileRef = 71DCB7001568197600862271 /* JSSVGZoomAndPan.h */; };
21352134 71E2183A17359FB8006E6E4D /* PlugInsResources.h in Headers */ = {isa = PBXBuildFile; fileRef = 71E2183817359FB8006E6E4D /* PlugInsResources.h */; };
21362135 71E2C42621C935280024F8C8 /* AnimationEffectPhase.h in Headers */ = {isa = PBXBuildFile; fileRef = 71E2C42421C9351D0024F8C8 /* AnimationEffectPhase.h */; settings = {ATTRIBUTES = (Private, ); }; };
2137  71E623D1151F72A60036E2F4 /* SVGAnimatedIntegerOptionalInteger.h in Headers */ = {isa = PBXBuildFile; fileRef = 71E623CF151F72A60036E2F4 /* SVGAnimatedIntegerOptionalInteger.h */; };
21382136 71EADCD822087E720065A45F /* PointerID.h in Headers */ = {isa = PBXBuildFile; fileRef = 71EADCD622087E6D0065A45F /* PointerID.h */; settings = {ATTRIBUTES = (Private, ); }; };
21392137 71EFCEDC202B38A900D7C411 /* AnimationEffect.h in Headers */ = {isa = PBXBuildFile; fileRef = 71EFCED7202B388D00D7C411 /* AnimationEffect.h */; settings = {ATTRIBUTES = (Private, ); }; };
21402138 71FB967B1383D64600AC8A4C /* SVGAnimatedEnumerationPropertyTearOff.h in Headers */ = {isa = PBXBuildFile; fileRef = 71FB967A1383D64600AC8A4C /* SVGAnimatedEnumerationPropertyTearOff.h */; };

55975595 081AA8D91111237E002AB06E /* SVGElementRareData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGElementRareData.h; sourceTree = "<group>"; };
55985596 081EBF380FD34F4100DA7559 /* SVGFilterBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGFilterBuilder.cpp; sourceTree = "<group>"; };
55995597 081EBF390FD34F4100DA7559 /* SVGFilterBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGFilterBuilder.h; sourceTree = "<group>"; };
5600  0823D158127AD6AC000EBC95 /* SVGAnimatedInteger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedInteger.h; sourceTree = "<group>"; };
56015598 08250938128BD4D800E2ED8E /* SVGAnimatedTransformList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedTransformList.h; sourceTree = "<group>"; };
56025599 082DE42C1292621600D923DF /* SVGPathSegWithContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPathSegWithContext.h; sourceTree = "<group>"; };
56035600 083DAEA20F01A7FB00342754 /* RenderTextControlMultiLine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderTextControlMultiLine.cpp; sourceTree = "<group>"; };

76827679 43D2597613C816F400608559 /* ImageBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageBuffer.cpp; sourceTree = "<group>"; };
76837680 43EDD67C1B485DBF00640E75 /* CombinedFiltersAlphabet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CombinedFiltersAlphabet.cpp; sourceTree = "<group>"; };
76847681 43EDD67D1B485DBF00640E75 /* CombinedFiltersAlphabet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CombinedFiltersAlphabet.h; sourceTree = "<group>"; };
7685  43F6FD9513BCD0B100224052 /* SVGAnimatedInteger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedInteger.cpp; sourceTree = "<group>"; };
76867682 4415292C0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLPlugInImageElement.h; sourceTree = "<group>"; };
76877683 4415292D0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLPlugInImageElement.cpp; sourceTree = "<group>"; };
76887684 442956CA218A6D300080DB54 /* DictionaryLookupLegacy.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = DictionaryLookupLegacy.mm; sourceTree = "<group>"; };

94669462 71E2183817359FB8006E6E4D /* PlugInsResources.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; name = PlugInsResources.h; path = DerivedSources/WebCore/PlugInsResources.h; sourceTree = BUILT_PRODUCTS_DIR; };
94679463 71E2183917359FB8006E6E4D /* PlugInsResourcesData.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = PlugInsResourcesData.cpp; path = DerivedSources/WebCore/PlugInsResourcesData.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
94689464 71E2C42421C9351D0024F8C8 /* AnimationEffectPhase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationEffectPhase.h; sourceTree = "<group>"; };
9469  71E623CE151F72A60036E2F4 /* SVGAnimatedIntegerOptionalInteger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedIntegerOptionalInteger.cpp; sourceTree = "<group>"; };
9470  71E623CF151F72A60036E2F4 /* SVGAnimatedIntegerOptionalInteger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedIntegerOptionalInteger.h; sourceTree = "<group>"; };
94719465 71EADCD622087E6D0065A45F /* PointerID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PointerID.h; sourceTree = "<group>"; };
94729466 71EFCED6202B388C00D7C411 /* AnimationEffect.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AnimationEffect.idl; sourceTree = "<group>"; };
94739467 71EFCED7202B388D00D7C411 /* AnimationEffect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnimationEffect.h; sourceTree = "<group>"; };

94759469 71EFCEDE202B39C700D7C411 /* JSAnimationEffectCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAnimationEffectCustom.cpp; sourceTree = "<group>"; };
94769470 71F936F71DD4F99B00922CC7 /* tracks-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "tracks-support.js"; sourceTree = "<group>"; };
94779471 71FB967A1383D64600AC8A4C /* SVGAnimatedEnumerationPropertyTearOff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedEnumerationPropertyTearOff.h; sourceTree = "<group>"; };
 9472 723F97A1223898DB007F079C /* SVGNewProperty.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGNewProperty.h; sourceTree = "<group>"; };
 9473 723F97A422389A78007F079C /* SVGPropertyRegistry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPropertyRegistry.h; sourceTree = "<group>"; };
 9474 723F97A522389AF8007F079C /* SVGPropertyOwnerRegistry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPropertyOwnerRegistry.h; sourceTree = "<group>"; };
 9475 723F97A622389C86007F079C /* SVGAnimatedPropertyAccessorImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyAccessorImpl.h; sourceTree = "<group>"; };
 9476 723F97A722389CA5007F079C /* SVGAnimatedPropertyAccessor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyAccessor.h; sourceTree = "<group>"; };
 9477 723F97A822389EB1007F079C /* SVGNewAnimatedProperty.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGNewAnimatedProperty.h; sourceTree = "<group>"; };
 9478 723F97A922389EE8007F079C /* SVGAnimatedPropertyImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyImpl.h; sourceTree = "<group>"; };
 9479 723F97AA2238A636007F079C /* SVGAnimatedPropertyAnimator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyAnimator.h; sourceTree = "<group>"; };
 9480 723F97AB2238A732007F079C /* SVGAnimatedPropertyAnimatorImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyAnimatorImpl.h; sourceTree = "<group>"; };
 9481 723F97AC2238A7D1007F079C /* SVGAnimatedPropertyPairAccessor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyPairAccessor.h; sourceTree = "<group>"; };
 9482 723F97AD2238A863007F079C /* SVGAnimatedPropertyPairAccessorImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyPairAccessorImpl.h; sourceTree = "<group>"; };
 9483 723F97AE2238A8C0007F079C /* SVGAnimatedPropertyPairAnimator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyPairAnimator.h; sourceTree = "<group>"; };
 9484 723F97AF2238B983007F079C /* SVGAnimatedPropertyPairAnimatorImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyPairAnimatorImpl.h; sourceTree = "<group>"; };
 9485 723F97B02238C958007F079C /* SVGAnimatedPrimitiveProperty.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPrimitiveProperty.h; sourceTree = "<group>"; };
 9486 723F97B12238CA59007F079C /* SVGPropertyOwner.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPropertyOwner.h; sourceTree = "<group>"; };
 9487 723F97B22238D048007F079C /* SVGAccessorPtr.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAccessorPtr.h; sourceTree = "<group>"; };
 9488 723F97B32238D0AC007F079C /* SVGAccessor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAccessor.h; sourceTree = "<group>"; };
 9489 723F97B42238D116007F079C /* SVGAnimator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimator.h; sourceTree = "<group>"; };
 9490 723F97B52238D1A6007F079C /* SVGAnimationAdditiveValueFunctionImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimationAdditiveValueFunctionImpl.h; sourceTree = "<group>"; };
 9491 723F97B62238D293007F079C /* SVGAnimationAdditiveValueFunction.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimationAdditiveValueFunction.h; sourceTree = "<group>"; };
 9492 723F97B72238D340007F079C /* SVGAnimationAdditiveFunction.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimationAdditiveFunction.h; sourceTree = "<group>"; };
 9493 723F97B82238D397007F079C /* SVGAnimationFunction.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimationFunction.h; sourceTree = "<group>"; };
 9494 723F97B92238E801007F079C /* SVGAnimator.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimator.cpp; sourceTree = "<group>"; };
 9495 723F97BB2238EA08007F079C /* SVGNewAnimatedProperty.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SVGNewAnimatedProperty.cpp; sourceTree = "<group>"; };
 9496 723F97BC2238EE08007F079C /* SVGNewAnimationController.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SVGNewAnimationController.cpp; sourceTree = "<group>"; };
 9497 723F97BD2238EE08007F079C /* SVGNewAnimationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGNewAnimationController.h; sourceTree = "<group>"; };
 9498 723F97BE2239512D007F079C /* SVGAnimationController.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimationController.cpp; sourceTree = "<group>"; };
 9499 723F97BF2239512D007F079C /* SVGAnimationController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimationController.h; sourceTree = "<group>"; };
 9500 723F97C022396B88007F079C /* SVGAnimationControllerBase.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAnimationControllerBase.h; sourceTree = "<group>"; };
 9501 723F97C122397725007F079C /* SVGAnimationControllerBase.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimationControllerBase.cpp; sourceTree = "<group>"; };
94789502 724ED3291A3A7E5400F5F13C /* EXTBlendMinMax.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EXTBlendMinMax.cpp; sourceTree = "<group>"; };
94799503 724ED32A1A3A7E5400F5F13C /* EXTBlendMinMax.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EXTBlendMinMax.h; sourceTree = "<group>"; };
94809504 724ED32B1A3A7E5400F5F13C /* EXTBlendMinMax.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EXTBlendMinMax.idl; sourceTree = "<group>"; };

1616516189 081CDFBD126ECFE800D215CA /* properties */ = {
1616616190 isa = PBXGroup;
1616716191 children = (
 16192 723F97B32238D0AC007F079C /* SVGAccessor.h */,
 16193 723F97B22238D048007F079C /* SVGAccessorPtr.h */,
1616816194 71FB967A1383D64600AC8A4C /* SVGAnimatedEnumerationPropertyTearOff.h */,
1616916195 088A0DFB126EF1DB00978F7A /* SVGAnimatedListPropertyTearOff.h */,
1617016196 55FA7FFC2110F813005AEFE7 /* SVGAnimatedPathSegListPropertyTearOff.cpp */,
1617116197 089A8E06128D8B3D00E7A534 /* SVGAnimatedPathSegListPropertyTearOff.h */,
 16198 723F97B02238C958007F079C /* SVGAnimatedPrimitiveProperty.h */,
1617216199 836FBCEB178C117F00B21A15 /* SVGAnimatedProperty.cpp */,
1617316200 088A0DFC126EF1DB00978F7A /* SVGAnimatedProperty.h */,
 16201 723F97A722389CA5007F079C /* SVGAnimatedPropertyAccessor.h */,
 16202 723F97A622389C86007F079C /* SVGAnimatedPropertyAccessorImpl.h */,
 16203 723F97AA2238A636007F079C /* SVGAnimatedPropertyAnimator.h */,
 16204 723F97AB2238A732007F079C /* SVGAnimatedPropertyAnimatorImpl.h */,
1617416205 088A0DFD126EF1DB00978F7A /* SVGAnimatedPropertyDescription.h */,
 16206 723F97A922389EE8007F079C /* SVGAnimatedPropertyImpl.h */,
 16207 723F97AC2238A7D1007F079C /* SVGAnimatedPropertyPairAccessor.h */,
 16208 723F97AD2238A863007F079C /* SVGAnimatedPropertyPairAccessorImpl.h */,
 16209 723F97AE2238A8C0007F079C /* SVGAnimatedPropertyPairAnimator.h */,
 16210 723F97AF2238B983007F079C /* SVGAnimatedPropertyPairAnimatorImpl.h */,
1617516211 088A0DFF126EF1DB00978F7A /* SVGAnimatedPropertyTearOff.h */,
1617616212 55FA7FFE21110E6E005AEFE7 /* SVGAnimatedPropertyType.h */,
1617716213 08525E621278C00100A84778 /* SVGAnimatedStaticPropertyTearOff.h */,
1617816214 085A15921289A8DD002710E3 /* SVGAnimatedTransformListPropertyTearOff.h */,
 16215 723F97B72238D340007F079C /* SVGAnimationAdditiveFunction.h */,
 16216 723F97B62238D293007F079C /* SVGAnimationAdditiveValueFunction.h */,
 16217 723F97B52238D1A6007F079C /* SVGAnimationAdditiveValueFunctionImpl.h */,
 16218 723F97B82238D397007F079C /* SVGAnimationFunction.h */,
 16219 723F97B92238E801007F079C /* SVGAnimator.cpp */,
 16220 723F97B42238D116007F079C /* SVGAnimator.h */,
1617916221 55FA7FEF210FA386005AEFE7 /* SVGAttribute.h */,
1618016222 55FA7FF4210FB688005AEFE7 /* SVGAttributeAccessor.h */,
1618116223 7A3EBEAC21BF0921000D043D /* SVGAttributeOwnerProxy.cpp */,

1618516227 0810764312828556007C63BA /* SVGListProperty.h */,
1618616228 088A0E00126EF1DB00978F7A /* SVGListPropertyTearOff.h */,
1618716229 08CA3D4312894A3800FFF260 /* SVGMatrixTearOff.h */,
 16230 723F97BB2238EA08007F079C /* SVGNewAnimatedProperty.cpp */,
 16231 723F97A822389EB1007F079C /* SVGNewAnimatedProperty.h */,
 16232 723F97A1223898DB007F079C /* SVGNewProperty.h */,
1618816233 088A0E01126EF1DB00978F7A /* SVGProperty.h */,
 16234 723F97B12238CA59007F079C /* SVGPropertyOwner.h */,
 16235 723F97A522389AF8007F079C /* SVGPropertyOwnerRegistry.h */,
 16236 723F97A422389A78007F079C /* SVGPropertyRegistry.h */,
1618916237 088A0E02126EF1DB00978F7A /* SVGPropertyTearOff.h */,
1619016238 088A0E03126EF1DB00978F7A /* SVGPropertyTraits.h */,
1619116239 0880F70D1282B46D00948505 /* SVGStaticListPropertyTearOff.h */,

2404524093 71CC7A1F152A0BFE009EEAF9 /* SVGAnimatedEnumeration.cpp */,
2404624094 08D46CE2127AD5FC0089694B /* SVGAnimatedEnumeration.h */,
2404724095 B22277E80D00BF1F0071B782 /* SVGAnimatedEnumeration.idl */,
24048  43F6FD9513BCD0B100224052 /* SVGAnimatedInteger.cpp */,
24049  0823D158127AD6AC000EBC95 /* SVGAnimatedInteger.h */,
2405024096 B22277E90D00BF1F0071B782 /* SVGAnimatedInteger.idl */,
24051  71E623CE151F72A60036E2F4 /* SVGAnimatedIntegerOptionalInteger.cpp */,
24052  71E623CF151F72A60036E2F4 /* SVGAnimatedIntegerOptionalInteger.h */,
2405324097 4381763A13A697D4007D1187 /* SVGAnimatedLength.cpp */,
2405424098 089021A8126EF5DE0092D5EA /* SVGAnimatedLength.h */,
2405524099 B22277EA0D00BF1F0071B782 /* SVGAnimatedLength.idl */,

2409424138 B22277FE0D00BF1F0071B782 /* SVGAnimateTransformElement.cpp */,
2409524139 B22277FF0D00BF1F0071B782 /* SVGAnimateTransformElement.h */,
2409624140 B22278000D00BF1F0071B782 /* SVGAnimateTransformElement.idl */,
 24141 723F97BE2239512D007F079C /* SVGAnimationController.cpp */,
 24142 723F97BF2239512D007F079C /* SVGAnimationController.h */,
 24143 723F97C122397725007F079C /* SVGAnimationControllerBase.cpp */,
 24144 723F97C022396B88007F079C /* SVGAnimationControllerBase.h */,
2409724145 B22278010D00BF1F0071B782 /* SVGAnimationElement.cpp */,
2409824146 B22278020D00BF1F0071B782 /* SVGAnimationElement.h */,
2409924147 B22278030D00BF1F0071B782 /* SVGAnimationElement.idl */,

2430424352 B22278B70D00BF200071B782 /* SVGMPathElement.cpp */,
2430524353 B22278B80D00BF200071B782 /* SVGMPathElement.h */,
2430624354 44D8DA98139545BE00337B75 /* SVGMPathElement.idl */,
 24355 723F97BC2238EE08007F079C /* SVGNewAnimationController.cpp */,
 24356 723F97BD2238EE08007F079C /* SVGNewAnimationController.h */,
2430724357 7CE58D4F1DD69A1E00128552 /* SVGNumber.h */,
2430824358 B22278B90D00BF200071B782 /* SVGNumber.idl */,
2430924359 B22278BB0D00BF200071B782 /* SVGNumberList.h */,

3183031880 43A625F813B3304000AC94B8 /* SVGAnimatedColor.h in Headers */,
3183131881 08D46CE3127AD5FC0089694B /* SVGAnimatedEnumeration.h in Headers */,
3183231882 71FB967B1383D64600AC8A4C /* SVGAnimatedEnumerationPropertyTearOff.h in Headers */,
31833  0823D159127AD6AC000EBC95 /* SVGAnimatedInteger.h in Headers */,
31834  71E623D1151F72A60036E2F4 /* SVGAnimatedIntegerOptionalInteger.h in Headers */,
3183531883 089021A9126EF5DE0092D5EA /* SVGAnimatedLength.h in Headers */,
3183631884 089021AD126EF5E90092D5EA /* SVGAnimatedLengthList.h in Headers */,
3183731885 088A0E04126EF1DB00978F7A /* SVGAnimatedListPropertyTearOff.h in Headers */,

Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

@@sub GenerateHeader
24992499 }
25002500 }
25012501
2502  $headerIncludes{"$interfaceName.h"} = 1 if $hasParent && $interface->extendedAttributes->{JSGenerateToNativeObject};
2503 
25042502 $headerIncludes{"SVGElement.h"} = 1 if $className =~ /^JSSVG/;
25052503
25062504 my $implType = GetImplClassName($interface);

@@sub GenerateHeader
25122510 push(@headerContent, "\nnamespace WebCore {\n\n");
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)) {
25192518 AddClassForwardIfNeeded($interface->type);

@@sub GenerateHeader
25632562 push(@headerContent, " return ptr;\n");
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");
25692570 push(@headerContent, " $className* ptr = new (NotNull, JSC::allocateCell<$className>(globalObject->vm().heap)) $className(structure, *globalObject, WTFMove(impl));\n");

Source/WebCore/svg/SVGAnimateElementBase.cpp

2424#include "config.h"
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 "SVGAnimationController.h"
3229#include "SVGElement.h"
3330#include "SVGNames.h"
34 #include "StyleProperties.h"
 31#include "SVGNewAnimationController.h"
3532#include <wtf/IsoMallocInlines.h>
3633
3734namespace WebCore {

@@WTF_MAKE_ISO_ALLOCATED_IMPL(SVGAnimateElementBase);
4037
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));
4642}
4743
4844SVGAnimateElementBase::~SVGAnimateElementBase() = default;
4945
50 bool SVGAnimateElementBase::hasValidAttributeType()
 46SVGAnimationControllerBase& SVGAnimateElementBase::ensureController()
5147{
52  if (!this->targetElement())
 48 ASSERT(targetElement());
 49 ASSERT(!hasInvalidCSSAttributeType());
 50
 51 if (!m_controller) {
 52 if (targetElement()->isAnimatedPropertyAttribute(attributeName()))
 53 m_controller = std::make_unique<SVGNewAnimationController>(*this, *targetElement());
 54 else
 55 m_controller = std::make_unique<SVGAnimationController>(*this, *targetElement());
 56 }
 57
 58 return *m_controller;
 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 SVGAnimationControllerBase::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)
92  return;
93 
94  const QualifiedName& attributeName = this->attributeName();
95  ShouldApplyAnimation shouldApply = shouldApplyAnimation(targetElement.get(), attributeName);
96 
97  if (shouldApply == DontApplyAnimation)
 79 if (!targetElement())
9880 return;
9981
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());
 82 ensureController().calculateAnimatedValue(percentage, repeatCount, resultElement);
14083}
14184
14285bool SVGAnimateElementBase::calculateToAtEndOfDurationValue(const String& toAtEndOfDurationString)
14386{
144  if (toAtEndOfDurationString.isEmpty())
 87 if (!targetElement())
14588 return false;
146  m_toAtEndOfDurationType = ensureAnimator()->constructFromString(toAtEndOfDurationString);
147  return true;
 89
 90 return ensureController().calculateToAtEndOfDurationValue(toAtEndOfDurationString);
14891}
14992
15093bool SVGAnimateElementBase::calculateFromAndToValues(const String& fromString, const String& toString)
15194{
152  if (!this->targetElement())
 95 if (!targetElement())
15396 return false;
15497
155  determinePropertyValueTypes(fromString, toString);
156  ensureAnimator()->calculateFromAndToValues(m_fromType, m_toType, fromString, toString);
157  ASSERT(m_animatedPropertyType == m_animator->type());
158  return true;
 98 return ensureController().calculateFromAndToValues(fromString, toString);
15999}
160100
161101bool SVGAnimateElementBase::calculateFromAndByValues(const String& fromString, const String& byString)
162102{
163  if (!this->targetElement())
 103 if (!targetElement())
164104 return false;
165105
166  if (animationMode() == ByAnimation && !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() == FromByAnimation && !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;
 106 return ensureController().calculateFromAndByValues(fromString, byString);
179107}
180108
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 
199109void SVGAnimateElementBase::resetAnimatedType()
200110{
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())
 111 if (!targetElement())
266112 return;
267113
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);
 114 ensureController().resetAnimatedType();
311115}
312116
313117void SVGAnimateElementBase::clearAnimatedType(SVGElement* targetElement)
314118{
315  if (!m_animatedType)
 119 if (!targetElement || !m_controller)
316120 return;
317121
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;
 122 m_controller->clearAnimatedType(targetElement);
347123}
348124
349125void SVGAnimateElementBase::applyResultsToTarget()
350126{
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());
 127 if (!targetElement())
368128 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 }
382129
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  }
 130 ensureController().applyResultsToTarget();
411131}
412132
413133bool SVGAnimateElementBase::isAdditive() const
414134{
415  if (animationMode() == ByAnimation || animationMode() == FromByAnimation) {
416  if (!animatedPropertyTypeSupportsAddition())
 135 if (animationMode() == AnimationMode::By || animationMode() == AnimationMode::FromBy) {
 136 if (targetElement() && m_controller && !m_controller->isAdditive())
417137 return false;
418138 }
419139

@@bool SVGAnimateElementBase::isAdditive() const
423143float SVGAnimateElementBase::calculateDistance(const String& fromString, const String& toString)
424144{
425145 // FIXME: A return value of float is not enough to support paced animations on lists.
426  if (!this->targetElement())
 146 if (!targetElement())
427147 return -1;
428148
429  return ensureAnimator()->calculateDistance(fromString, toString);
 149 return ensureController().calculateDistance(fromString, toString);
430150}
431151
432152void SVGAnimateElementBase::setTargetElement(SVGElement* target)
433153{
434154 SVGAnimationElement::setTargetElement(target);
435  resetAnimatedPropertyType();
 155 resetAnimation();
436156}
437157
438158void SVGAnimateElementBase::setAttributeName(const QualifiedName& attributeName)
439159{
440160 SVGSMILElement::setAttributeName(attributeName);
441  checkInvalidCSSAttributeType(targetElement());
442  resetAnimatedPropertyType();
 161 resetAnimation();
443162}
444163
445 void SVGAnimateElementBase::resetAnimatedPropertyType()
 164void SVGAnimateElementBase::resetAnimation()
446165{
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;
 166 SVGAnimationElement::resetAnimation();
 167 m_controller = nullptr;
 168 m_hasInvalidCSSAttributeType = WTF::nullopt;
454169}
455170
456 SVGAnimatedTypeAnimator* SVGAnimateElementBase::ensureAnimator()
 171bool SVGAnimateElementBase::hasInvalidCSSAttributeType() const
457172{
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();
 173 if (!targetElement())
 174 return false;
 175
 176 if (!m_hasInvalidCSSAttributeType)
 177 m_hasInvalidCSSAttributeType = hasValidAttributeName() && attributeType() == AttributeType::CSS && !isTargetAttributeCSSProperty(targetElement(), attributeName());
 178
 179 return m_hasInvalidCSSAttributeType.value();
462180}
463181
464182} // namespace WebCore

Source/WebCore/svg/SVGAnimateElementBase.h

2323
2424#pragma once
2525
26 #include "SVGAnimatedType.h"
27 #include "SVGAnimatedTypeAnimator.h"
2826#include "SVGAnimationElement.h"
2927#include "SVGNames.h"
3028
3129namespace WebCore {
3230
 31class SVGAnimationControllerBase;
 32
3333class SVGAnimateElementBase : public SVGAnimationElement {
3434 WTF_MAKE_ISO_ALLOCATED(SVGAnimateElementBase);
3535public:
3636 virtual ~SVGAnimateElementBase();
3737
 38 SVGAnimationControllerBase& ensureController();
 39
3840 AnimatedPropertyType determineAnimatedPropertyType(SVGElement&) const;
3941
4042protected:
4143 SVGAnimateElementBase(const QualifiedName&, Document&);
4244
 45 bool hasValidAttributeType() const override;
 46
4347 void resetAnimatedType() override;
4448 void clearAnimatedType(SVGElement* targetElement) override;
4549

@@protected:
5357
5458 void setTargetElement(SVGElement*) override;
5559 void setAttributeName(const QualifiedName&) override;
56  void resetAnimatedPropertyType() override;
57 
58  AnimatedPropertyType m_animatedPropertyType;
 60 void resetAnimation() override;
5961
6062private:
61  SVGAnimatedTypeAnimator* ensureAnimator();
62  bool animatedPropertyTypeSupportsAddition() const;
63 
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;
 63 bool hasInvalidCSSAttributeType() const;
7064
71  SVGElementAnimatedPropertyList m_animatedProperties;
72  std::unique_ptr<SVGAnimatedTypeAnimator> m_animator;
 65 mutable Optional<bool> m_hasInvalidCSSAttributeType;
 66 std::unique_ptr<SVGAnimationControllerBase> m_controller;
7367};
7468
7569} // namespace WebCore

Source/WebCore/svg/SVGAnimateMotionElement.cpp

@@Ref<SVGAnimateMotionElement> SVGAnimateMotionElement::create(const QualifiedName
5757 return adoptRef(*new SVGAnimateMotionElement(tagName, document));
5858}
5959
60 bool SVGAnimateMotionElement::hasValidAttributeType()
 60bool SVGAnimateMotionElement::hasValidAttributeType() const
6161{
6262 auto targetElement = makeRefPtr(this->targetElement());
6363 if (!targetElement)

@@bool SVGAnimateMotionElement::hasValidAttributeType()
9090 return false;
9191}
9292
93 bool SVGAnimateMotionElement::hasValidAttributeName()
 93bool SVGAnimateMotionElement::hasValidAttributeName() const
9494{
9595 // AnimateMotion does not use attributeName so it is always valid.
9696 return true;

@@bool SVGAnimateMotionElement::calculateFromAndToValues(const String& fromString,
176176bool SVGAnimateMotionElement::calculateFromAndByValues(const String& fromString, const String& byString)
177177{
178178 m_hasToPointAtEndOfDuration = false;
179  if (animationMode() == ByAnimation && !isAdditive())
 179 if (animationMode() == AnimationMode::By && !isAdditive())
180180 return false;
181181 parsePoint(fromString, m_fromPoint);
182182 FloatPoint byPoint;

@@void SVGAnimateMotionElement::calculateAnimatedValue(float percentage, unsigned
222222 if (!isAdditive())
223223 transform->makeIdentity();
224224
225  if (animationMode() != PathAnimation) {
 225 if (animationMode() != AnimationMode::Path) {
226226 FloatPoint toPointAtEndOfDuration = m_toPoint;
227227 if (isAccumulated() && repeatCount && m_hasToPointAtEndOfDuration)
228228 toPointAtEndOfDuration = m_toPointAtEndOfDuration;

@@float SVGAnimateMotionElement::calculateDistance(const String& fromString, const
288288void SVGAnimateMotionElement::updateAnimationMode()
289289{
290290 if (!m_animationPath.isEmpty())
291  setAnimationMode(PathAnimation);
 291 setAnimationMode(AnimationMode::Path);
292292 else
293293 SVGAnimationElement::updateAnimationMode();
294294}

Source/WebCore/svg/SVGAnimateMotionElement.h

@@public:
3636private:
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;
4343

Source/WebCore/svg/SVGAnimateTransformElement.cpp

@@Ref<SVGAnimateTransformElement> SVGAnimateTransformElement::create(const Qualifi
4343 return adoptRef(*new SVGAnimateTransformElement(tagName, document));
4444}
4545
46 bool SVGAnimateTransformElement::hasValidAttributeType()
 46bool SVGAnimateTransformElement::hasValidAttributeType() const
4747{
4848 if (!this->targetElement())
4949 return false;

@@bool SVGAnimateTransformElement::hasValidAttributeType()
5151 if (attributeType() == AttributeType::CSS)
5252 return false;
5353
54  return m_animatedPropertyType == AnimatedTransformList;
 54 return SVGAnimateElementBase::hasValidAttributeType();
5555}
5656
5757void SVGAnimateTransformElement::parseAttribute(const QualifiedName& name, const AtomicString& value)

Source/WebCore/svg/SVGAnimateTransformElement.h

@@public:
3939private:
4040 SVGAnimateTransformElement(const QualifiedName&, Document&);
4141
42  bool hasValidAttributeType() final;
 42 bool hasValidAttributeType() const final;
4343 void parseAttribute(const QualifiedName&, const AtomicString&) final;
4444
4545 SVGTransformValue::SVGTransformType m_type;

Source/WebCore/svg/SVGAnimatedAngle.cpp

@@void SVGAnimatedAngleAnimator::calculateAnimatedValue(float percentage, unsigned
8080 ASSERT(m_animationElement);
8181 ASSERT(m_contextElement);
8282
83  const auto& fromAngleAndEnumeration = (m_animationElement->animationMode() == ToAnimation ? animated : from)->as<std::pair<SVGAngleValue, unsigned>>();
 83 const auto& fromAngleAndEnumeration = (m_animationElement->animationMode() == AnimationMode::To ? animated : from)->as<std::pair<SVGAngleValue, unsigned>>();
8484 auto& toAngleAndEnumeration = to->as<std::pair<SVGAngleValue, unsigned>>();
8585 auto& toAtEndOfDurationAngleAndEnumeration = toAtEndOfDuration->as<std::pair<SVGAngleValue, unsigned>>();
8686 auto& animatedAngleAndEnumeration = animated->as<std::pair<SVGAngleValue, unsigned>>();

Source/WebCore/svg/SVGAnimatedBoolean.cpp

@@void SVGAnimatedBooleanAnimator::calculateAnimatedValue(float percentage, unsign
7070 ASSERT(m_animationElement);
7171 ASSERT(m_contextElement);
7272
73  const auto fromBoolean = (m_animationElement->animationMode() == ToAnimation ? animated : from)->as<bool>();
 73 const auto fromBoolean = (m_animationElement->animationMode() == AnimationMode::To ? animated : from)->as<bool>();
7474 const auto toBoolean = to->as<bool>();
7575 auto& animatedBoolean = animated->as<bool>();
7676

Source/WebCore/svg/SVGAnimatedColor.cpp

@@void SVGAnimatedColorAnimator::calculateAnimatedValue(float percentage, unsigned
7070 ASSERT(m_animationElement);
7171 ASSERT(m_contextElement);
7272
73  auto fromColor = (m_animationElement->animationMode() == ToAnimation ? animated : from)->as<Color>();
 73 auto fromColor = (m_animationElement->animationMode() == AnimationMode::To ? animated : from)->as<Color>();
7474 auto toColor = to->as<Color>();
7575
7676 // Apply CSS inheritance rules.

Source/WebCore/svg/SVGAnimatedEnumeration.cpp

@@void SVGAnimatedEnumerationAnimator::calculateAnimatedValue(float percentage, un
148148 ASSERT(m_animationElement);
149149 ASSERT(m_contextElement);
150150
151  const auto fromEnumeration = (m_animationElement->animationMode() == ToAnimation ? animated : from)->as<unsigned>();
 151 const auto fromEnumeration = (m_animationElement->animationMode() == AnimationMode::To ? animated : from)->as<unsigned>();
152152 const auto toEnumeration = to->as<unsigned>();
153153 auto& animatedEnumeration = animated->as<unsigned>();
154154

Source/WebCore/svg/SVGAnimatedInteger.cpp

1 /*
2  * Copyright (C) Research In Motion Limited 2011. All rights reserved.
3  * Copyright (C) 2018 Apple Inc. All rights reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #include "config.h"
22 #include "SVGAnimatedInteger.h"
23 
24 #include "SVGAnimateElementBase.h"
25 #include "SVGAnimatedNumber.h"
26 #include <wtf/MathExtras.h>
27 
28 namespace WebCore {
29 
30 SVGAnimatedIntegerAnimator::SVGAnimatedIntegerAnimator(SVGAnimationElement* animationElement, SVGElement* contextElement)
31  : SVGAnimatedTypeAnimator(AnimatedInteger, animationElement, contextElement)
32 {
33 }
34 
35 std::unique_ptr<SVGAnimatedType> SVGAnimatedIntegerAnimator::constructFromString(const String& string)
36 {
37  return SVGAnimatedType::create(SVGPropertyTraits<int>::fromString(string));
38 }
39 
40 std::unique_ptr<SVGAnimatedType> SVGAnimatedIntegerAnimator::startAnimValAnimation(const SVGElementAnimatedPropertyList& animatedTypes)
41 {
42  return constructFromBaseValue<SVGAnimatedInteger>(animatedTypes);
43 }
44 
45 void SVGAnimatedIntegerAnimator::stopAnimValAnimation(const SVGElementAnimatedPropertyList& animatedTypes)
46 {
47  stopAnimValAnimationForType<SVGAnimatedInteger>(animatedTypes);
48 }
49 
50 void SVGAnimatedIntegerAnimator::resetAnimValToBaseVal(const SVGElementAnimatedPropertyList& animatedTypes, SVGAnimatedType& type)
51 {
52  resetFromBaseValue<SVGAnimatedInteger>(animatedTypes, type);
53 }
54 
55 void SVGAnimatedIntegerAnimator::animValWillChange(const SVGElementAnimatedPropertyList& animatedTypes)
56 {
57  animValWillChangeForType<SVGAnimatedInteger>(animatedTypes);
58 }
59 
60 void SVGAnimatedIntegerAnimator::animValDidChange(const SVGElementAnimatedPropertyList& animatedTypes)
61 {
62  animValDidChangeForType<SVGAnimatedInteger>(animatedTypes);
63 }
64 
65 void SVGAnimatedIntegerAnimator::addAnimatedTypes(SVGAnimatedType* from, SVGAnimatedType* to)
66 {
67  ASSERT(from->type() == AnimatedInteger);
68  ASSERT(from->type() == to->type());
69 
70  to->as<int>() += from->as<int>();
71 }
72 
73 void SVGAnimatedIntegerAnimator::calculateAnimatedInteger(SVGAnimationElement* animationElement, float percentage, unsigned repeatCount, int fromInteger, int toInteger, int toAtEndOfDurationInteger, int& animatedInteger)
74 {
75  float animatedNumber = animatedInteger;
76  animationElement->animateAdditiveNumber(percentage, repeatCount, fromInteger, toInteger, toAtEndOfDurationInteger, animatedNumber);
77  animatedInteger = static_cast<int>(roundf(animatedNumber));
78 }
79 
80 void SVGAnimatedIntegerAnimator::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGAnimatedType* from, SVGAnimatedType* to, SVGAnimatedType* toAtEndOfDuration, SVGAnimatedType* animated)
81 {
82  ASSERT(m_animationElement);
83  ASSERT(m_contextElement);
84 
85  const auto fromInteger = (m_animationElement->animationMode() == ToAnimation ? animated : from)->as<int>();
86  const auto toInteger = to->as<int>();
87  const auto toAtEndOfDurationInteger = toAtEndOfDuration->as<int>();
88  auto& animatedInteger = animated->as<int>();
89 
90  calculateAnimatedInteger(m_animationElement, percentage, repeatCount, fromInteger, toInteger, toAtEndOfDurationInteger, animatedInteger);
91 }
92 
93 float SVGAnimatedIntegerAnimator::calculateDistance(const String& fromString, const String& toString)
94 {
95  ASSERT(m_contextElement);
96  int from = fromString.toIntStrict();
97  int to = toString.toIntStrict();
98  return abs(to - from);
99 }
100 
101 }

Source/WebCore/svg/SVGAnimatedInteger.h

1 /*
2  * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3  * Copyright (C) 2018 Apple Inc. All rights reserved.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public License
16  * along with this library; see the file COPYING.LIB. If not, write to
17  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  */
20 
21 #pragma once
22 
23 #include "SVGAnimatedStaticPropertyTearOff.h"
24 #include "SVGAnimatedTypeAnimator.h"
25 #include "SVGAttributeAccessor.h"
26 
27 namespace WebCore {
28 
29 class SVGAnimationElement;
30 
31 using SVGAnimatedInteger = SVGAnimatedStaticPropertyTearOff<int>;
32 using SVGAnimatedIntegerAttribute = SVGAnimatedAttribute<SVGAnimatedInteger>;
33 
34 template<typename OwnerType>
35 using SVGAnimatedIntegerAttributeAccessor = SVGAnimatedAttributeAccessor<OwnerType, SVGAnimatedIntegerAttribute, AnimatedInteger>;
36 
37 template<typename OwnerType>
38 using SVGAnimatedOptionalIntegerAttributeAccessor = SVGAnimatedOptionalAttributeAccessor<OwnerType, SVGAnimatedIntegerAttribute, AnimatedIntegerOptionalInteger>;
39 
40 class SVGAnimatedIntegerAnimator final : public SVGAnimatedTypeAnimator {
41 public:
42  SVGAnimatedIntegerAnimator(SVGAnimationElement*, SVGElement*);
43 
44  static void calculateAnimatedInteger(SVGAnimationElement*, float percentage, unsigned repeatCount, int fromInteger, int toInteger, int toAtEndOfDurationInteger, int& animatedInteger);
45 
46  std::unique_ptr<SVGAnimatedType> constructFromString(const String&) override;
47  std::unique_ptr<SVGAnimatedType> startAnimValAnimation(const SVGElementAnimatedPropertyList&) override;
48  void stopAnimValAnimation(const SVGElementAnimatedPropertyList&) override;
49  void resetAnimValToBaseVal(const SVGElementAnimatedPropertyList&, SVGAnimatedType&) override;
50  void animValWillChange(const SVGElementAnimatedPropertyList&) override;
51  void animValDidChange(const SVGElementAnimatedPropertyList&) override;
52 
53  void addAnimatedTypes(SVGAnimatedType*, SVGAnimatedType*) override;
54  void calculateAnimatedValue(float percentage, unsigned repeatCount, SVGAnimatedType*, SVGAnimatedType*, SVGAnimatedType*, SVGAnimatedType*) override;
55  float calculateDistance(const String& fromString, const String& toString) override;
56 };
57 
58 } // namespace WebCore

Source/WebCore/svg/SVGAnimatedIntegerOptionalInteger.cpp

1 /*
2  * Copyright (C) Research In Motion Limited 2012. All rights reserved.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #include "config.h"
21 #include "SVGAnimatedIntegerOptionalInteger.h"
22 
23 #include "SVGAnimateElementBase.h"
24 #include "SVGAnimatedInteger.h"
25 #include "SVGParserUtilities.h"
26 
27 namespace WebCore {
28 
29 SVGAnimatedIntegerOptionalIntegerAnimator::SVGAnimatedIntegerOptionalIntegerAnimator(SVGAnimationElement* animationElement, SVGElement* contextElement)
30  : SVGAnimatedTypeAnimator(AnimatedIntegerOptionalInteger, animationElement, contextElement)
31 {
32 }
33 
34 std::unique_ptr<SVGAnimatedType> SVGAnimatedIntegerOptionalIntegerAnimator::constructFromString(const String& string)
35 {
36  return SVGAnimatedType::create(SVGPropertyTraits<std::pair<int, int>>::fromString(string));
37 }
38 
39 std::unique_ptr<SVGAnimatedType> SVGAnimatedIntegerOptionalIntegerAnimator::startAnimValAnimation(const SVGElementAnimatedPropertyList& animatedTypes)
40 {
41  return constructFromBaseValues<SVGAnimatedInteger, SVGAnimatedInteger>(animatedTypes);
42 }
43 
44 void SVGAnimatedIntegerOptionalIntegerAnimator::stopAnimValAnimation(const SVGElementAnimatedPropertyList& animatedTypes)
45 {
46  stopAnimValAnimationForTypes<SVGAnimatedInteger, SVGAnimatedInteger>(animatedTypes);
47 }
48 
49 void SVGAnimatedIntegerOptionalIntegerAnimator::resetAnimValToBaseVal(const SVGElementAnimatedPropertyList& animatedTypes, SVGAnimatedType& type)
50 {
51  resetFromBaseValues<SVGAnimatedInteger, SVGAnimatedInteger>(animatedTypes, type);
52 }
53 
54 void SVGAnimatedIntegerOptionalIntegerAnimator::animValWillChange(const SVGElementAnimatedPropertyList& animatedTypes)
55 {
56  animValWillChangeForTypes<SVGAnimatedInteger, SVGAnimatedInteger>(animatedTypes);
57 }
58 
59 void SVGAnimatedIntegerOptionalIntegerAnimator::animValDidChange(const SVGElementAnimatedPropertyList& animatedTypes)
60 {
61  animValDidChangeForTypes<SVGAnimatedInteger, SVGAnimatedInteger>(animatedTypes);
62 }
63 
64 void SVGAnimatedIntegerOptionalIntegerAnimator::addAnimatedTypes(SVGAnimatedType* from, SVGAnimatedType* to)
65 {
66  ASSERT(from->type() == AnimatedIntegerOptionalInteger);
67  ASSERT(from->type() == to->type());
68 
69  const auto& fromIntegerPair = from->as<std::pair<int, int>>();
70  auto& toIntegerPair = to->as<std::pair<int, int>>();
71 
72  toIntegerPair.first += fromIntegerPair.first;
73  toIntegerPair.second += fromIntegerPair.second;
74 }
75 
76 void SVGAnimatedIntegerOptionalIntegerAnimator::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGAnimatedType* from, SVGAnimatedType* to, SVGAnimatedType* toAtEndOfDuration, SVGAnimatedType* animated)
77 {
78  ASSERT(m_animationElement);
79  ASSERT(m_contextElement);
80 
81  const auto& fromIntegerPair = (m_animationElement->animationMode() == ToAnimation ? animated : from)->as<std::pair<int, int>>();
82  const auto& toIntegerPair = to->as<std::pair<int, int>>();
83  const auto& toAtEndOfDurationIntegerPair = toAtEndOfDuration->as<std::pair<int, int>>();
84  auto& animatedIntegerPair = animated->as<std::pair<int, int>>();
85 
86  SVGAnimatedIntegerAnimator::calculateAnimatedInteger(m_animationElement, percentage, repeatCount, fromIntegerPair.first, toIntegerPair.first, toAtEndOfDurationIntegerPair.first, animatedIntegerPair.first);
87  SVGAnimatedIntegerAnimator::calculateAnimatedInteger(m_animationElement, percentage, repeatCount, fromIntegerPair.second, toIntegerPair.second, toAtEndOfDurationIntegerPair.second, animatedIntegerPair.second);
88 }
89 
90 float SVGAnimatedIntegerOptionalIntegerAnimator::calculateDistance(const String&, const String&)
91 {
92  // FIXME: Distance calculation is not possible for SVGIntegerOptionalInteger right now. We need the distance for every single value.
93  return -1;
94 }
95 
96 }

Source/WebCore/svg/SVGAnimatedIntegerOptionalInteger.h

1 /*
2  * Copyright (C) Research In Motion Limited 2012. All rights reserved.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #pragma once
21 
22 #include "SVGAnimatedTypeAnimator.h"
23 
24 namespace WebCore {
25 
26 class SVGAnimationElement;
27 
28 class SVGAnimatedIntegerOptionalIntegerAnimator final : public SVGAnimatedTypeAnimator {
29 public:
30  SVGAnimatedIntegerOptionalIntegerAnimator(SVGAnimationElement*, SVGElement*);
31 
32  std::unique_ptr<SVGAnimatedType> constructFromString(const String&) override;
33  std::unique_ptr<SVGAnimatedType> startAnimValAnimation(const SVGElementAnimatedPropertyList&) override;
34  void stopAnimValAnimation(const SVGElementAnimatedPropertyList&) override;
35  void resetAnimValToBaseVal(const SVGElementAnimatedPropertyList&, SVGAnimatedType&) override;
36  void animValWillChange(const SVGElementAnimatedPropertyList&) override;
37  void animValDidChange(const SVGElementAnimatedPropertyList&) override;
38 
39  void addAnimatedTypes(SVGAnimatedType*, SVGAnimatedType*) override;
40  void calculateAnimatedValue(float percentage, unsigned repeatCount, SVGAnimatedType*, SVGAnimatedType*, SVGAnimatedType*, SVGAnimatedType*) override;
41  float calculateDistance(const String& fromString, const String& toString) override;
42 };
43 
44 } // namespace WebCore

Source/WebCore/svg/SVGAnimatedLength.cpp

@@void SVGAnimatedLengthAnimator::calculateAnimatedValue(float percentage, unsigne
8686 ASSERT(m_animationElement);
8787 ASSERT(m_contextElement);
8888
89  auto fromSVGLength = (m_animationElement->animationMode() == ToAnimation ? animated : from)->as<SVGLengthValue>();
 89 auto fromSVGLength = (m_animationElement->animationMode() == AnimationMode::To ? animated : from)->as<SVGLengthValue>();
9090 auto toSVGLength = to->as<SVGLengthValue>();
9191 const auto& toAtEndOfDurationSVGLength = toAtEndOfDuration->as<SVGLengthValue>();
9292 auto& animatedSVGLength = animated->as<SVGLengthValue>();

Source/WebCore/svg/SVGAnimatedLengthList.cpp

@@void SVGAnimatedLengthListAnimator::calculateAnimatedValue(float percentage, uns
9090 ASSERT(m_animationElement);
9191 ASSERT(m_contextElement);
9292
93  auto fromLengthList = (m_animationElement->animationMode() == ToAnimation ? animated : from)->as<SVGLengthListValues>();
 93 auto fromLengthList = (m_animationElement->animationMode() == AnimationMode::To ? animated : from)->as<SVGLengthListValues>();
9494 auto toLengthList = to->as<SVGLengthListValues>();
9595 const auto& toAtEndOfDurationLengthList = toAtEndOfDuration->as<SVGLengthListValues>();
9696 auto& animatedLengthList = animated->as<SVGLengthListValues>();

Source/WebCore/svg/SVGAnimatedNumber.cpp

@@void SVGAnimatedNumberAnimator::calculateAnimatedValue(float percentage, unsigne
7979 ASSERT(m_animationElement);
8080 ASSERT(m_contextElement);
8181
82  auto fromNumber = (m_animationElement->animationMode() == ToAnimation ? animated : from)->as<float>();
 82 auto fromNumber = (m_animationElement->animationMode() == AnimationMode::To ? animated : from)->as<float>();
8383 auto toNumber = to->as<float>();
8484 const auto toAtEndOfDurationNumber = toAtEndOfDuration->as<float>();
8585 auto& animatedNumber = animated->as<float>();

Source/WebCore/svg/SVGAnimatedNumberList.cpp

@@void SVGAnimatedNumberListAnimator::calculateAnimatedValue(float percentage, uns
8181{
8282 ASSERT(m_animationElement);
8383
84  const auto& fromNumberList = (m_animationElement->animationMode() == ToAnimation ? animated : from)->as<SVGNumberListValues>();
 84 const auto& fromNumberList = (m_animationElement->animationMode() == AnimationMode::To ? animated : from)->as<SVGNumberListValues>();
8585 const auto& toNumberList = to->as<SVGNumberListValues>();
8686 const auto& toAtEndOfDurationNumberList = toAtEndOfDuration->as<SVGNumberListValues>();
8787 auto& animatedNumberList = animated->as<SVGNumberListValues>();

Source/WebCore/svg/SVGAnimatedNumberOptionalNumber.cpp

@@void SVGAnimatedNumberOptionalNumberAnimator::calculateAnimatedValue(float perce
7878 ASSERT(m_animationElement);
7979 ASSERT(m_contextElement);
8080
81  const auto& fromNumberPair = (m_animationElement->animationMode() == ToAnimation ? animated : from)->as<std::pair<float, float>>();
 81 const auto& fromNumberPair = (m_animationElement->animationMode() == AnimationMode::To ? animated : from)->as<std::pair<float, float>>();
8282 const auto& toNumberPair = to->as<std::pair<float, float>>();
8383 const auto& toAtEndOfDurationNumberPair = toAtEndOfDuration->as<std::pair<float, float>>();
8484 auto& animatedNumberPair = animated->as<std::pair<float, float>>();

Source/WebCore/svg/SVGAnimatedPath.cpp

@@void SVGAnimatedPathAnimator::calculateAnimatedValue(float percentage, unsigned
108108 ASSERT(m_animationElement);
109109 ASSERT(m_contextElement);
110110
111  bool isToAnimation = m_animationElement->animationMode() == ToAnimation;
 111 bool isToAnimation = m_animationElement->animationMode() == AnimationMode::To;
112112 auto& animatedPath = animated->as<SVGPathByteStream>();
113113
114114 SVGPathByteStream underlyingPath;

Source/WebCore/svg/SVGAnimatedPointList.cpp

@@void SVGAnimatedPointListAnimator::calculateAnimatedValue(float percentage, unsi
8282{
8383 ASSERT(m_animationElement);
8484
85  const auto& fromPointList = (m_animationElement->animationMode() == ToAnimation ? animated : from)->as<SVGPointListValues>();
 85 const auto& fromPointList = (m_animationElement->animationMode() == AnimationMode::To ? animated : from)->as<SVGPointListValues>();
8686 const auto& toPointList = to->as<SVGPointListValues>();
8787 const auto& toAtEndOfDurationPointList = toAtEndOfDuration->as<SVGPointListValues>();
8888 auto& animatedPointList = animated->as<SVGPointListValues>();

Source/WebCore/svg/SVGAnimatedPointList.h

2222
2323#include "SVGAnimatedListPropertyTearOff.h"
2424#include "SVGAnimatedTypeAnimator.h"
 25#include "SVGAttribute.h"
 26#include "SVGAttributeAccessor.h"
2527#include "SVGPointList.h"
2628
2729namespace WebCore {

Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.cpp

@@void SVGAnimatedPreserveAspectRatioAnimator::calculateAnimatedValue(float percen
6969 ASSERT(m_animationElement);
7070 ASSERT(m_contextElement);
7171
72  const auto& fromPreserveAspectRatio = (m_animationElement->animationMode() == ToAnimation ? animated : from)->as<SVGPreserveAspectRatioValue>();
 72 const auto& fromPreserveAspectRatio = (m_animationElement->animationMode() == AnimationMode::To ? animated : from)->as<SVGPreserveAspectRatioValue>();
7373 const auto& toPreserveAspectRatio = to->as<SVGPreserveAspectRatioValue>();
7474 auto& animatedPreserveAspectRatio = animated->as<SVGPreserveAspectRatioValue>();
7575

Source/WebCore/svg/SVGAnimatedRect.cpp

@@void SVGAnimatedRectAnimator::calculateAnimatedValue(float percentage, unsigned
7373 ASSERT(m_animationElement);
7474 ASSERT(m_contextElement);
7575
76  const auto& fromRect = (m_animationElement->animationMode() == ToAnimation ? animated : from)->as<FloatRect>();
 76 const auto& fromRect = (m_animationElement->animationMode() == AnimationMode::To ? animated : from)->as<FloatRect>();
7777 const auto& toRect = to->as<FloatRect>();
7878 const auto& toAtEndOfDurationRect = toAtEndOfDuration->as<FloatRect>();
7979 auto& animatedRect = animated->as<FloatRect>();

Source/WebCore/svg/SVGAnimatedTransformList.cpp

@@void SVGAnimatedTransformListAnimator::calculateAnimatedValue(float percentage,
105105 return;
106106
107107 // Never resize the animatedTransformList to the toTransformList size, instead either clear the list or append to it.
108  if (!animatedTransformList.isEmpty() && (!m_animationElement->isAdditive() || m_animationElement->animationMode() == ToAnimation))
 108 if (!animatedTransformList.isEmpty() && (!m_animationElement->isAdditive() || m_animationElement->animationMode() == AnimationMode::To))
109109 animatedTransformList.clear();
110110
111111 auto fromTransformListSize = fromTransformList.size();

Source/WebCore/svg/SVGAnimationController.cpp

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#include "config.h"
 27#include "SVGAnimationController.h"
 28
 29#include "CSSPropertyNames.h"
 30#include "CSSPropertyParser.h"
 31#include "QualifiedName.h"
 32#include "SVGAnimatorFactory.h"
 33#include "SVGElement.h"
 34#include "SVGNames.h"
 35#include "StyleProperties.h"
 36#include <wtf/IsoMallocInlines.h>
 37
 38namespace WebCore {
 39
 40SVGAnimationController::SVGAnimationController(SVGAnimationElement& animationElement, SVGElement& targetElement)
 41 : SVGAnimationControllerBase(animationElement, targetElement)
 42{
 43 m_animatedPropertyType = determineAnimatedPropertyType(m_animationElement, m_targetElement, m_animationElement.attributeName());
 44}
 45
 46SVGAnimatedTypeAnimator* SVGAnimationController::ensureAnimator()
 47{
 48 if (!m_animator)
 49 m_animator = SVGAnimatorFactory::create(&m_animationElement, &m_targetElement, m_animatedPropertyType);
 50 ASSERT(m_animatedPropertyType == m_animator->type());
 51 return m_animator.get();
 52}
 53
 54bool SVGAnimationController::isAdditive() const
 55{
 56 // Spec: http://www.w3.org/TR/SVG/animate.html#AnimationAttributesAndProperties.
 57 switch (m_animatedPropertyType) {
 58 case AnimatedBoolean:
 59 case AnimatedEnumeration:
 60 case AnimatedPreserveAspectRatio:
 61 case AnimatedString:
 62 case AnimatedUnknown:
 63 return false;
 64 case AnimatedAngle:
 65 case AnimatedColor:
 66 case AnimatedInteger:
 67 case AnimatedIntegerOptionalInteger:
 68 case AnimatedLength:
 69 case AnimatedLengthList:
 70 case AnimatedNumber:
 71 case AnimatedNumberList:
 72 case AnimatedNumberOptionalNumber:
 73 case AnimatedPath:
 74 case AnimatedPoints:
 75 case AnimatedRect:
 76 case AnimatedTransformList:
 77 return true;
 78 default:
 79 RELEASE_ASSERT_NOT_REACHED();
 80 return true;
 81 }
 82}
 83
 84bool SVGAnimationController::hasValidAttributeType() const
 85{
 86 return m_animatedPropertyType != AnimatedUnknown;
 87}
 88
 89bool SVGAnimationController::calculateFromAndToValues(const String& fromString, const String& toString)
 90{
 91 m_animationElement.determinePropertyValueTypes(fromString, toString);
 92 ensureAnimator()->calculateFromAndToValues(m_fromType, m_toType, fromString, toString);
 93 ASSERT(m_animatedPropertyType == m_animator->type());
 94 return true;
 95}
 96
 97bool SVGAnimationController::calculateFromAndByValues(const String& fromString, const String& byString)
 98{
 99 if (m_animationElement.animationMode() == AnimationMode::By && !isAdditive())
 100 return false;
 101
 102 // from-by animation may only be used with attributes that support addition (e.g. most numeric attributes).
 103 if (m_animationElement.animationMode() == AnimationMode::FromBy && !isAdditive())
 104 return false;
 105
 106 m_animationElement.determinePropertyValueTypes(fromString, byString);
 107 ensureAnimator()->calculateFromAndByValues(m_fromType, m_toType, fromString, byString);
 108 ASSERT(m_animatedPropertyType == m_animator->type());
 109 return true;
 110}
 111
 112bool SVGAnimationController::calculateToAtEndOfDurationValue(const String& toAtEndOfDurationString)
 113{
 114 if (toAtEndOfDurationString.isEmpty())
 115 return false;
 116 m_toAtEndOfDurationType = ensureAnimator()->constructFromString(toAtEndOfDurationString);
 117 return true;
 118}
 119
 120#ifndef NDEBUG
 121static inline bool propertyTypesAreConsistent(AnimatedPropertyType expectedPropertyType, const SVGElementAnimatedPropertyList& animatedTypes)
 122{
 123 for (auto& type : animatedTypes) {
 124 for (auto& property : type.properties) {
 125 if (expectedPropertyType != property->animatedPropertyType()) {
 126 // This is the only allowed inconsistency. SVGAnimatedAngleAnimator handles both SVGAnimatedAngle & SVGAnimatedEnumeration for markers orient attribute.
 127 if (expectedPropertyType == AnimatedAngle && property->animatedPropertyType() == AnimatedEnumeration)
 128 return true;
 129 return false;
 130 }
 131 }
 132 }
 133
 134 return true;
 135}
 136#endif
 137
 138void SVGAnimationController::resetAnimatedType()
 139{
 140 SVGAnimatedTypeAnimator* animator = ensureAnimator();
 141 ASSERT(m_animatedPropertyType == animator->type());
 142
 143 const QualifiedName& attributeName = m_animationElement.attributeName();
 144 SVGAnimationElement::ShouldApplyAnimation shouldApply = m_animationElement.shouldApplyAnimation(&m_targetElement, attributeName);
 145
 146 if (shouldApply == SVGAnimationElement::DontApplyAnimation)
 147 return;
 148
 149 if (shouldApply == SVGAnimationElement::ApplyXMLAnimation || shouldApply == SVGAnimationElement::ApplyXMLandCSSAnimation) {
 150 // SVG DOM animVal animation code-path.
 151 m_animatedProperties = animator->findAnimatedPropertiesForAttributeName(m_targetElement, attributeName);
 152 if (m_animatedProperties.isEmpty())
 153 return;
 154
 155 ASSERT(propertyTypesAreConsistent(m_animatedPropertyType, m_animatedProperties));
 156 if (!m_animatedType)
 157 m_animatedType = animator->startAnimValAnimation(m_animatedProperties);
 158 else {
 159 animator->resetAnimValToBaseVal(m_animatedProperties, *m_animatedType);
 160 animator->animValDidChange(m_animatedProperties);
 161 }
 162 return;
 163 }
 164
 165 // CSS properties animation code-path.
 166 ASSERT(m_animatedProperties.isEmpty());
 167 String baseValue;
 168
 169 if (shouldApply == SVGAnimationElement::ApplyCSSAnimation) {
 170 ASSERT(SVGAnimationElement::isTargetAttributeCSSProperty(&m_targetElement, attributeName));
 171 m_animationElement.computeCSSPropertyValue(&m_targetElement, cssPropertyID(attributeName.localName()), baseValue);
 172 }
 173
 174 if (!m_animatedType)
 175 m_animatedType = animator->constructFromString(baseValue);
 176 else
 177 m_animatedType->setValueAsString(attributeName, baseValue);
 178}
 179
 180void SVGAnimationController::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGSMILElement* resultElement)
 181{
 182 ASSERT(resultElement);
 183
 184 const QualifiedName& attributeName = m_animationElement.attributeName();
 185 SVGAnimationElement::ShouldApplyAnimation shouldApply = m_animationElement.shouldApplyAnimation(&m_targetElement, attributeName);
 186
 187 if (shouldApply == SVGAnimationElement::DontApplyAnimation)
 188 return;
 189
 190 ASSERT(m_animatedPropertyType == determineAnimatedPropertyType(m_animationElement, m_targetElement, attributeName));
 191
 192 ASSERT(percentage >= 0 && percentage <= 1);
 193 ASSERT(m_animatedPropertyType != AnimatedTransformList || m_animationElement.hasTagName(SVGNames::animateTransformTag));
 194 ASSERT(m_animatedPropertyType != AnimatedUnknown);
 195 ASSERT(m_animator);
 196 ASSERT(m_animator->type() == m_animatedPropertyType);
 197 ASSERT(m_fromType);
 198 ASSERT(m_fromType->type() == m_animatedPropertyType);
 199 ASSERT(m_toType);
 200
 201 if (shouldApply == SVGAnimationElement::ApplyXMLAnimation || shouldApply == SVGAnimationElement::ApplyXMLandCSSAnimation) {
 202 // SVG DOM animVal animation code-path.
 203 if (m_animator->findAnimatedPropertiesForAttributeName(m_targetElement, attributeName).isEmpty())
 204 return;
 205 }
 206
 207 SVGAnimateElementBase& resultAnimationElement = downcast<SVGAnimateElementBase>(*resultElement);
 208 SVGAnimationController& resultAnimationController = static_cast<SVGAnimationController&>(resultAnimationElement.ensureController());
 209
 210 ASSERT(resultAnimationController.m_animatedType);
 211 ASSERT(resultAnimationController.m_animatedPropertyType == m_animatedPropertyType);
 212
 213 if (m_animationElement.hasTagName(SVGNames::setTag))
 214 percentage = 1;
 215
 216 if (m_animationElement.calcMode() == CalcMode::Discrete)
 217 percentage = percentage < 0.5 ? 0 : 1;
 218
 219 // Target element might have changed.
 220 m_animator->setContextElement(&m_targetElement);
 221
 222 // Be sure to detach list wrappers before we modfiy their underlying value. If we'd do
 223 // if after calculateAnimatedValue() ran the cached pointers in the list propery tear
 224 // offs would point nowhere, and we couldn't create copies of those values anymore,
 225 // while detaching. This is covered by assertions, moving this down would fire them.
 226 if (!m_animatedProperties.isEmpty())
 227 m_animator->animValWillChange(m_animatedProperties);
 228
 229 // Values-animation accumulates using the last values entry corresponding to the end of duration time.
 230 SVGAnimatedType* toAtEndOfDurationType = m_toAtEndOfDurationType ? m_toAtEndOfDurationType.get() : m_toType.get();
 231 m_animator->calculateAnimatedValue(percentage, repeatCount, m_fromType.get(), m_toType.get(), toAtEndOfDurationType, resultAnimationController.m_animatedType.get());
 232}
 233
 234static inline void applyCSSPropertyToTarget(SVGElement& targetElement, CSSPropertyID id, const String& value)
 235{
 236 ASSERT(!targetElement.m_deletionHasBegun);
 237
 238 if (!targetElement.ensureAnimatedSMILStyleProperties().setProperty(id, value, false))
 239 return;
 240
 241 targetElement.invalidateStyle();
 242}
 243
 244static inline void removeCSSPropertyFromTarget(SVGElement& targetElement, CSSPropertyID id)
 245{
 246 ASSERT(!targetElement.m_deletionHasBegun);
 247 targetElement.ensureAnimatedSMILStyleProperties().removeProperty(id);
 248 targetElement.invalidateStyle();
 249}
 250
 251static inline void applyCSSPropertyToTargetAndInstances(SVGElement& targetElement, const QualifiedName& attributeName, const String& valueAsString)
 252{
 253 // FIXME: Do we really need to check both isConnected and !parentNode?
 254 if (attributeName == anyQName() || !targetElement.isConnected() || !targetElement.parentNode())
 255 return;
 256
 257 CSSPropertyID id = cssPropertyID(attributeName.localName());
 258
 259 SVGElement::InstanceUpdateBlocker blocker(targetElement);
 260 applyCSSPropertyToTarget(targetElement, id, valueAsString);
 261
 262 // If the target element has instances, update them as well, w/o requiring the <use> tree to be rebuilt.
 263 for (auto* instance : targetElement.instances())
 264 applyCSSPropertyToTarget(*instance, id, valueAsString);
 265}
 266
 267static inline void removeCSSPropertyFromTargetAndInstances(SVGElement& targetElement, const QualifiedName& attributeName)
 268{
 269 // FIXME: Do we really need to check both isConnected and !parentNode?
 270 if (attributeName == anyQName() || !targetElement.isConnected() || !targetElement.parentNode())
 271 return;
 272
 273 CSSPropertyID id = cssPropertyID(attributeName.localName());
 274
 275 SVGElement::InstanceUpdateBlocker blocker(targetElement);
 276 removeCSSPropertyFromTarget(targetElement, id);
 277
 278 // If the target element has instances, update them as well, w/o requiring the <use> tree to be rebuilt.
 279 for (auto* instance : targetElement.instances())
 280 removeCSSPropertyFromTarget(*instance, id);
 281}
 282
 283static inline void notifyTargetAboutAnimValChange(SVGElement& targetElement, const QualifiedName& attributeName)
 284{
 285 ASSERT(!targetElement.m_deletionHasBegun);
 286 targetElement.svgAttributeChanged(attributeName);
 287}
 288
 289static inline void notifyTargetAndInstancesAboutAnimValChange(SVGElement& targetElement, const QualifiedName& attributeName)
 290{
 291 if (attributeName == anyQName() || !targetElement.isConnected() || !targetElement.parentNode())
 292 return;
 293
 294 SVGElement::InstanceUpdateBlocker blocker(targetElement);
 295 notifyTargetAboutAnimValChange(targetElement, attributeName);
 296
 297 // If the target element has instances, update them as well, w/o requiring the <use> tree to be rebuilt.
 298 for (auto* instance : targetElement.instances())
 299 notifyTargetAboutAnimValChange(*instance, attributeName);
 300}
 301
 302void SVGAnimationController::applyResultsToTarget()
 303{
 304 ASSERT(m_animatedPropertyType != AnimatedTransformList || m_animationElement.hasTagName(SVGNames::animateTransformTag));
 305 ASSERT(m_animatedPropertyType != AnimatedUnknown);
 306 ASSERT(m_animator);
 307
 308 // Early exit if our animated type got destroyed by a previous endedActiveInterval().
 309 if (!m_animatedType)
 310 return;
 311
 312 const QualifiedName& attributeName = m_animationElement.attributeName();
 313
 314 if (m_animatedProperties.isEmpty()) {
 315 // CSS properties animation code-path.
 316 // Convert the result of the animation to a String and apply it as CSS property on the target & all instances.
 317 applyCSSPropertyToTargetAndInstances(m_targetElement, attributeName, m_animatedType->valueAsString());
 318 return;
 319 }
 320
 321 // We do update the style and the animation property independent of each other.
 322 SVGAnimationElement::ShouldApplyAnimation shouldApply = m_animationElement.shouldApplyAnimation(&m_targetElement, attributeName);
 323 if (shouldApply == SVGAnimationElement::ApplyXMLandCSSAnimation)
 324 applyCSSPropertyToTargetAndInstances(m_targetElement, attributeName, m_animatedType->valueAsString());
 325
 326 // SVG DOM animVal animation code-path.
 327 // At this point the SVG DOM values are already changed, unlike for CSS.
 328 // We only have to trigger update notifications here.
 329 m_animator->animValDidChange(m_animatedProperties);
 330 notifyTargetAndInstancesAboutAnimValChange(m_targetElement, attributeName);
 331}
 332
 333void SVGAnimationController::clearAnimatedType(SVGElement* targetElement)
 334{
 335 if (!m_animatedType)
 336 return;
 337
 338 // If the SVGAnimatedType is a list type, e.g. SVGLengthListValues, the wrappers of the
 339 // animated properties have to be detached from the items in the list before it's deleted.
 340 if (!m_animatedProperties.isEmpty())
 341 m_animator->animValWillChange(m_animatedProperties);
 342
 343 if (!targetElement) {
 344 m_animatedType = nullptr;
 345 return;
 346 }
 347
 348 const QualifiedName& attributeName = m_animationElement.attributeName();
 349
 350 if (m_animatedProperties.isEmpty()) {
 351 // CSS properties animation code-path.
 352 removeCSSPropertyFromTargetAndInstances(*targetElement, m_animationElement.attributeName());
 353 m_animatedType = nullptr;
 354 return;
 355 }
 356
 357 SVGAnimationElement::ShouldApplyAnimation shouldApply = m_animationElement.shouldApplyAnimation(targetElement, attributeName);
 358 if (shouldApply == SVGAnimationElement::ApplyXMLandCSSAnimation)
 359 removeCSSPropertyFromTargetAndInstances(*targetElement, attributeName);
 360
 361 // SVG DOM animVal animation code-path.
 362 if (m_animator) {
 363 m_animator->stopAnimValAnimation(m_animatedProperties);
 364 notifyTargetAndInstancesAboutAnimValChange(*targetElement, attributeName);
 365 }
 366
 367 m_animatedProperties.clear();
 368 m_animatedType = nullptr;
 369}
 370
 371float SVGAnimationController::calculateDistance(const String& fromString, const String& toString)
 372{
 373 return ensureAnimator()->calculateDistance(fromString, toString);
 374}
 375
 376}
 377

Source/WebCore/svg/SVGAnimationController.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28#include "SVGAnimatedType.h"
 29#include "SVGAnimatedTypeAnimator.h"
 30#include "SVGAnimationControllerBase.h"
 31
 32namespace WebCore {
 33
 34class SVGAnimationElement;
 35class SVGElement;
 36class SVGSMILElement;
 37
 38class SVGAnimationController : public SVGAnimationControllerBase {
 39public:
 40 SVGAnimationController(SVGAnimationElement&, SVGElement&);
 41
 42private:
 43 SVGAnimatedTypeAnimator* ensureAnimator();
 44
 45 void resetAnimatedType() override;
 46 void clearAnimatedType(SVGElement* targetElement) override;
 47
 48 bool calculateFromAndToValues(const String& fromString, const String& toString) override;
 49 bool calculateFromAndByValues(const String& fromString, const String& byString) override;
 50 bool calculateToAtEndOfDurationValue(const String& toAtEndOfDurationString) override;
 51
 52 void calculateAnimatedValue(float percentage, unsigned repeatCount, SVGSMILElement* resultElement) override;
 53
 54 void applyResultsToTarget() override;
 55 float calculateDistance(const String& fromString, const String& toString) override;
 56
 57 bool isAdditive() const override;
 58 bool hasValidAttributeType() const override;
 59
 60 AnimatedPropertyType m_animatedPropertyType;
 61
 62 std::unique_ptr<SVGAnimatedType> m_fromType;
 63 std::unique_ptr<SVGAnimatedType> m_toType;
 64 std::unique_ptr<SVGAnimatedType> m_toAtEndOfDurationType;
 65 std::unique_ptr<SVGAnimatedType> m_animatedType;
 66
 67 SVGElementAnimatedPropertyList m_animatedProperties;
 68 std::unique_ptr<SVGAnimatedTypeAnimator> m_animator;
 69};
 70
 71} // namespace WebCore

Source/WebCore/svg/SVGAnimationControllerBase.cpp

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#include "config.h"
 27#include "SVGAnimationControllerBase.h"
 28
 29#include "SVGAnimationElement.h"
 30#include "SVGElement.h"
 31
 32namespace WebCore {
 33
 34SVGAnimationControllerBase::SVGAnimationControllerBase(SVGAnimationElement& animationElement, SVGElement& targetElement)
 35 : m_animationElement(animationElement)
 36 , m_targetElement(targetElement)
 37{
 38}
 39
 40AnimatedPropertyType SVGAnimationControllerBase::determineAnimatedPropertyType(const SVGAnimationElement& animationElement, SVGElement& targetElement, const QualifiedName& attributeName)
 41{
 42 auto propertyTypes = targetElement.animatedPropertyTypesForAttribute(attributeName);
 43 if (propertyTypes.isEmpty())
 44 return AnimatedUnknown;
 45
 46 ASSERT(propertyTypes.size() <= 2);
 47 AnimatedPropertyType type = propertyTypes[0];
 48 if (animationElement.hasTagName(SVGNames::animateColorTag) && type != AnimatedColor)
 49 return AnimatedUnknown;
 50
 51 // Animations of transform lists are not allowed for <animate> or <set>
 52 // http://www.w3.org/TR/SVG/animate.html#AnimationAttributesAndProperties
 53 if (type == AnimatedTransformList && !animationElement.hasTagName(SVGNames::animateTransformTag))
 54 return AnimatedUnknown;
 55
 56 // Fortunately there's just one special case needed here: SVGMarkerElements orientAttr, which
 57 // corresponds to SVGAnimatedAngle orientAngle and SVGAnimatedEnumeration orientType. We have to
 58 // figure out whose value to change here.
 59 if (targetElement.hasTagName(SVGNames::markerTag) && type == AnimatedAngle) {
 60 ASSERT(propertyTypes.size() == 2);
 61 ASSERT(propertyTypes[0] == AnimatedAngle);
 62 ASSERT(propertyTypes[1] == AnimatedEnumeration);
 63 } else if (propertyTypes.size() == 2)
 64 ASSERT(propertyTypes[0] == propertyTypes[1]);
 65
 66 return type;
 67}
 68
 69}

Source/WebCore/svg/SVGAnimationControllerBase.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28namespace WebCore {
 29
 30class SVGAnimationElement;
 31class SVGElement;
 32class SVGSMILElement;
 33
 34class SVGAnimationControllerBase {
 35public:
 36 SVGAnimationControllerBase(SVGAnimationElement&, SVGElement&);
 37 virtual ~SVGAnimationControllerBase() = default;
 38
 39 static AnimatedPropertyType determineAnimatedPropertyType(const SVGAnimationElement&, SVGElement&, const QualifiedName&);
 40
 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;
 50
 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
 56protected:
 57 SVGAnimationElement& m_animationElement;
 58 SVGElement& m_targetElement;
 59};
 60
 61} // namespace WebCore
 62

Source/WebCore/svg/SVGAnimationElement.cpp

@@void SVGAnimationElement::updateAnimationMode()
268268{
269269 // http://www.w3.org/TR/2001/REC-smil-animation-20010904/#AnimFuncValues
270270 if (hasAttribute(SVGNames::valuesAttr))
271  setAnimationMode(ValuesAnimation);
 271 setAnimationMode(AnimationMode::Values);
272272 else if (!toValue().isEmpty())
273  setAnimationMode(fromValue().isEmpty() ? ToAnimation : FromToAnimation);
 273 setAnimationMode(fromValue().isEmpty() ? AnimationMode::To : AnimationMode::FromTo);
274274 else if (!byValue().isEmpty())
275  setAnimationMode(fromValue().isEmpty() ? ByAnimation : FromByAnimation);
 275 setAnimationMode(fromValue().isEmpty() ? AnimationMode::By : AnimationMode::FromBy);
276276 else
277  setAnimationMode(NoAnimation);
 277 setAnimationMode(AnimationMode::None);
278278}
279279
280280void SVGAnimationElement::setCalcMode(const AtomicString& calcMode)

@@void SVGAnimationElement::setAttributeType(const AtomicString& attributeType)
305305 m_attributeType = AttributeType::XML;
306306 else
307307 m_attributeType = AttributeType::Auto;
308  checkInvalidCSSAttributeType(targetElement());
309308}
310309
311310String SVGAnimationElement::toValue() const

@@bool SVGAnimationElement::isAdditive() const
327326{
328327 static NeverDestroyed<const AtomicString> sum("sum", AtomicString::ConstructFromLiteral);
329328 const AtomicString& value = attributeWithoutSynchronization(SVGNames::additiveAttr);
330  return value == sum || animationMode() == ByAnimation;
 329 return value == sum || animationMode() == AnimationMode::By;
331330}
332331
333332bool SVGAnimationElement::isAccumulated() const
334333{
335334 static NeverDestroyed<const AtomicString> sum("sum", AtomicString::ConstructFromLiteral);
336335 const AtomicString& value = attributeWithoutSynchronization(SVGNames::accumulateAttr);
337  return value == sum && animationMode() != ToAnimation;
 336 return value == sum && animationMode() != AnimationMode::To;
338337}
339338
340339bool SVGAnimationElement::isTargetAttributeCSSProperty(SVGElement* element, const QualifiedName& attributeName)

@@SVGAnimationElement::ShouldApplyAnimation SVGAnimationElement::shouldApplyAnimat
369368void SVGAnimationElement::calculateKeyTimesForCalcModePaced()
370369{
371370 ASSERT(calcMode() == CalcMode::Paced);
372  ASSERT(animationMode() == ValuesAnimation);
 371 ASSERT(animationMode() == AnimationMode::Values);
373372
374373 unsigned valuesCount = m_values.size();
375374 ASSERT(valuesCount >= 1);

@@void SVGAnimationElement::startedActiveInterval()
554553 unsigned splinesCount = m_keySplines.size();
555554 if (!splinesCount
556555 || (hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) && m_keyPoints.size() - 1 != splinesCount)
557  || (animationMode == ValuesAnimation && m_values.size() - 1 != splinesCount)
 556 || (animationMode == AnimationMode::Values && m_values.size() - 1 != splinesCount)
558557 || (hasAttributeWithoutSynchronization(SVGNames::keyTimesAttr) && m_keyTimes.size() - 1 != splinesCount))
559558 return;
560559 }

@@void SVGAnimationElement::startedActiveInterval()
562561 String from = fromValue();
563562 String to = toValue();
564563 String by = byValue();
565  if (animationMode == NoAnimation)
 564 if (animationMode == AnimationMode::None)
566565 return;
567  if ((animationMode == FromToAnimation || animationMode == FromByAnimation || animationMode == ToAnimation || animationMode == ByAnimation)
 566 if ((animationMode == AnimationMode::FromTo || animationMode == AnimationMode::FromBy || animationMode == AnimationMode::To || animationMode == AnimationMode::By)
568567 && (hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) && hasAttributeWithoutSynchronization(SVGNames::keyTimesAttr) && (m_keyTimes.size() < 2 || m_keyTimes.size() != m_keyPoints.size())))
569568 return;
570  if (animationMode == FromToAnimation)
 569 if (animationMode == AnimationMode::FromTo)
571570 m_animationValid = calculateFromAndToValues(from, to);
572  else if (animationMode == ToAnimation) {
 571 else if (animationMode == AnimationMode::To) {
573572 // For to-animations the from value is the current accumulated value from lower priority animations.
574573 // The value is not static and is determined during the animation.
575574 m_animationValid = calculateFromAndToValues(emptyString(), to);
576  } else if (animationMode == FromByAnimation)
 575 } else if (animationMode == AnimationMode::FromBy)
577576 m_animationValid = calculateFromAndByValues(from, by);
578  else if (animationMode == ByAnimation)
 577 else if (animationMode == AnimationMode::By)
579578 m_animationValid = calculateFromAndByValues(emptyString(), by);
580  else if (animationMode == ValuesAnimation) {
 579 else if (animationMode == AnimationMode::Values) {
581580 m_animationValid = m_values.size() >= 1
582581 && (calcMode == CalcMode::Paced || !hasAttributeWithoutSynchronization(SVGNames::keyTimesAttr) || hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) || (m_values.size() == m_keyTimes.size()))
583582 && (calcMode == CalcMode::Discrete || !m_keyTimes.size() || m_keyTimes.last() == 1)

@@void SVGAnimationElement::startedActiveInterval()
587586 m_animationValid = calculateToAtEndOfDurationValue(m_values.last());
588587 if (calcMode == CalcMode::Paced && m_animationValid)
589588 calculateKeyTimesForCalcModePaced();
590  } else if (animationMode == PathAnimation)
 589 } else if (animationMode == AnimationMode::Path)
591590 m_animationValid = calcMode == CalcMode::Paced || !hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) || (m_keyTimes.size() > 1 && m_keyTimes.size() == m_keyPoints.size());
592591}
593592

@@void SVGAnimationElement::updateAnimation(float percent, unsigned repeatCount, S
599598 float effectivePercent;
600599 CalcMode calcMode = this->calcMode();
601600 AnimationMode animationMode = this->animationMode();
602  if (animationMode == ValuesAnimation) {
 601 if (animationMode == AnimationMode::Values) {
603602 String from;
604603 String to;
605604 currentValuesForValuesAnimation(percent, effectivePercent, from, to);

@@void SVGAnimationElement::updateAnimation(float percent, unsigned repeatCount, S
614613 effectivePercent = calculatePercentFromKeyPoints(percent);
615614 else if (m_keyPoints.isEmpty() && calcMode == CalcMode::Spline && m_keyTimes.size() > 1)
616615 effectivePercent = calculatePercentForSpline(percent, calculateKeyTimesIndex(percent));
617  else if (animationMode == FromToAnimation || animationMode == ToAnimation)
 616 else if (animationMode == AnimationMode::FromTo || animationMode == AnimationMode::To)
618617 effectivePercent = calculatePercentForFromTo(percent);
619618 else
620619 effectivePercent = percent;

@@void SVGAnimationElement::determinePropertyValueTypes(const String& from, const
667666 if (inheritsFromProperty(targetElement.get(), attributeName, to))
668667 m_toPropertyValueType = InheritValue;
669668}
670 void SVGAnimationElement::resetAnimatedPropertyType()
 669void SVGAnimationElement::resetAnimation()
671670{
672671 m_lastValuesAnimationFrom = String();
673672 m_lastValuesAnimationTo = 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 
687675}

Source/WebCore/svg/SVGAnimationElement.h

@@class ConditionEventListener;
3636class SVGAnimatedType;
3737class TimeContainer;
3838
39 enum AnimationMode {
40  NoAnimation,
41  FromToAnimation,
42  FromByAnimation,
43  ToAnimation,
44  ByAnimation,
45  ValuesAnimation,
46  PathAnimation // 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 };
5242
53 enum class CalcMode { Discrete, Linear, Paced, Spline };
54 
5543class SVGAnimationElement : public SVGSMILElement, public SVGExternalResourcesRequired, public SVGTests {
5644 WTF_MAKE_ISO_ALLOCATED(SVGAnimationElement);
5745public:

@@public:
10593 unsigned fromListSize = fromList.size();
10694 if (fromListSize != toListSize && fromListSize) {
10795 if (percentage < 0.5) {
108  if (animationMode() != ToAnimation)
 96 if (animationMode() != AnimationMode::To)
10997 animatedList = AnimatedType(fromList);
11098 } else
11199 animatedList = AnimatedType(toList);

@@public:
122110
123111 template<typename AnimatedType> void animateDiscreteType(float percentage, const AnimatedType& fromType, const AnimatedType& toType, AnimatedType& animatedType)
124112 {
125  if ((animationMode() == FromToAnimation && percentage > 0.5) || animationMode() == ToAnimation || percentage == 1) {
 113 if ((animationMode() == AnimationMode::FromTo && percentage > 0.5) || animationMode() == AnimationMode::To || percentage == 1) {
126114 animatedType = AnimatedType(toType);
127115 return;
128116 }

@@public:
140128 if (isAccumulated() && repeatCount)
141129 number += toAtEndOfDurationNumber * repeatCount;
142130
143  if (isAdditive() && animationMode() != ToAnimation)
 131 if (isAdditive() && animationMode() != AnimationMode::To)
144132 animatedNumber += number;
145133 else
146134 animatedNumber = number;
147135 }
148136
 137 enum class AttributeType { CSS, XML, Auto };
 138 AttributeType attributeType() const { return m_attributeType; }
 139 void computeCSSPropertyValue(SVGElement*, CSSPropertyID, String& value);
 140 virtual void determinePropertyValueTypes(const String& from, const String& to);
 141
149142protected:
150143 SVGAnimationElement(const QualifiedName&, Document&);
151144

@@protected:
153146 static AttributeOwnerProxy::AttributeRegistry& attributeRegistry() { return AttributeOwnerProxy::attributeRegistry(); }
154147 const SVGAttributeOwnerProxy& attributeOwnerProxy() const override { return m_attributeOwnerProxy; }
155148
156  void computeCSSPropertyValue(SVGElement*, CSSPropertyID, String& value);
157  virtual void determinePropertyValueTypes(const String& from, const String& to);
158  virtual void resetAnimatedPropertyType();
 149 virtual void resetAnimation();
159150
160151 static bool isSupportedAttribute(const QualifiedName&);
161152 void parseAttribute(const QualifiedName&, const AtomicString&) override;
162153 void svgAttributeChanged(const QualifiedName&) override;
163154
164  enum class AttributeType { CSS, XML, Auto };
165  AttributeType attributeType() const { return m_attributeType; }
166 
167155 String toValue() const;
168156 String byValue() const;
169157 String fromValue() const;

@@protected:
177165 AnimatedPropertyValueType m_fromPropertyValueType { RegularPropertyValue };
178166 AnimatedPropertyValueType m_toPropertyValueType { RegularPropertyValue };
179167
180  void setTargetElement(SVGElement*) override;
181168 void setAttributeName(const QualifiedName&) override { }
182  bool hasInvalidCSSAttributeType() const { return m_hasInvalidCSSAttributeType; }
183  void checkInvalidCSSAttributeType(SVGElement*);
184169
185170 virtual void updateAnimationMode();
186171 void setAnimationMode(AnimationMode animationMode) { m_animationMode = animationMode; }

@@private:
218203 Vector<UnitBezier> m_keySplines;
219204 String m_lastValuesAnimationFrom;
220205 String m_lastValuesAnimationTo;
221  bool m_hasInvalidCSSAttributeType { false };
222206 CalcMode m_calcMode { CalcMode::Linear };
223  AnimationMode m_animationMode { NoAnimation };
 207 AnimationMode m_animationMode { AnimationMode::None };
224208 AttributeOwnerProxy m_attributeOwnerProxy { *this };
225209};
226210

Source/WebCore/svg/SVGAnimatorFactory.h

2323#include "SVGAnimatedBoolean.h"
2424#include "SVGAnimatedColor.h"
2525#include "SVGAnimatedEnumeration.h"
26 #include "SVGAnimatedInteger.h"
27 #include "SVGAnimatedIntegerOptionalInteger.h"
2826#include "SVGAnimatedLength.h"
2927#include "SVGAnimatedLengthList.h"
3028#include "SVGAnimatedNumber.h"

@@public:
5856 case AnimatedEnumeration:
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);
6664 case AnimatedLengthList:

Source/WebCore/svg/SVGElement.cpp

@@void SVGElement::synchronizeAllAnimatedSVGAttribute(SVGElement* svgElement)
700700
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
705713void SVGElement::synchronizeAnimatedSVGAttribute(const QualifiedName& name) const

@@void SVGElement::synchronizeAnimatedSVGAttribute(const QualifiedName& name) cons
707715 if (!elementData() || !elementData()->animatedSVGAttributesAreDirty())
708716 return;
709717
 718 // FIXME: Delete the SVG tear off properties code from this function
 719
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);
715729}
716730
 731void SVGElement::commitPropertyChange(SVGNewAnimatedProperty* 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
 750RefPtr<SVGAnimator> 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 for (auto* instance : instances())
 754 instance->propertyRegistry().appendAnimatedInstance(attributeName, animator);
 755 return animator;
 756}
 757
717758Optional<ElementStyle> SVGElement::resolveCustomStyle(const RenderStyle& parentStyle, const RenderStyle*)
718759{
719760 // If the element is in a <use> tree we get the style from the definition tree.

Source/WebCore/svg/SVGElement.h

2222
2323#pragma once
2424
25 #include "SVGAnimatedString.h"
 25#include "SVGAnimatedPropertyImpl.h"
2626#include "SVGAttributeOwnerProxy.h"
2727#include "SVGLangSpace.h"
2828#include "SVGLocatable.h"
2929#include "SVGNames.h"
3030#include "SVGParsingError.h"
 31#include "SVGPropertyOwnerRegistry.h"
3132#include "StyledElement.h"
3233#include <wtf/HashMap.h>
3334#include <wtf/HashSet.h>

@@class SVGUseElement;
4647
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:
5253 bool isOutermostSVGSVGElement() const;

@@public:
150151 RefPtr<SVGAnimatedProperty> lookupOrCreateAnimatedProperty(const SVGAttribute& attribute) { return attributeOwnerProxy().lookupOrCreateAnimatedProperty(attribute); }
151152 Vector<RefPtr<SVGAnimatedProperty>> 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(SVGNewAnimatedProperty*);
 162
 163 const SVGElement* attributeContextElement() const override { return this; }
 164 RefPtr<SVGAnimator> 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()); }
155168 auto classNameAnimated() { return m_className.animatedProperty(attributeOwnerProxy()); }

@@private:
204217
205218 AttributeOwnerProxy m_attributeOwnerProxy { *this };
206219 SVGAnimatedStringAttribute m_className;
 220
 221 PropertyRegistry m_propertyRegistry { *this };
207222};
208223
209224class SVGElement::InstanceInvalidationGuard {

Source/WebCore/svg/SVGFEConvolveMatrixElement.cpp

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
66 * modify it under the terms of the GNU Library General Public

@@inline SVGFEConvolveMatrixElement::SVGFEConvolveMatrixElement(const QualifiedNam
4040{
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
4552Ref<SVGFEConvolveMatrixElement> SVGFEConvolveMatrixElement::create(const QualifiedName& tagName, Document& document)

@@const AtomicString& SVGFEConvolveMatrixElement::kernelUnitLengthYIdentifier()
5966 return s_identifier;
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{
7671 auto& registry = attributeRegistry();
7772 if (!registry.isEmpty())
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,
9080 &SVGFEConvolveMatrixElement::kernelUnitLengthXIdentifier, &SVGFEConvolveMatrixElement::m_kernelUnitLengthX,

@@void SVGFEConvolveMatrixElement::parseAttribute(const QualifiedName& name, const
10292 if (name == SVGNames::orderAttr) {
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.");
10999 return;

@@void SVGFEConvolveMatrixElement::parseAttribute(const QualifiedName& name, const
141131 }
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 }
152142

@@bool SVGFEConvolveMatrixElement::setFilterEffectAttribute(FilterEffect* effect,
197187
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}
204194

Source/WebCore/svg/SVGFEConvolveMatrixElement.h

2121#pragma once
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
3126namespace WebCore {

@@public:
7368 void setKernelUnitLength(float kernelUnitLengthX, float kernelUnitLengthY);
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()); }
8580 float kernelUnitLengthY() const { return m_kernelUnitLengthY.currentValue(attributeOwnerProxy()); }
8681 bool preserveAlpha() const { return m_preserveAlpha.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 Ref<SVGAnimatedInteger>& orderXAnimated() { return m_orderX; }
 85 Ref<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 Ref<SVGAnimatedInteger>& targetXAnimated() { return m_targetX; }
 90 Ref<SVGAnimatedInteger>& targetYAnimated() { return m_targetY; }
9691 RefPtr<SVGAnimatedEnumeration> edgeModeAnimated() { return m_edgeMode.animatedProperty(attributeOwnerProxy()); }
9792 RefPtr<SVGAnimatedNumber> kernelUnitLengthXAnimated() { return m_kernelUnitLengthX.animatedProperty(attributeOwnerProxy()); }
9893 RefPtr<SVGAnimatedNumber> kernelUnitLengthYAnimated() { return m_kernelUnitLengthY.animatedProperty(attributeOwnerProxy()); }

@@private:
105100 static AttributeOwnerProxy::AttributeRegistry& attributeRegistry() { return AttributeOwnerProxy::attributeRegistry(); }
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; }
110108 void parseAttribute(const QualifiedName&, const AtomicString&) override;

@@private:
113111 bool setFilterEffectAttribute(FilterEffect*, const QualifiedName&) override;
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;
132130 SVGAnimatedNumberAttribute m_kernelUnitLengthY;

Source/WebCore/svg/SVGFETurbulenceElement.cpp

@@inline SVGFETurbulenceElement::SVGFETurbulenceElement(const QualifiedName& tagNa
3535{
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
4045Ref<SVGFETurbulenceElement> SVGFETurbulenceElement::create(const QualifiedName& tagName, Document& document)

@@void SVGFETurbulenceElement::registerAttributes()
6267 registry.registerAttribute<SVGNames::baseFrequencyAttr,
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>();
6872 registry.registerAttribute<SVGNames::typeAttr, TurbulenceType, &SVGFETurbulenceElement::m_type>();

@@void SVGFETurbulenceElement::parseAttribute(const QualifiedName& name, const Ato
99103 }
100104
101105 if (name == SVGNames::numOctavesAttr) {
102  m_numOctaves.setValue(value.string().toUIntStrict());
 106 m_numOctaves->setBaseValInternal(value.string().toUIntStrict());
103107 return;
104108 }
105109

Source/WebCore/svg/SVGFETurbulenceElement.h

11/*
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
77 * modify it under the terms of the GNU Library General Public

2323
2424#include "FETurbulence.h"
2525#include "SVGAnimatedEnumeration.h"
26 #include "SVGAnimatedInteger.h"
2726#include "SVGAnimatedNumber.h"
2827#include "SVGFilterPrimitiveStandardAttributes.h"
2928

@@public:
10099
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()); }
106105 TurbulenceType type() const { return m_type.currentValue(attributeOwnerProxy()); }
107106
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 Ref<SVGAnimatedInteger>& numOctavesAnimated() { return m_numOctaves; }
111110 RefPtr<SVGAnimatedNumber> seedAnimated() { return m_seed.animatedProperty(attributeOwnerProxy()); }
112111 RefPtr<SVGAnimatedEnumeration> stitchTilesAnimated() { return m_stitchTiles.animatedProperty(attributeOwnerProxy()); }
113112 RefPtr<SVGAnimatedEnumeration> typeAnimated() { return m_type.animatedProperty(attributeOwnerProxy()); }

@@private:
119118 static AttributeOwnerProxy::AttributeRegistry& attributeRegistry() { return AttributeOwnerProxy::attributeRegistry(); }
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; }
124126 void parseAttribute(const QualifiedName&, const AtomicString&) override;

@@private:
131133 static const AtomicString& baseFrequencyYIdentifier();
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 };
139142 SVGAnimatedEnumerationAttribute<TurbulenceType> m_type { TurbulenceType::Turbulence };

Source/WebCore/svg/SVGFilterElement.h

2424#pragma once
2525
2626#include "SVGAnimatedEnumeration.h"
27 #include "SVGAnimatedInteger.h"
2827#include "SVGAnimatedLength.h"
2928#include "SVGElement.h"
3029#include "SVGExternalResourcesRequired.h"

Source/WebCore/svg/SVGNewAnimationController.cpp

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#include "config.h"
 27#include "SVGNewAnimationController.h"
 28
 29#include "QualifiedName.h"
 30#include "SVGAnimationElement.h"
 31#include "SVGAnimator.h"
 32#include "SVGElement.h"
 33
 34namespace WebCore {
 35
 36
 37SVGNewAnimationController::SVGNewAnimationController(SVGAnimationElement& animationElement, SVGElement& targetElement)
 38 : SVGAnimationControllerBase(animationElement, targetElement)
 39{
 40}
 41
 42RefPtr<SVGAnimator> SVGNewAnimationController::createAnimator() const
 43{
 44 if (!m_animator)
 45 m_animator = m_targetElement.createAnimator(m_animationElement.attributeName(), m_animationElement.animationMode(), m_animationElement.calcMode(), m_animationElement.isAccumulated(), m_animationElement.isAdditive());
 46
 47 return m_animator;
 48}
 49
 50bool SVGNewAnimationController::isDiscreteAnimator() const
 51{
 52 return hasValidAttributeType() && m_animator && m_animator->isDiscrete();
 53}
 54
 55bool SVGNewAnimationController::isAdditive() const
 56{
 57 return !isDiscreteAnimator();
 58}
 59
 60bool SVGNewAnimationController::hasValidAttributeType() const
 61{
 62 return m_targetElement.isAnimatedAttribute(m_animationElement.attributeName());
 63}
 64
 65bool SVGNewAnimationController::calculateFromAndToValues(const String& from, const String& to)
 66{
 67 if (!createAnimator())
 68 return false;
 69
 70 m_animator->setFromAndToValues(&m_targetElement, from, to);
 71 return true;
 72}
 73
 74bool SVGNewAnimationController::calculateFromAndByValues(const String& from, const String& by)
 75{
 76 if (!createAnimator())
 77 return false;
 78
 79 if (m_animationElement.animationMode() == AnimationMode::By && (!isAdditive() || isDiscreteAnimator()))
 80 return false;
 81
 82 if (m_animationElement.animationMode() == AnimationMode::FromBy && isDiscreteAnimator())
 83 return false;
 84
 85 m_animator->setFromAndByValues(&m_targetElement, from, by);
 86 return true;
 87}
 88
 89bool SVGNewAnimationController::calculateToAtEndOfDurationValue(const String& toAtEndOfDurationString)
 90{
 91 if (!createAnimator())
 92 return false;
 93
 94 if (toAtEndOfDurationString.isEmpty())
 95 return false;
 96
 97 if (isDiscreteAnimator())
 98 return true;
 99
 100 m_animator->setToAtEndOfDurationValue(toAtEndOfDurationString);
 101 return true;
 102}
 103
 104void SVGNewAnimationController::resetAnimatedType()
 105{
 106 if (!createAnimator())
 107 return;
 108 m_animator->start(&m_targetElement);
 109}
 110
 111void SVGNewAnimationController::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGSMILElement*)
 112{
 113 if (!createAnimator())
 114 return;
 115
 116 ASSERT(percentage >= 0 && percentage <= 1);
 117 if (m_targetElement.hasTagName(SVGNames::setTag))
 118 percentage = 1;
 119
 120 if (m_animationElement.calcMode() == CalcMode::Discrete)
 121 percentage = percentage < 0.5 ? 0 : 1;
 122
 123 m_animator->progress(&m_targetElement, percentage, repeatCount);
 124}
 125
 126void SVGNewAnimationController::applyResultsToTarget()
 127{
 128 if (!createAnimator())
 129 return;
 130 m_animator->apply(&m_targetElement);
 131}
 132
 133void SVGNewAnimationController::clearAnimatedType(SVGElement* targetElement)
 134{
 135 if (!m_animator)
 136 return;
 137 m_animator->stop(targetElement);
 138}
 139
 140float SVGNewAnimationController::calculateDistance(const String& from, const String& to)
 141{
 142 // FIXME: A return value of float is not enough to support paced animations on lists.
 143 if (!createAnimator())
 144 return -1;
 145 return m_animator->calculateDistance(&m_targetElement, from, to);
 146}
 147
 148}

Source/WebCore/svg/SVGNewAnimationController.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28#include "SVGAnimationControllerBase.h"
 29
 30namespace WebCore {
 31
 32class SVGAnimationElement;
 33class SVGElement;
 34class SVGSMILElement;
 35
 36class SVGNewAnimationController : public SVGAnimationControllerBase {
 37public:
 38 SVGNewAnimationController(SVGAnimationElement&, SVGElement&);
 39
 40private:
 41 RefPtr<SVGAnimator> createAnimator() const;
 42
 43 void resetAnimatedType() override;
 44 void clearAnimatedType(SVGElement* targetElement) override;
 45
 46 bool calculateFromAndToValues(const String& fromString, const String& toString) override;
 47 bool calculateFromAndByValues(const String& fromString, const String& byString) override;
 48 bool calculateToAtEndOfDurationValue(const String& toAtEndOfDurationString) override;
 49
 50 void calculateAnimatedValue(float percentage, unsigned repeatCount, SVGSMILElement* resultElement) override;
 51
 52 void applyResultsToTarget() override;
 53 float calculateDistance(const String& fromString, const String& toString) override;
 54
 55 bool isAdditive() const override;
 56 bool hasValidAttributeType() const override;
 57
 58 bool isDiscreteAnimator() const;
 59
 60 mutable RefPtr<SVGAnimator> m_animator;
 61};
 62
 63} // namespace WebCore

Source/WebCore/svg/SVGSetElement.cpp

@@WTF_MAKE_ISO_ALLOCATED_IMPL(SVGSetElement);
3131inline SVGSetElement::SVGSetElement(const QualifiedName& tagName, Document& document)
3232 : SVGAnimateElementBase(tagName, document)
3333{
34  setAnimationMode(ToAnimation);
 34 setAnimationMode(AnimationMode::To);
3535 ASSERT(hasTagName(SVGNames::setTag));
3636}
3737

Source/WebCore/svg/animation/SVGSMILElement.cpp

@@void SVGSMILElement::removedFromAncestor(RemovalType removalType, ContainerNode&
309309 SVGElement::removedFromAncestor(removalType, oldParentOfRemovedTree);
310310}
311311
312 bool SVGSMILElement::hasValidAttributeName()
 312bool SVGSMILElement::hasValidAttributeName() const
313313{
314314 return attributeName() != anyQName();
315315}

Source/WebCore/svg/animation/SVGSMILElement.h

@@public:
5151 InsertedIntoAncestorResult insertedIntoAncestor(InsertionType, ContainerNode&) override;
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
5858 SMILTimeContainer* timeContainer() { return m_timeContainer.get(); }

Source/WebCore/svg/properties/SVGAccessor.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28#include "QualifiedName.h"
 29#include "SVGAnimator.h"
 30
 31namespace WebCore {
 32
 33class SVGNewAnimatedProperty;
 34class SVGProperty;
 35
 36template<typename OwnerType>
 37class SVGAccessor {
 38 WTF_MAKE_FAST_ALLOCATED;
 39public:
 40 virtual ~SVGAccessor() = default;
 41
 42 virtual void detach(const OwnerType&) const { }
 43 virtual bool isAnimatedProperty() const { return false; }
 44 virtual bool isAnimatedLength() const { return false; }
 45
 46 virtual bool matches(const OwnerType&, const SVGNewAnimatedProperty&) const { return false; }
 47 virtual Optional<String> synchronize(const OwnerType&) const { return WTF::nullopt; }
 48
 49 virtual RefPtr<SVGAnimator> createAnimator(OwnerType&, const QualifiedName&, AnimationMode, CalcMode, bool, bool) const { return nullptr; }
 50 virtual void appendAnimatedInstance(OwnerType&, const RefPtr<SVGAnimator>&) const { }
 51
 52protected:
 53 SVGAccessor() = default;
 54};
 55
 56} // namespace WebCore

Source/WebCore/svg/properties/SVGAccessorPtr.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28#include "SVGAccessor.h"
 29
 30namespace WebCore {
 31
 32template<typename OwnerType, typename PropertyType>
 33class SVGAccessorPtr : public SVGAccessor<OwnerType> {
 34 using Base = SVGAccessor<OwnerType>;
 35
 36public:
 37 SVGAccessorPtr(Ref<PropertyType> OwnerType::*property)
 38 : m_property(property)
 39 {
 40 }
 41
 42 Ref<PropertyType>& property(OwnerType& owner) const { return owner.*m_property; }
 43 const Ref<PropertyType>& property(const OwnerType& owner) const { return owner.*m_property; }
 44
 45 void detach(const OwnerType& owner) const override
 46 {
 47 property(owner)->detach();
 48 }
 49
 50 Optional<String> synchronize(const OwnerType& owner) const override
 51 {
 52 return property(owner)->synchronize();
 53 }
 54
 55protected:
 56 template<typename AccessorType, Ref<PropertyType> OwnerType::*property>
 57 static const SVGAccessor<OwnerType>& singleton()
 58 {
 59 static NeverDestroyed<AccessorType> propertyAccessor { property };
 60 return propertyAccessor;
 61 }
 62
 63 Ref<PropertyType> OwnerType::*m_property;
 64};
 65
 66}

Source/WebCore/svg/properties/SVGAnimatedPrimitiveProperty.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28#include "SVGNewAnimatedProperty.h"
 29#include "SVGNewProperty.h"
 30
 31namespace WebCore {
 32
 33template<typename PropertyType>
 34class SVGAnimatedPrimitiveProperty : public SVGNewAnimatedProperty {
 35public:
 36 using ValueType = PropertyType;
 37
 38 static Ref<SVGAnimatedPrimitiveProperty> create(SVGElement* contextElement)
 39 {
 40 return adoptRef(*new SVGAnimatedPrimitiveProperty(contextElement));
 41 }
 42
 43 static Ref<SVGAnimatedPrimitiveProperty> create(SVGElement* contextElement, const PropertyType& value)
 44 {
 45 return adoptRef(*new SVGAnimatedPrimitiveProperty(contextElement, value));
 46 }
 47
 48 // Used by the DOM.
 49 ExceptionOr<void> setBaseVal(const PropertyType& baseVal)
 50 {
 51 m_baseVal = baseVal;
 52 commitPropertyChange();
 53 return { };
 54 }
 55
 56 // Used by SVGElement::parseAttribute().
 57 void setBaseValInternal(const PropertyType& baseVal) { m_baseVal = baseVal; }
 58 const PropertyType& baseVal() const { return m_baseVal; }
 59
 60 // Used by SVGAnimator::progress.
 61 void setAnimVal(const PropertyType& animVal)
 62 {
 63 ASSERT(isAnimating());
 64 m_animVal = animVal;
 65 }
 66
 67 const PropertyType& animVal() const
 68 {
 69 ASSERT_IMPLIES(isAnimating(), m_animVal);
 70 return isAnimating() ? *m_animVal : m_baseVal;
 71 }
 72
 73 PropertyType& animVal()
 74 {
 75 ASSERT_IMPLIES(isAnimating(), m_animVal);
 76 return isAnimating() ? *m_animVal : m_baseVal;
 77 }
 78
 79 // Used when committing a change from the SVGAnimatedProperty to the attribute.
 80 String baseValAsString() const override { return SVGPropertyTraits<PropertyType>::toString(m_baseVal); }
 81
 82 // Used to apply the SVGAnimator change to the target element.
 83 String animValAsString() const override
 84 {
 85 ASSERT(isAnimating() && !!m_animVal);
 86 return SVGPropertyTraits<PropertyType>::toString(*m_animVal);
 87 }
 88
 89 // Managing the relationship with the owner.
 90 void setDirty() override { m_state = SVGPropertyState::Dirty; }
 91 bool isDirty() const override { return m_state == SVGPropertyState::Dirty; }
 92 Optional<String> synchronize() override
 93 {
 94 if (m_state == SVGPropertyState::Clean)
 95 return WTF::nullopt;
 96 m_state = SVGPropertyState::Clean;
 97 return baseValAsString();
 98 }
 99
 100 // Used by RenderSVGElements and DumpRenderTree.
 101 const PropertyType& currentValue() const
 102 {
 103 ASSERT_IMPLIES(isAnimating(), m_animVal);
 104 return isAnimating() ? *m_animVal : m_baseVal;
 105 }
 106
 107 // Controlling the animation.
 108 void startAnimation() override
 109 {
 110 if (isAnimating())
 111 return;
 112 m_animVal = m_baseVal;
 113 SVGNewAnimatedProperty::startAnimation();
 114 }
 115 void stopAnimation() override
 116 {
 117 if (!isAnimating())
 118 return;
 119 m_animVal = WTF::nullopt;
 120 SVGNewAnimatedProperty::stopAnimation();
 121 }
 122
 123protected:
 124 SVGAnimatedPrimitiveProperty(SVGElement* contextElement)
 125 : SVGNewAnimatedProperty(contextElement)
 126 , m_baseVal(SVGPropertyTraits<PropertyType>::initialValue())
 127 {
 128 }
 129
 130 SVGAnimatedPrimitiveProperty(SVGElement* contextElement, const PropertyType& value)
 131 : SVGNewAnimatedProperty(contextElement)
 132 , m_baseVal(value)
 133 {
 134 }
 135
 136 PropertyType m_baseVal;
 137 mutable Optional<PropertyType> m_animVal;
 138 SVGPropertyState m_state { SVGPropertyState::Clean };
 139};
 140
 141}

Source/WebCore/svg/properties/SVGAnimatedPropertyAccessor.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28#include "SVGAccessorPtr.h"
 29
 30namespace WebCore {
 31
 32template<typename OwnerType, typename AnimatedPropertyType>
 33class SVGAnimatedPropertyAccessor : public SVGAccessorPtr<OwnerType, AnimatedPropertyType> {
 34 using Base = SVGAccessorPtr<OwnerType, AnimatedPropertyType>;
 35
 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 SVGNewAnimatedProperty& animatedProperty) const override
 43 {
 44 return property(owner).ptr() == &animatedProperty;
 45 }
 46
 47private:
 48 bool isAnimatedProperty() const override { return true; }
 49};
 50
 51}

Source/WebCore/svg/properties/SVGAnimatedPropertyAccessorImpl.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28#include "SVGAnimatedPropertyAccessor.h"
 29#include "SVGAnimatedPropertyAnimatorImpl.h"
 30#include "SVGAnimatedPropertyImpl.h"
 31#include "SVGNames.h"
 32
 33namespace WebCore {
 34
 35template<typename OwnerType>
 36class SVGAnimatedIntegerAccessor final : public SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedInteger> {
 37 using Base = SVGAnimatedPropertyAccessor<OwnerType, SVGAnimatedInteger>;
 38
 39public:
 40 using Base::Base;
 41 using Base::property;
 42 template<Ref<SVGAnimatedInteger> OwnerType::*property>
 43 constexpr static const SVGAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedIntegerAccessor, property>(); }
 44
 45private:
 46 RefPtr<SVGAnimator> 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 }
 50
 51 void appendAnimatedInstance(OwnerType& owner, const RefPtr<SVGAnimator>& animator) const final
 52 {
 53 static_pointer_cast<SVGAnimatedIntegerAnimator>(animator)->appendAnimatedInstance(property(owner));
 54 }
 55};
 56
 57}

Source/WebCore/svg/properties/SVGAnimatedPropertyAnimator.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28#include "SVGAnimator.h"
 29
 30namespace WebCore {
 31
 32class SVGElement;
 33
 34template<typename AnimatedProperty, typename AnimationFunction>
 35class SVGAnimatedPropertyAnimator : public SVGAnimator {
 36public:
 37 using AnimatorAnimatedProperty = AnimatedProperty;
 38
 39 void appendAnimatedInstance(Ref<AnimatedProperty>& animated)
 40 {
 41 m_animatedInstances.append(animated.copyRef());
 42 }
 43
 44 bool isDiscrete() const override { return m_function.isDiscrete(); }
 45
 46 void setFromAndToValues(SVGElement* targetElement, const String& from, const String& to) override
 47 {
 48 m_function.setFromAndToValues(targetElement, from, to);
 49 }
 50
 51 void setFromAndByValues(SVGElement* targetElement, const String& from, const String& by) override
 52 {
 53 m_function.setFromAndByValues(targetElement, from, by);
 54 }
 55
 56 void setToAtEndOfDurationValue(const String& toAtEndOfDuration) override
 57 {
 58 m_function.setToAtEndOfDurationValue(toAtEndOfDuration);
 59 }
 60
 61 void start(SVGElement*) override
 62 {
 63 m_animated->startAnimation();
 64 for (auto& instance : m_animatedInstances)
 65 instance->instanceStartAnimation(m_animated);
 66 }
 67
 68 void apply(SVGElement* targetElement) override
 69 {
 70 applyAnimatedPropertyChange(targetElement);
 71 }
 72
 73 void stop(SVGElement* targetElement) override
 74 {
 75 if (!m_animated->isAnimating())
 76 return;
 77
 78 m_animated->stopAnimation();
 79 for (auto& instance : m_animatedInstances)
 80 instance->instanceStopAnimation();
 81
 82 applyAnimatedPropertyChange(targetElement);
 83 }
 84
 85 float calculateDistance(SVGElement* targetElement, const String& from, const String& to) const override
 86 {
 87 return m_function.calculateDistance(targetElement, from, to);
 88 }
 89
 90protected:
 91 template<typename... Arguments>
 92 SVGAnimatedPropertyAnimator(const QualifiedName& attributeName, Ref<AnimatedProperty>& animated, Arguments&&... arguments)
 93 : SVGAnimator(attributeName)
 94 , m_animated(animated.copyRef())
 95 , m_function(std::forward<Arguments>(arguments)...)
 96 {
 97 }
 98
 99 Ref<AnimatedProperty> m_animated;
 100 Vector<Ref<AnimatedProperty>> m_animatedInstances;
 101 AnimationFunction m_function;
 102};
 103
 104}

Source/WebCore/svg/properties/SVGAnimatedPropertyAnimatorImpl.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28#include "SVGAnimatedPropertyAnimator.h"
 29#include "SVGAnimatedPropertyImpl.h"
 30#include "SVGAnimationAdditiveValueFunctionImpl.h"
 31
 32namespace WebCore {
 33
 34class SVGAnimatedIntegerPairAnimator;
 35
 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
 45public:
 46 static auto create(const QualifiedName& attributeName, Ref<SVGAnimatedInteger>& animated, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive)
 47 {
 48 return adoptRef(*new SVGAnimatedIntegerAnimator(attributeName, animated, animationMode, calcMode, isAccumulated, isAdditive));
 49 }
 50
 51private:
 52 void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) final
 53 {
 54 m_function.progress(targetElement, percentage, repeatCount, m_animated->animVal());
 55 }
 56};
 57
 58}

Source/WebCore/svg/properties/SVGAnimatedPropertyImpl.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 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"
 41
 42namespace WebCore {
 43
 44using SVGAnimatedInteger = SVGAnimatedPrimitiveProperty<int>;
 45
 46}

Source/WebCore/svg/properties/SVGAnimatedPropertyPairAccessor.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28#include "SVGAccessor.h"
 29
 30namespace WebCore {
 31
 32template<typename OwnerType, typename AccessorType1, typename AccessorType2>
 33class SVGAnimatedPropertyPairAccessor : public SVGAccessor<OwnerType> {
 34 using AnimatedPropertyType1 = typename AccessorType1::AnimatedProperty;
 35 using AnimatedPropertyType2 = typename AccessorType2::AnimatedProperty;
 36 using Base = SVGAccessor<OwnerType>;
 37
 38public:
 39 SVGAnimatedPropertyPairAccessor(Ref<AnimatedPropertyType1> OwnerType::*property1, Ref<AnimatedPropertyType2> OwnerType::*property2)
 40 : m_accessor1(property1)
 41 , m_accessor2(property2)
 42 {
 43 }
 44
 45protected:
 46 template<typename AccessorType, Ref<AnimatedPropertyType1> OwnerType::*property1, Ref<AnimatedPropertyType2> OwnerType::*property2>
 47 static SVGAccessor<OwnerType>& singleton()
 48 {
 49 static NeverDestroyed<AccessorType> propertyAccessor { property1, property2 };
 50 return propertyAccessor;
 51 }
 52
 53 bool isAnimatedProperty() const override { return true; }
 54
 55 Ref<AnimatedPropertyType1>& property1(OwnerType& owner) const { return m_accessor1.property(owner); }
 56 const Ref<AnimatedPropertyType1>& property1(const OwnerType& owner) const { return m_accessor1.property(owner); }
 57
 58 Ref<AnimatedPropertyType2>& property2(OwnerType& owner) const { return m_accessor2.property(owner); }
 59 const Ref<AnimatedPropertyType2>& property2(const OwnerType& owner) const { return m_accessor2.property(owner); }
 60
 61 bool matches(const OwnerType& owner, const SVGNewAnimatedProperty& animatedProperty) const override
 62 {
 63 return m_accessor1.matches(owner, animatedProperty) || m_accessor2.matches(owner, animatedProperty);
 64 }
 65
 66 AccessorType1 m_accessor1;
 67 AccessorType2 m_accessor2;
 68};
 69
 70}

Source/WebCore/svg/properties/SVGAnimatedPropertyPairAccessorImpl.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28#include "SVGAnimatedPropertyAccessorImpl.h"
 29#include "SVGAnimatedPropertyAnimatorImpl.h"
 30#include "SVGAnimatedPropertyImpl.h"
 31#include "SVGAnimatedPropertyPairAccessor.h"
 32#include "SVGAnimatedPropertyPairAnimatorImpl.h"
 33#include "SVGNames.h"
 34
 35namespace WebCore {
 36
 37template<typename OwnerType>
 38class SVGAnimatedIntegerPairAccessor final : public SVGAnimatedPropertyPairAccessor<OwnerType, SVGAnimatedIntegerAccessor<OwnerType>, SVGAnimatedIntegerAccessor<OwnerType>> {
 39 using Base = SVGAnimatedPropertyPairAccessor<OwnerType, SVGAnimatedIntegerAccessor<OwnerType>, SVGAnimatedIntegerAccessor<OwnerType>>;
 40 using Base::property1;
 41 using Base::property2;
 42
 43public:
 44 using Base::Base;
 45 template<Ref<SVGAnimatedInteger> OwnerType::*property1, Ref<SVGAnimatedInteger> OwnerType::*property2>
 46 constexpr static const SVGAccessor<OwnerType>& singleton() { return Base::template singleton<SVGAnimatedIntegerPairAccessor, property1, property2>(); }
 47
 48private:
 49 Optional<String> synchronize(const OwnerType& owner) const final
 50 {
 51 bool dirty1 = property1(owner)->isDirty();
 52 bool dirty2 = property2(owner)->isDirty();
 53 if (!(dirty1 || dirty2))
 54 return WTF::nullopt;
 55
 56 String string1 = dirty1 ? *property1(owner)->synchronize() : property1(owner)->baseValAsString();
 57 String string2 = dirty2 ? *property2(owner)->synchronize() : property2(owner)->baseValAsString();
 58 return string1 == string2 ? string1 : string1 + ", " + string2;
 59 }
 60
 61 RefPtr<SVGAnimator> createAnimator(OwnerType& owner, const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) const final
 62 {
 63 return SVGAnimatedIntegerPairAnimator::create(attributeName, property1(owner), property2(owner), animationMode, calcMode, isAccumulated, isAdditive);
 64 }
 65
 66 void appendAnimatedInstance(OwnerType& owner, const RefPtr<SVGAnimator>& animator) const final
 67 {
 68 static_pointer_cast<SVGAnimatedIntegerPairAnimator>(animator)->appendAnimatedInstance(property1(owner), property2(owner));
 69 }
 70};
 71
 72}

Source/WebCore/svg/properties/SVGAnimatedPropertyPairAnimator.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28#include "SVGAnimator.h"
 29
 30namespace WebCore {
 31
 32class SVGElement;
 33
 34template<typename AnimatedPropertyAnimator1, typename AnimatedPropertyAnimator2>
 35class SVGAnimatedPropertyPairAnimator : public SVGAnimator {
 36public:
 37 using AnimatedProperty1 = typename AnimatedPropertyAnimator1::AnimatorAnimatedProperty;
 38 using AnimatedProperty2 = typename AnimatedPropertyAnimator2::AnimatorAnimatedProperty;
 39
 40 void appendAnimatedInstance(Ref<AnimatedProperty1>& animated1, Ref<AnimatedProperty2>& animated2)
 41 {
 42 m_animatedPropertyAnimator1->appendAnimatedInstance(animated1);
 43 m_animatedPropertyAnimator2->appendAnimatedInstance(animated2);
 44 }
 45
 46protected:
 47 SVGAnimatedPropertyPairAnimator(const QualifiedName& attributeName, Ref<AnimatedProperty1>& animated1, Ref<AnimatedProperty2>& animated2, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive)
 48 : SVGAnimator(attributeName)
 49 , m_animatedPropertyAnimator1(AnimatedPropertyAnimator1::create(attributeName, animated1, animationMode, calcMode, isAccumulated, isAdditive))
 50 , m_animatedPropertyAnimator2(AnimatedPropertyAnimator2::create(attributeName, animated2, animationMode, calcMode, isAccumulated, isAdditive))
 51 {
 52 }
 53
 54 void start(SVGElement* targetElement) override
 55 {
 56 m_animatedPropertyAnimator1->start(targetElement);
 57 m_animatedPropertyAnimator2->start(targetElement);
 58 }
 59
 60 void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) override
 61 {
 62 m_animatedPropertyAnimator1->progress(targetElement, percentage, repeatCount);
 63 m_animatedPropertyAnimator2->progress(targetElement, percentage, repeatCount);
 64 }
 65
 66 void apply(SVGElement* targetElement) override
 67 {
 68 applyAnimatedPropertyChange(targetElement);
 69 }
 70
 71 void stop(SVGElement* targetElement) override
 72 {
 73 m_animatedPropertyAnimator1->stop(targetElement);
 74 m_animatedPropertyAnimator2->stop(targetElement);
 75 }
 76
 77 Ref<AnimatedPropertyAnimator1> m_animatedPropertyAnimator1;
 78 Ref<AnimatedPropertyAnimator2> m_animatedPropertyAnimator2;
 79};
 80
 81}

Source/WebCore/svg/properties/SVGAnimatedPropertyPairAnimatorImpl.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28#include "SVGAnimatedPropertyImpl.h"
 29#include "SVGAnimatedPropertyPairAnimator.h"
 30#include "SVGMarkerTypes.h"
 31
 32namespace WebCore {
 33
 34class SVGElement;
 35
 36class SVGAnimatedIntegerPairAnimator final : public SVGAnimatedPropertyPairAnimator<SVGAnimatedIntegerAnimator, SVGAnimatedIntegerAnimator> {
 37 using Base = SVGAnimatedPropertyPairAnimator<SVGAnimatedIntegerAnimator, SVGAnimatedIntegerAnimator>;
 38 using Base::Base;
 39
 40public:
 41 static auto create(const QualifiedName& attributeName, Ref<SVGAnimatedInteger>& animated1, Ref<SVGAnimatedInteger>& animated2, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive)
 42 {
 43 return adoptRef(*new SVGAnimatedIntegerPairAnimator(attributeName, animated1, animated2, animationMode, calcMode, isAccumulated, isAdditive));
 44 }
 45
 46private:
 47 void setFromAndToValues(SVGElement*, const String& from, const String& to) final
 48 {
 49 auto pairFrom = SVGPropertyTraits<std::pair<int, int>>::fromString(from);
 50 auto pairTo = SVGPropertyTraits<std::pair<int, int>>::fromString(to);
 51
 52 m_animatedPropertyAnimator1->m_function.m_from = pairFrom.first;
 53 m_animatedPropertyAnimator1->m_function.m_to = pairTo.first;
 54
 55 m_animatedPropertyAnimator2->m_function.m_from = pairFrom.second;
 56 m_animatedPropertyAnimator2->m_function.m_to = pairTo.second;
 57 }
 58
 59 void setFromAndByValues(SVGElement*, const String& from, const String& by) final
 60 {
 61 auto pairFrom = SVGPropertyTraits<std::pair<int, int>>::fromString(from);
 62 auto pairBy = SVGPropertyTraits<std::pair<int, int>>::fromString(by);
 63
 64 m_animatedPropertyAnimator1->m_function.m_from = pairFrom.first;
 65 m_animatedPropertyAnimator1->m_function.m_to = pairFrom.first + pairBy.first;
 66
 67 m_animatedPropertyAnimator2->m_function.m_from = pairFrom.second;
 68 m_animatedPropertyAnimator2->m_function.m_to = pairFrom.second + pairBy.second;
 69 }
 70
 71 void setToAtEndOfDurationValue(const String& toAtEndOfDuration) final
 72 {
 73 auto pairToAtEndOfDuration = SVGPropertyTraits<std::pair<int, int>>::fromString(toAtEndOfDuration);
 74 m_animatedPropertyAnimator1->m_function.m_toAtEndOfDuration = pairToAtEndOfDuration.first;
 75 m_animatedPropertyAnimator2->m_function.m_toAtEndOfDuration = pairToAtEndOfDuration.second;
 76 }
 77};
 78
 79}

Source/WebCore/svg/properties/SVGAnimationAdditiveFunction.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28#include "SVGAnimationFunction.h"
 29
 30namespace WebCore {
 31
 32class SVGAnimationAdditiveFunction : public SVGAnimationFunction {
 33public:
 34 SVGAnimationAdditiveFunction(AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive)
 35 : SVGAnimationFunction(animationMode)
 36 , m_calcMode(calcMode)
 37 , m_isAccumulated(isAccumulated)
 38 , m_isAdditive(isAdditive)
 39 {
 40 }
 41
 42 void setFromAndByValues(SVGElement* targetElement, const String& from, const String& by) override
 43 {
 44 setFromAndToValues(targetElement, from, by);
 45 addFromAndToValues(targetElement);
 46 }
 47
 48 void setToAtEndOfDurationValue(const String&) override
 49 {
 50 ASSERT_NOT_REACHED();
 51 }
 52
 53protected:
 54 float progress(float percentage, unsigned repeatCount, float from, float to, float toAtEndOfDuration, float animated)
 55 {
 56 float number;
 57 if (m_calcMode == CalcMode::Discrete)
 58 number = percentage < 0.5 ? from : to;
 59 else
 60 number = (to - from) * percentage + from;
 61
 62 if (m_isAccumulated && repeatCount)
 63 number += toAtEndOfDuration * repeatCount;
 64
 65 if (m_isAdditive && m_animationMode != AnimationMode::To)
 66 number += animated;
 67
 68 return number;
 69 }
 70
 71 CalcMode m_calcMode;
 72 bool m_isAccumulated;
 73 bool m_isAdditive;
 74};
 75
 76}

Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunction.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28#include "SVGAnimationAdditiveFunction.h"
 29
 30namespace WebCore {
 31
 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; }
 39
 40 ValueType m_from;
 41 ValueType m_to;
 42 Optional<ValueType> m_toAtEndOfDuration;
 43};
 44
 45}

Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunctionImpl.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28#include "SVGAnimationAdditiveValueFunction.h"
 29#include "SVGPropertyTraits.h"
 30
 31namespace WebCore {
 32
 33class SVGAnimationIntegerFunction : public SVGAnimationAdditiveValueFunction<int> {
 34 friend class SVGAnimatedIntegerPairAnimator;
 35
 36public:
 37 using Base = SVGAnimationAdditiveValueFunction<int>;
 38 using Base::Base;
 39
 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 }
 45
 46 void setToAtEndOfDurationValue(const String& toAtEndOfDuration) override
 47 {
 48 m_toAtEndOfDuration = SVGPropertyTraits<int>::fromString(toAtEndOfDuration);
 49 }
 50
 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 }
 55
 56 float calculateDistance(SVGElement*, const String& from, const String& to) const override
 57 {
 58 return std::abs(to.toIntStrict() - from.toIntStrict());
 59 }
 60
 61private:
 62 void addFromAndToValues(SVGElement*) override
 63 {
 64 m_to += m_from;
 65 }
 66};
 67
 68}

Source/WebCore/svg/properties/SVGAnimationFunction.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28namespace WebCore {
 29
 30class SVGAnimationFunction {
 31public:
 32 virtual ~SVGAnimationFunction() = default;
 33
 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};
 51
 52}

Source/WebCore/svg/properties/SVGAnimator.cpp

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#include "config.h"
 27#include "SVGAnimator.h"
 28
 29#include "CSSComputedStyleDeclaration.h"
 30#include "CSSPropertyParser.h"
 31#include "SVGElement.h"
 32
 33namespace WebCore {
 34
 35void SVGAnimator::applyAnimatedPropertyChange(SVGElement* element, const QualifiedName& attributeName)
 36{
 37 ASSERT(!element->m_deletionHasBegun);
 38 element->svgAttributeChanged(attributeName);
 39}
 40
 41void SVGAnimator::applyAnimatedPropertyChange(SVGElement* targetElement)
 42{
 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);
 56}
 57
 58}

Source/WebCore/svg/properties/SVGAnimator.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28#include "CSSPropertyNames.h"
 29#include "QualifiedName.h"
 30#include <wtf/RefCounted.h>
 31#include <wtf/StdLibExtras.h>
 32
 33namespace WebCore {
 34
 35class SVGElement;
 36
 37enum class AnimationMode : uint8_t { None, FromTo, FromBy, To, By, Values, Path };
 38enum class CalcMode : uint8_t { Discrete, Linear, Paced, Spline };
 39
 40class SVGAnimator : public RefCounted<SVGAnimator> {
 41public:
 42 SVGAnimator(const QualifiedName& attributeName)
 43 : m_attributeName(attributeName)
 44 {
 45 }
 46
 47 virtual ~SVGAnimator() = default;
 48
 49 virtual bool isDiscrete() const { return false; }
 50
 51 virtual void setFromAndToValues(SVGElement*, const String&, const String&) { }
 52 virtual void setFromAndByValues(SVGElement*, const String&, const String&) { }
 53 virtual void setToAtEndOfDurationValue(const String&) { }
 54
 55 virtual void start(SVGElement*) = 0;
 56 virtual void progress(SVGElement*, float, unsigned) = 0;
 57 virtual void apply(SVGElement*) = 0;
 58 virtual void stop(SVGElement* targetElement) = 0;
 59
 60 virtual float calculateDistance(SVGElement*, const String&, const String&) const { return -1; }
 61 virtual RefPtr<SVGAnimator> createSibling(AnimationMode, CalcMode, bool, bool) { return nullptr; }
 62
 63protected:
 64 static void applyAnimatedPropertyChange(SVGElement*, const QualifiedName&);
 65
 66 void applyAnimatedPropertyChange(SVGElement*);
 67
 68 const QualifiedName& m_attributeName;
 69};
 70
 71}

Source/WebCore/svg/properties/SVGAttributeOwnerProxy.cpp

2626#include "config.h"
2727#include "SVGAttributeOwnerProxy.h"
2828
 29#include "SVGElement.h"
 30
2931namespace WebCore {
3032
3133SVGAttributeOwnerProxy::SVGAttributeOwnerProxy(SVGElement& element)

Source/WebCore/svg/properties/SVGAttributeOwnerProxy.h

2525
2626#pragma once
2727
 28#include "QualifiedName.h"
2829#include "SVGAnimatedPropertyType.h"
2930#include <wtf/WeakPtr.h>
3031

Source/WebCore/svg/properties/SVGAttributeRegistry.h

2727
2828#include "SVGAnimatedBoolean.h"
2929#include "SVGAnimatedEnumeration.h"
30 #include "SVGAnimatedInteger.h"
3130#include "SVGAnimatedLength.h"
3231#include "SVGAnimatedLengthList.h"
3332#include "SVGAnimatedNumber.h"

@@public:
8079 registerAttribute(SVGAnimatedEnumerationAttributeAccessor<OwnerType, EnumType>::template singleton<attributeName, attribute>());
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()
9984 {

Source/WebCore/svg/properties/SVGNewAnimatedProperty.cpp

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#include "config.h"
 27#include "SVGNewAnimatedProperty.h"
 28
 29#include "SVGElement.h"
 30
 31namespace WebCore {
 32
 33SVGPropertyOwner* SVGNewAnimatedProperty::owner() const
 34{
 35 // Casting from SVGElement to SVGPropertyOwner requires SVGElement.h.
 36 return m_contextElement;
 37}
 38
 39void SVGNewAnimatedProperty::commitPropertyChange()
 40{
 41 if (!m_contextElement)
 42 return;
 43 m_contextElement->commitPropertyChange(this);
 44}
 45
 46}

Source/WebCore/svg/properties/SVGNewAnimatedProperty.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28#include "SVGPropertyOwner.h"
 29
 30namespace WebCore {
 31
 32class SVGNewAnimatedProperty : public RefCounted<SVGNewAnimatedProperty>, public SVGPropertyOwner {
 33public:
 34 virtual ~SVGNewAnimatedProperty() = default;
 35
 36 // Manage the relationship with the owner.
 37 bool isAttached() const { return m_contextElement; }
 38 void detach() { m_contextElement = nullptr; }
 39 SVGElement* contextElement() const { return m_contextElement; }
 40
 41 virtual String baseValAsString() const { return emptyString(); }
 42 virtual String animValAsString() const { return emptyString(); }
 43
 44 // Control the synchronization between the attribute and its reflection in baseVal.
 45 virtual bool isDirty() const { return false; }
 46 virtual void setDirty() { }
 47 virtual Optional<String> synchronize() { return WTF::nullopt; }
 48
 49 // Control the animation life cycle.
 50 bool isAnimating() const { return m_isAnimating; }
 51 virtual void startAnimation() { m_isAnimating = true; }
 52 virtual void stopAnimation() { m_isAnimating = false; }
 53
 54 // Attach/Detach the animVal of the traget element's property by the instance element's property.
 55 virtual void instanceStartAnimation(SVGNewAnimatedProperty&) { m_isAnimating = true; }
 56 virtual void instanceStopAnimation() { m_isAnimating = false; }
 57
 58protected:
 59 SVGNewAnimatedProperty(SVGElement* contextElement)
 60 : m_contextElement(contextElement)
 61 {
 62 }
 63
 64 SVGPropertyOwner* owner() const override;
 65 void commitPropertyChange() override;
 66
 67 SVGElement* m_contextElement { nullptr };
 68 bool m_isAnimating { false };
 69};
 70
 71} // namespace WebCore
 72

Source/WebCore/svg/properties/SVGNewProperty.h

 1/*
 2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
 3 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 4 *
 5 * This library is free software; you can redistribute it and/or
 6 * modify it under the terms of the GNU Library General Public
 7 * License as published by the Free Software Foundation; either
 8 * version 2 of the License, or (at your option) any later version.
 9 *
 10 * This library is distributed in the hope that it will be useful,
 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 13 * Library General Public License for more details.
 14 *
 15 * You should have received a copy of the GNU Library General Public License
 16 * along with this library; see the file COPYING.LIB. If not, write to
 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 18 * Boston, MA 02110-1301, USA.
 19 */
 20
 21#pragma once
 22
 23namespace WebCore {
 24
 25enum class SVGPropertyAccess : uint8_t { ReadWrite, ReadOnly };
 26enum class SVGPropertyState : uint8_t { Clean, Dirty };
 27
 28} // namespace WebCore
 29

Source/WebCore/svg/properties/SVGPropertyOwner.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28namespace WebCore {
 29
 30class SVGPropertyOwner {
 31public:
 32 virtual ~SVGPropertyOwner() = default;
 33
 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};
 53
 54}

Source/WebCore/svg/properties/SVGPropertyOwnerRegistry.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28#include "SVGAnimatedPropertyAccessorImpl.h"
 29#include "SVGAnimatedPropertyPairAccessorImpl.h"
 30#include "SVGPropertyRegistry.h"
 31#include <wtf/HashMap.h>
 32
 33namespace WebCore {
 34
 35class SVGAnimator;
 36
 37template<typename OwnerType, typename... BaseTypes>
 38class SVGPropertyOwnerRegistry : public SVGPropertyRegistry {
 39public:
 40 SVGPropertyOwnerRegistry(OwnerType& owner)
 41 : m_owner(owner)
 42 {
 43 }
 44
 45 template<const LazyNeverDestroyed<const QualifiedName>& attributeName, Ref<SVGAnimatedInteger> OwnerType::*property>
 46 static void registerProperty()
 47 {
 48 registerProperty(attributeName, SVGAnimatedIntegerAccessor<OwnerType>::template singleton<property>());
 49 }
 50
 51 template<const LazyNeverDestroyed<const QualifiedName>& attributeName, Ref<SVGAnimatedInteger> OwnerType::*property1, Ref<SVGAnimatedInteger> OwnerType::*property2>
 52 static void registerProperty()
 53 {
 54 registerProperty(attributeName, SVGAnimatedIntegerPairAccessor<OwnerType>::template singleton<property1, property2>());
 55 }
 56 // Enumrate all the SVGAccessors recursively. The functor will be called and will
 57 // be given the pair<QualifiedName, SVGAccessor> till the functor returns false.
 58 template<typename Functor>
 59 static bool enumerateRecursively(const Functor& functor)
 60 {
 61 for (const auto& entry : attributeNameToAccessorMap()) {
 62 if (!functor(entry))
 63 return false;
 64 }
 65 return enumerateRecursivelyBaseTypes(functor);
 66 }
 67
 68 // Returns true if OwnerType owns a property whose name is attributeName.
 69 static bool isKnownAttribute(const QualifiedName& attributeName)
 70 {
 71 return findAccessor(attributeName);
 72 }
 73
 74 QualifiedName animatedPropertyAttributeName(const SVGNewAnimatedProperty& animatedProperty) const override
 75 {
 76 QualifiedName attributeName = nullQName();
 77 enumerateRecursively([&](const auto& entry) -> bool {
 78 if (!entry.value->matches(m_owner, animatedProperty))
 79 return true;
 80 attributeName = entry.key;
 81 return false;
 82 });
 83 return attributeName;
 84 }
 85
 86 // Detach all the properties recursively from their OwnerTypes.
 87 void detachAllProperties() const override
 88 {
 89 enumerateRecursively([&](const auto& entry) -> bool {
 90 entry.value->detach(m_owner);
 91 return true;
 92 });
 93 }
 94
 95 // Finds the property whose name is attributeName and returns the synchronize
 96 // string through the associated SVGAccessor.
 97 Optional<String> synchronize(const QualifiedName& attributeName) const override
 98 {
 99 Optional<String> value;
 100 enumerateRecursively([&](const auto& entry) -> bool {
 101 if (!entry.key.matches(attributeName))
 102 return true;
 103 value = entry.value->synchronize(m_owner);
 104 return false;
 105 });
 106 return value;
 107 }
 108
 109 // Enumerate recursively the SVGAccessors of the OwnerType and all its BaseTypes.
 110 // Collect all the pairs <AttributeName, String> only for the dirty properties.
 111 HashMap<QualifiedName, String> synchronizeAllAttributes() const override
 112 {
 113 HashMap<QualifiedName, String> map;
 114 enumerateRecursively([&](const auto& entry) -> bool {
 115 if (auto string = entry.value->synchronize(m_owner))
 116 map.add(entry.key, *string);
 117 return true;
 118 });
 119 return map;
 120 }
 121
 122 // This is a virtual function because SVGElement will access it through the base class.
 123 bool isAnimatedPropertyAttribute(const QualifiedName& attributeName) const override
 124 {
 125 bool isAnimatedPropertyAttribute = false;
 126 enumerateRecursively([&attributeName, &isAnimatedPropertyAttribute](const auto& entry) -> bool {
 127 if (!entry.key.matches(attributeName))
 128 return true;
 129 isAnimatedPropertyAttribute = entry.value->isAnimatedProperty();
 130 return false;
 131 });
 132 return isAnimatedPropertyAttribute;
 133 }
 134
 135 // Creates an SVGAnimator for a given attributeName.
 136 RefPtr<SVGAnimator> createAnimator(const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) const override
 137 {
 138 RefPtr<SVGAnimator> animator;
 139 enumerateRecursively([&](const auto& entry) -> bool {
 140 if (!entry.key.matches(attributeName))
 141 return true;
 142 animator = entry.value->createAnimator(m_owner, attributeName, animationMode, calcMode, isAccumulated, isAdditive);
 143 return false;
 144 });
 145 return animator;
 146 }
 147
 148 void appendAnimatedInstance(const QualifiedName& attributeName, RefPtr<SVGAnimator>& animator) const override
 149 {
 150 enumerateRecursively([&](const auto& entry) -> bool {
 151 if (!entry.key.matches(attributeName))
 152 return true;
 153 entry.value->appendAnimatedInstance(m_owner, animator);
 154 return false;
 155 });
 156 }
 157
 158private:
 159 // Singleton map for every OwnerType.
 160 static HashMap<QualifiedName, const SVGAccessor<OwnerType>*>& attributeNameToAccessorMap()
 161 {
 162 static NeverDestroyed<HashMap<QualifiedName, const SVGAccessor<OwnerType>*>> attributeNameToAccessorMap;
 163 return attributeNameToAccessorMap;
 164 }
 165
 166 static void registerProperty(const QualifiedName& attributeName, const SVGAccessor<OwnerType>& propertyAccessor)
 167 {
 168 attributeNameToAccessorMap().add(attributeName, &propertyAccessor);
 169 }
 170
 171 // This is a template function with parameter 'I' whose default value = 0. So you can call it without any parameter
 172 // from enumerateRecursively(). It returns true and is enable_if<I == sizeof...(BaseTypes)>. So it is mainly for
 173 // breaking the recursion.
 174 template<typename Functor, size_t I = 0>
 175 static typename std::enable_if<I == sizeof...(BaseTypes), bool>::type enumerateRecursivelyBaseTypes(const Functor&) { return true; }
 176
 177 // This version of animatedTypesBaseTypes() is enable_if<I < sizeof...(BaseTypes)>.
 178 template<typename Functor, size_t I = 0>
 179 static typename std::enable_if<I < sizeof...(BaseTypes), bool>::type enumerateRecursivelyBaseTypes(const Functor& functor)
 180 {
 181 // Get the base type at index 'I' using std::tuple and std::tuple_element.
 182 using BaseType = typename std::tuple_element<I, typename std::tuple<BaseTypes...>>::type;
 183 if (!BaseType::PropertyRegistry::enumerateRecursively(functor))
 184 return false;
 185 // BaseType does not want to break the recursion. So recurse to the next BaseType.
 186 return enumerateRecursivelyBaseTypes<Functor, I + 1>(functor);
 187 }
 188
 189 static const SVGAccessor<OwnerType>* findAccessor(const QualifiedName& attributeName)
 190 {
 191 // Here we need to loop through the entries in the map and use matches() to compare them with attributeName.
 192 // m_map.contains() uses QualifiedName::operator==() which compares the impl pointers only while matches()
 193 // compares the contents if the impl pointers differ.
 194 auto it = std::find_if(attributeNameToAccessorMap().begin(), attributeNameToAccessorMap().end(), [&attributeName](const auto& entry) -> bool {
 195 return entry.key.matches(attributeName);
 196 });
 197 return it != attributeNameToAccessorMap().end() ? it->value : nullptr;
 198 }
 199
 200 OwnerType& m_owner;
 201};
 202
 203}

Source/WebCore/svg/properties/SVGPropertyRegistry.h

 1/*
 2 * Copyright (C) 2018-2019 Apple Inc. All rights reserved.
 3 *
 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.
 12 *
 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.
 24 */
 25
 26#pragma once
 27
 28#include "SVGAnimator.h"
 29
 30namespace WebCore {
 31
 32class SVGNewAnimatedProperty;
 33
 34class SVGPropertyRegistry {
 35public:
 36 SVGPropertyRegistry() = default;
 37 virtual ~SVGPropertyRegistry() = default;
 38
 39 virtual void detachAllProperties() const = 0;
 40 virtual QualifiedName animatedPropertyAttributeName(const SVGNewAnimatedProperty&) 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 RefPtr<SVGAnimator> createAnimator(const QualifiedName&, AnimationMode, CalcMode, bool isAccumulated, bool isAdditive) const = 0;
 46 virtual void appendAnimatedInstance(const QualifiedName& attributeName, RefPtr<SVGAnimator>&) const = 0;
 47};
 48
 49}