WebKit Bugzilla
Attachment 356579 Details for
Bug 191237
: Remove SVG properties tear-off objects
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
8-SVGAnimator.patch
8-SVGAnimator.patch (text/plain), 91.91 KB, created by
Said Abou-Hallawa
on 2018-12-04 21:09:27 PST
(
hide
)
Description:
8-SVGAnimator.patch
Filename:
MIME Type:
Creator:
Said Abou-Hallawa
Created:
2018-12-04 21:09:27 PST
Size:
91.91 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index c3e491fcb50..3ae262bd3f7 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,99 @@ >+2018-12-04 Said Abou-Hallawa <sabouhallawa@apple.com> >+ >+ Remove SVG properties tear-off objects >+ https://bugs.webkit.org/show_bug.cgi?id=191237 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ The SVGAnimator acts like a bridge between the SVGAnimatedPropty or the >+ SVG style property in one side and the SVGAnimationFunction in the other >+ side. >+ >+ -- SVGAnimator is the base of: >+ >+ %% SVGAnimatedPropertyAnimator which animates a single SVGAnimatedProperty, >+ e.g. the 'x' attribute of SVGRectElement. >+ >+ %% SVGAnimatedPropertyPairAnimator which animates a pair of >+ SVGAnimatedProperties, e.g. the 'orient' attribute of SVGMarkerElement. >+ >+ %% SVGPropertyAnimator which animates an SVG style property, e.g. >+ the 'fill' attribute of SVGRectElement. >+ >+ -- Who creates the SVGAnimator? >+ >+ %% SVGAnimatedPropertyAnimator and SVGAnimatedPropertyPairAnimator are >+ created by the SVGAccessor because the SVGAccessor knows what type >+ animator to create for its property. It also has access to the >+ SVGAnimatedProperty(s) given the owner object. >+ >+ %% SVGPropertyAnimator will be created by SVGPropertyAnimatorCreator. >+ >+ -- Multiple animators to the same style property and animated property: >+ >+ %% Because all the SVGAnimatedProperties are RefCounted pointers, >+ having multiple animators for the same attribute should work as >+ expected because all the animators will have access to the same >+ SVGAnimatedProperty. >+ >+ %% For SVGPropertyAnimator, a RefCounted of the PropertyType will be >+ created and initialized with the attribute value. Having multiple >+ animators for the same SVG style property will work as expected if >+ they all have access to the same PropertyType. Creating a new >+ RefCounted of the PropertyType or passing an existing one will be >+ managed by SVGPropertyAnimatorCreator. >+ >+ * Sources.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ * svg/properties/SVGAnimatedPropertyAnimator.h: Added. >+ (WebCore::SVGAnimatedPropertyAnimator::appendAnimatedInstance): >+ (WebCore::SVGAnimatedPropertyAnimator::SVGAnimatedPropertyAnimator): >+ * svg/properties/SVGAnimatedPropertyAnimatorImpl.h: Added. >+ * svg/properties/SVGAnimatedPropertyPairAnimator.h: Added. >+ (WebCore::SVGAnimatedPropertyPairAnimator::appendAnimatedInstance): >+ (WebCore::SVGAnimatedPropertyPairAnimator::SVGAnimatedPropertyPairAnimator): >+ * svg/properties/SVGAnimatedPropertyPairAnimatorImpl.h: Added. >+ * svg/properties/SVGAnimator.cpp: Added. >+ (WebCore::SVGAnimator::isAnimatedStylePropertyAniamtor const): >+ (WebCore::SVGAnimator::applyAnimatedStylePropertyChange): >+ (WebCore::SVGAnimator::removeAnimatedStyleProperty): >+ (WebCore::SVGAnimator::applyAnimatedPropertyChange): >+ * svg/properties/SVGAnimator.h: Added. >+ (WebCore::SVGAnimator::SVGAnimator): >+ (WebCore::SVGAnimator::isDiscrete const): >+ (WebCore::SVGAnimator::setFromAndToValues): >+ (WebCore::SVGAnimator::setFromAndByValues): >+ (WebCore::SVGAnimator::setToAtEndOfDurationValue): >+ (WebCore::SVGAnimator::calculateDistance const): >+ (WebCore::SVGAnimator::createSibling): >+ * svg/properties/SVGPrimitivePropertyAnimator.h: Added. >+ (WebCore::SVGPrimitivePropertyAnimator::SVGPrimitivePropertyAnimator): >+ * svg/properties/SVGPrimitivePropertyAnimatorImpl.h: Added. >+ (WebCore::SVGNumberAnimator::create): >+ (WebCore::SVGRectAnimator::create): >+ (WebCore::SVGStringAnimator::create): >+ * svg/properties/SVGPropertyAnimator.h: Added. >+ (WebCore::SVGPropertyAnimator::SVGPropertyAnimator): >+ (WebCore::SVGPropertyAnimator::adjustForInheritance const): >+ (WebCore::SVGPropertyAnimator::computeCSSPropertyValue const): >+ (WebCore::SVGPropertyAnimator::computeInheritedCSSPropertyValue const): >+ * svg/properties/SVGPropertyAnimatorCreator.h: Added. >+ (WebCore::SVGPropertyAnimatorCreator::isKnownAttribute): >+ (WebCore::SVGPropertyAnimatorCreator::createAnimator): >+ (WebCore::SVGPropertyAnimatorCreator::attributeAnimatorCreator): >+ (WebCore::SVGPropertyAnimatorCreator::createColorAnimator): >+ (WebCore::SVGPropertyAnimatorCreator::createLengthAnimator): >+ (WebCore::SVGPropertyAnimatorCreator::createLengthListAnimator): >+ (WebCore::SVGPropertyAnimatorCreator::createNumberAnimator): >+ (WebCore::SVGPropertyAnimatorCreator::createRectAnimator): >+ (WebCore::SVGPropertyAnimatorCreator::createStringAnimator): >+ * svg/properties/SVGValuePropertyAnimator.h: Added. >+ (WebCore::SVGValuePropertyAnimator::SVGValuePropertyAnimator): >+ * svg/properties/SVGValuePropertyAnimatorImpl.h: Added. >+ * svg/properties/SVGValuePropertyListAnimator.h: Added. >+ (WebCore::SVGValuePropertyListAnimator::SVGValuePropertyListAnimator): >+ * svg/properties/SVGValuePropertyListAnimatorImpl.h: Added. >+ > 2018-12-04 Said Abou-Hallawa <sabouhallawa@apple.com> > > Remove SVG properties tear-off objects >diff --git a/Source/WebCore/Sources.txt b/Source/WebCore/Sources.txt >index 883714d6e68..24e9d569e53 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -2343,6 +2343,7 @@ svg/graphics/filters/SVGFilterBuilder.cpp > svg/properties/SVGAnimatedPathSegListPropertyTearOff.cpp > svg/properties/SVGAnimatedProperty.cpp > svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp >+svg/properties/SVGAnimator.cpp > > workers/AbstractWorker.cpp > workers/DedicatedWorkerGlobalScope.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 841415721df..011389f3e19 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -9342,6 +9342,20 @@ > 72227A8A21B6EAA3008EC3E4 /* SVGAnimationDiscreteFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimationDiscreteFunction.h; sourceTree = "<group>"; }; > 72227A8B21B6EAA4008EC3E4 /* SVGAnimationAdditiveListFunctionImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimationAdditiveListFunctionImpl.h; sourceTree = "<group>"; }; > 72227A8C21B6EAA4008EC3E4 /* SVGAnimationAdditiveFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimationAdditiveFunction.h; sourceTree = "<group>"; }; >+ 72227A8D21B6F5CB008EC3E4 /* SVGValuePropertyAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGValuePropertyAnimator.h; sourceTree = "<group>"; }; >+ 72227A8E21B6F5CC008EC3E4 /* SVGAnimatedPropertyPairAnimatorImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyPairAnimatorImpl.h; sourceTree = "<group>"; }; >+ 72227A8F21B6F5CC008EC3E4 /* SVGAnimatedPropertyAnimatorImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyAnimatorImpl.h; sourceTree = "<group>"; }; >+ 72227A9021B6F5CD008EC3E4 /* SVGPrimitivePropertyAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPrimitivePropertyAnimator.h; sourceTree = "<group>"; }; >+ 72227A9121B6F5CD008EC3E4 /* SVGPropertyAnimatorCreator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPropertyAnimatorCreator.h; sourceTree = "<group>"; }; >+ 72227A9221B6F5CE008EC3E4 /* SVGAnimatedPropertyAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyAnimator.h; sourceTree = "<group>"; }; >+ 72227A9321B6F5CE008EC3E4 /* SVGPrimitivePropertyAnimatorImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPrimitivePropertyAnimatorImpl.h; sourceTree = "<group>"; }; >+ 72227A9421B6F5CF008EC3E4 /* SVGPropertyAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPropertyAnimator.h; sourceTree = "<group>"; }; >+ 72227A9521B6F5CF008EC3E4 /* SVGAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimator.h; sourceTree = "<group>"; }; >+ 72227A9621B6F5CF008EC3E4 /* SVGValuePropertyListAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGValuePropertyListAnimator.h; sourceTree = "<group>"; }; >+ 72227A9721B6F5D0008EC3E4 /* SVGAnimatedPropertyPairAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyPairAnimator.h; sourceTree = "<group>"; }; >+ 72227A9821B6F5D0008EC3E4 /* SVGValuePropertyAnimatorImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGValuePropertyAnimatorImpl.h; sourceTree = "<group>"; }; >+ 72227A9921B6F5D1008EC3E4 /* SVGAnimator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimator.cpp; sourceTree = "<group>"; }; >+ 72227A9A21B6F5D1008EC3E4 /* SVGValuePropertyListAnimatorImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGValuePropertyListAnimatorImpl.h; sourceTree = "<group>"; }; > 724ED3291A3A7E5400F5F13C /* EXTBlendMinMax.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EXTBlendMinMax.cpp; sourceTree = "<group>"; }; > 724ED32A1A3A7E5400F5F13C /* EXTBlendMinMax.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EXTBlendMinMax.h; sourceTree = "<group>"; }; > 724ED32B1A3A7E5400F5F13C /* EXTBlendMinMax.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EXTBlendMinMax.idl; sourceTree = "<group>"; }; >@@ -15778,9 +15792,13 @@ > 72227A8121B6DC6E008EC3E4 /* SVGAnimatedPrimitiveProperty.h */, > 836FBCEB178C117F00B21A15 /* SVGAnimatedProperty.cpp */, > 088A0DFC126EF1DB00978F7A /* SVGAnimatedProperty.h */, >+ 72227A9221B6F5CE008EC3E4 /* SVGAnimatedPropertyAnimator.h */, >+ 72227A8F21B6F5CC008EC3E4 /* SVGAnimatedPropertyAnimatorImpl.h */, > 72227A8021B6DC6E008EC3E4 /* SVGAnimatedPropertyImpl.h */, > 088A0DFD126EF1DB00978F7A /* SVGAnimatedPropertyDescription.h */, > 72227A8221B6DC6F008EC3E4 /* SVGAnimatedPropertyList.h */, >+ 72227A9721B6F5D0008EC3E4 /* SVGAnimatedPropertyPairAnimator.h */, >+ 72227A8E21B6F5CC008EC3E4 /* SVGAnimatedPropertyPairAnimatorImpl.h */, > 088A0DFF126EF1DB00978F7A /* SVGAnimatedPropertyTearOff.h */, > 55FA7FFE21110E6E005AEFE7 /* SVGAnimatedPropertyType.h */, > 08525E621278C00100A84778 /* SVGAnimatedStaticPropertyTearOff.h */, >@@ -15795,6 +15813,8 @@ > 72227A8A21B6EAA3008EC3E4 /* SVGAnimationDiscreteFunction.h */, > 72227A8521B6EAA1008EC3E4 /* SVGAnimationDiscreteFunctionImpl.h */, > 72227A8921B6EAA3008EC3E4 /* SVGAnimationFunction.h */, >+ 72227A9921B6F5D1008EC3E4 /* SVGAnimator.cpp */, >+ 72227A9521B6F5CF008EC3E4 /* SVGAnimator.h */, > 55FA7FEF210FA386005AEFE7 /* SVGAttribute.h */, > 55FA7FF4210FB688005AEFE7 /* SVGAttributeAccessor.h */, > 55346AF021150FAF0059BCDD /* SVGAttributeOwnerProxy.h */, >@@ -15808,7 +15828,11 @@ > 088A0E00126EF1DB00978F7A /* SVGListPropertyTearOff.h */, > 08CA3D4312894A3800FFF260 /* SVGMatrixTearOff.h */, > 72227A7321B50901008EC3E4 /* SVGPrimitiveList.h */, >+ 72227A9021B6F5CD008EC3E4 /* SVGPrimitivePropertyAnimator.h */, >+ 72227A9321B6F5CE008EC3E4 /* SVGPrimitivePropertyAnimatorImpl.h */, > 088A0E01126EF1DB00978F7A /* SVGProperty.h */, >+ 72227A9421B6F5CF008EC3E4 /* SVGPropertyAnimator.h */, >+ 72227A9121B6F5CD008EC3E4 /* SVGPropertyAnimatorCreator.h */, > 72227A7221B50901008EC3E4 /* SVGPropertyList.h */, > 72227A6C21B4B1F6008EC3E4 /* SVGPropertyOwner.h */, > 088A0E02126EF1DB00978F7A /* SVGPropertyTearOff.h */, >@@ -15816,7 +15840,11 @@ > 0880F70D1282B46D00948505 /* SVGStaticListPropertyTearOff.h */, > 0813A4E91284132600992511 /* SVGStaticPropertyTearOff.h */, > 72227A6D21B4B1F7008EC3E4 /* SVGValueProperty.h */, >+ 72227A8D21B6F5CB008EC3E4 /* SVGValuePropertyAnimator.h */, >+ 72227A9821B6F5D0008EC3E4 /* SVGValuePropertyAnimatorImpl.h */, > 72227A7121B50900008EC3E4 /* SVGValuePropertyList.h */, >+ 72227A9621B6F5CF008EC3E4 /* SVGValuePropertyListAnimator.h */, >+ 72227A9A21B6F5D1008EC3E4 /* SVGValuePropertyListAnimatorImpl.h */, > ); > path = properties; > sourceTree = "<group>"; >diff --git a/Source/WebCore/svg/properties/SVGAnimatedPropertyAnimator.h b/Source/WebCore/svg/properties/SVGAnimatedPropertyAnimator.h >index 8b137891791..c62209e9d2a 100644 >--- a/Source/WebCore/svg/properties/SVGAnimatedPropertyAnimator.h >+++ b/Source/WebCore/svg/properties/SVGAnimatedPropertyAnimator.h >@@ -1 +1,109 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ > >+#pragma once >+ >+#include "SVGAnimator.h" >+ >+namespace WebCore { >+ >+class SVGElement; >+ >+template<typename AnimatedProperty, typename AnimationFunction> >+class SVGAnimatedPropertyAnimator : public SVGAnimator { >+public: >+ using AnimatorAnimatedProperty = AnimatedProperty; >+ >+ void appendAnimatedInstance(Ref<AnimatedProperty>& animated) >+ { >+ m_animatedInstances.append(animated.copyRef()); >+ } >+ >+ bool isDiscrete() const override { return m_function.isDiscrete(); } >+ >+ void setFromAndToValues(SVGElement* targetElement, const String& from, const String& to) override >+ { >+ m_function.setFromAndToValues(targetElement, from, to); >+ } >+ >+ void setFromAndByValues(SVGElement* targetElement, const String& from, const String& by) override >+ { >+ m_function.setFromAndByValues(targetElement, from, by); >+ } >+ >+ void setToAtEndOfDurationValue(const String& toAtEndOfDuration) override >+ { >+ m_function.setToAtEndOfDurationValue(toAtEndOfDuration); >+ } >+ >+ void start(SVGElement*) override >+ { >+ m_animated->startAnimation(); >+ for (auto& instance : m_animatedInstances) >+ instance->instanceStartAnimation(m_animated); >+ } >+ >+ void apply(SVGElement* targetElement) override >+ { >+ if (isAnimatedStylePropertyAniamtor(targetElement)) >+ applyAnimatedStylePropertyChange(targetElement, m_animated->animValAsString()); >+ >+ applyAnimatedPropertyChange(targetElement); >+ } >+ >+ void stop(SVGElement* targetElement) override >+ { >+ if (!m_animated->isAnimating()) >+ return; >+ >+ m_animated->stopAnimation(); >+ for (auto& instance : m_animatedInstances) >+ instance->instanceStopAnimation(); >+ >+ applyAnimatedPropertyChange(targetElement); >+ if (isAnimatedStylePropertyAniamtor(targetElement)) >+ removeAnimatedStyleProperty(targetElement); >+ } >+ >+ float calculateDistance(SVGElement* targetElement, const String& from, const String& to) const override >+ { >+ return m_function.calculateDistance(targetElement, from, to); >+ } >+ >+protected: >+ template<typename... Arguments> >+ SVGAnimatedPropertyAnimator(const QualifiedName& attributeName, Ref<AnimatedProperty>& animated, Arguments&&... arguments) >+ : SVGAnimator(attributeName) >+ , m_animated(animated.copyRef()) >+ , m_function(std::forward<Arguments>(arguments)...) >+ { >+ } >+ >+ Ref<AnimatedProperty> m_animated; >+ Vector<Ref<AnimatedProperty>> m_animatedInstances; >+ AnimationFunction m_function; >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGAnimatedPropertyAnimatorImpl.h b/Source/WebCore/svg/properties/SVGAnimatedPropertyAnimatorImpl.h >index 8b137891791..5b08087a00b 100644 >--- a/Source/WebCore/svg/properties/SVGAnimatedPropertyAnimatorImpl.h >+++ b/Source/WebCore/svg/properties/SVGAnimatedPropertyAnimatorImpl.h >@@ -1 +1,329 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ > >+#pragma once >+ >+#include "SVGAnimatedPropertyAnimator.h" >+#include "SVGAnimatedPropertyImpl.h" >+#include "SVGAnimationAdditiveListFunctionImpl.h" >+#include "SVGAnimationAdditiveValueFunctionImpl.h" >+#include "SVGAnimationDiscreteFunctionImpl.h" >+#include "SVGMarkerTypes.h" >+#include "SVGPathByteStream.h" >+ >+namespace WebCore { >+ >+class SVGAnimatedAngleAnimator; >+class SVGAnimatedIntegerPairAnimator; >+class SVGAnimatedNumberPairAnimator; >+class SVGAnimatedOrientTypeAnimator; >+ >+template<typename AnimatedPropertyAnimator1, typename AnimatedPropertyAnimator2> >+class SVGAnimatedPropertyPairAnimator; >+ >+class SVGAnimatedBooleanAnimator final : public SVGAnimatedPropertyAnimator<SVGAnimatedBoolean, SVGAnimationBooleanFunction> { >+ using Base = SVGAnimatedPropertyAnimator<SVGAnimatedBoolean, SVGAnimationBooleanFunction>; >+ using Base::Base; >+ >+public: >+ static auto create(const QualifiedName& attributeName, Ref<SVGAnimatedBoolean>& animated, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return adoptRef(*new SVGAnimatedBooleanAnimator(attributeName, animated, animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+ >+private: >+ void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) final >+ { >+ bool& animated = m_animated->animVal(); >+ m_function.progress(targetElement, percentage, repeatCount, animated); >+ } >+}; >+ >+template<typename EnumType> >+class SVGAnimatedEnumerationAnimator final : public SVGAnimatedPropertyAnimator<SVGAnimatedEnumeration, SVGAnimationEnumerationFunction<EnumType>> { >+ using Base = SVGAnimatedPropertyAnimator<SVGAnimatedEnumeration, SVGAnimationEnumerationFunction<EnumType>>; >+ using Base::Base; >+ using Base::m_animated; >+ using Base::m_function; >+ >+public: >+ static auto create(const QualifiedName& attributeName, Ref<SVGAnimatedEnumeration>& animated, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return adoptRef(*new SVGAnimatedEnumerationAnimator<EnumType>(attributeName, animated, animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+ >+private: >+ void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) final >+ { >+ EnumType animated; >+ m_function.progress(targetElement, percentage, repeatCount, animated); >+ m_animated->template setAnimVal<EnumType>(animated); >+ } >+}; >+ >+class SVGAnimatedPreserveAspectRatioAnimator final : public SVGAnimatedPropertyAnimator<SVGAnimatedPreserveAspectRatio, SVGAnimationPreserveAspectRatioFunction> { >+ using Base = SVGAnimatedPropertyAnimator<SVGAnimatedPreserveAspectRatio, SVGAnimationPreserveAspectRatioFunction>; >+ using Base::Base; >+ >+public: >+ static auto create(const QualifiedName& attributeName, Ref<SVGAnimatedPreserveAspectRatio>& animated, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return adoptRef(*new SVGAnimatedPreserveAspectRatioAnimator(attributeName, animated, animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+ >+private: >+ void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) final >+ { >+ SVGPreserveAspectRatioValue& animated = m_animated->animVal()->value(); >+ m_function.progress(targetElement, percentage, repeatCount, animated); >+ } >+}; >+ >+class SVGAnimatedStringAnimator final : public SVGAnimatedPropertyAnimator<SVGAnimatedString, SVGAnimationStringFunction> { >+ using Base = SVGAnimatedPropertyAnimator<SVGAnimatedString, SVGAnimationStringFunction>; >+ using Base::Base; >+ >+public: >+ static auto create(const QualifiedName& attributeName, Ref<SVGAnimatedString>& animated, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return adoptRef(*new SVGAnimatedStringAnimator(attributeName, animated, animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+ >+private: >+ void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) final >+ { >+ String& animated = m_animated->animVal(); >+ m_function.progress(targetElement, percentage, repeatCount, animated); >+ } >+}; >+ >+class SVGAnimatedOrientTypeAnimator final : public SVGAnimatedPropertyAnimator<SVGAnimatedOrientType, SVGAnimationOrientTypeFunction> { >+ friend class SVGAnimatedPropertyPairAnimator<SVGAnimatedAngleAnimator, SVGAnimatedOrientTypeAnimator>; >+ friend class SVGAnimatedAngleOrientAnimator; >+ using Base = SVGAnimatedPropertyAnimator<SVGAnimatedOrientType, SVGAnimationOrientTypeFunction>; >+ using Base::Base; >+ >+public: >+ static auto create(const QualifiedName& attributeName, Ref<SVGAnimatedOrientType>& animated, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return adoptRef(*new SVGAnimatedOrientTypeAnimator(attributeName, animated, animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+ >+private: >+ void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) final >+ { >+ SVGMarkerOrientType animated; >+ m_function.progress(targetElement, percentage, repeatCount, animated); >+ m_animated->setAnimVal(animated); >+ } >+}; >+ >+class SVGAnimatedNumberAnimator final : public SVGAnimatedPropertyAnimator<SVGAnimatedNumber, SVGAnimationNumberFunction> { >+ friend class SVGAnimatedPropertyPairAnimator<SVGAnimatedNumberAnimator, SVGAnimatedNumberAnimator>; >+ friend class SVGAnimatedNumberPairAnimator; >+ using Base = SVGAnimatedPropertyAnimator<SVGAnimatedNumber, SVGAnimationNumberFunction>; >+ using Base::Base; >+ >+public: >+ static auto create(const QualifiedName& attributeName, Ref<SVGAnimatedNumber>& animated, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return adoptRef(*new SVGAnimatedNumberAnimator(attributeName, animated, animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+ >+private: >+ void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) final >+ { >+ m_function.progress(targetElement, percentage, repeatCount, m_animated->animVal()); >+ } >+}; >+ >+class SVGAnimatedIntegerAnimator final : public SVGAnimatedPropertyAnimator<SVGAnimatedInteger, SVGAnimationIntegerFunction> { >+ friend class SVGAnimatedPropertyPairAnimator<SVGAnimatedIntegerAnimator, SVGAnimatedIntegerAnimator>; >+ friend class SVGAnimatedIntegerPairAnimator; >+ using Base = SVGAnimatedPropertyAnimator<SVGAnimatedInteger, SVGAnimationIntegerFunction>; >+ using Base::Base; >+ >+public: >+ static auto create(const QualifiedName& attributeName, Ref<SVGAnimatedInteger>& animated, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return adoptRef(*new SVGAnimatedIntegerAnimator(attributeName, animated, animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+ >+private: >+ void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) final >+ { >+ m_function.progress(targetElement, percentage, repeatCount, m_animated->animVal()); >+ } >+}; >+ >+class SVGAnimatedRectAnimator final : public SVGAnimatedPropertyAnimator<SVGAnimatedRect, SVGAnimationRectFunction> { >+ using Base = SVGAnimatedPropertyAnimator<SVGAnimatedRect, SVGAnimationRectFunction>; >+ using Base::Base; >+ >+public: >+ static auto create(const QualifiedName& attributeName, Ref<SVGAnimatedRect>& animated, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return adoptRef(*new SVGAnimatedRectAnimator(attributeName, animated, animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+ >+private: >+ void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) final >+ { >+ m_function.progress(targetElement, percentage, repeatCount, m_animated->animVal()->value()); >+ } >+}; >+ >+class SVGAnimatedAngleAnimator final : public SVGAnimatedPropertyAnimator<SVGAnimatedAngle, SVGAnimationAngleFunction> { >+ friend class SVGAnimatedPropertyPairAnimator<SVGAnimatedAngleAnimator, SVGAnimatedOrientTypeAnimator>; >+ friend class SVGAnimatedAngleOrientAnimator; >+ using Base = SVGAnimatedPropertyAnimator<SVGAnimatedAngle, SVGAnimationAngleFunction>; >+ using Base::Base; >+ >+public: >+ static auto create(const QualifiedName& attributeName, Ref<SVGAnimatedAngle>& animated, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return adoptRef(*new SVGAnimatedAngleAnimator(attributeName, animated, animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+ >+private: >+ void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) final >+ { >+ m_function.progress(targetElement, percentage, repeatCount, m_animated->animVal()->value()); >+ } >+}; >+ >+class SVGAnimatedLengthAnimator final : public SVGAnimatedPropertyAnimator<SVGAnimatedLength, SVGAnimationLengthFunction> { >+ using Base = SVGAnimatedPropertyAnimator<SVGAnimatedLength, SVGAnimationLengthFunction>; >+ >+public: >+ static auto create(const QualifiedName& attributeName, Ref<SVGAnimatedLength>& animated, AnimationMode animationMode, >+ CalcMode calcMode, bool isAccumulated, bool isAdditive, SVGLengthMode lengthMode) >+ { >+ return adoptRef(*new SVGAnimatedLengthAnimator(attributeName, animated, animationMode, calcMode, isAccumulated, isAdditive, lengthMode)); >+ } >+private: >+ SVGAnimatedLengthAnimator(const QualifiedName& attributeName, Ref<SVGAnimatedLength>& animated, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive, SVGLengthMode lengthMode) >+ : Base(attributeName, animated, animationMode, calcMode, isAccumulated, isAdditive, lengthMode) >+ { >+ } >+ >+ void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) final >+ { >+ m_function.progress(targetElement, percentage, repeatCount, m_animated->animVal()->value()); >+ } >+}; >+ >+class SVGAnimatedLengthListAnimator final : public SVGAnimatedPropertyAnimator<SVGAnimatedLengthList, SVGAnimationLengthListFunction> { >+ using Base = SVGAnimatedPropertyAnimator<SVGAnimatedLengthList, SVGAnimationLengthListFunction>; >+ >+public: >+ static auto create(const QualifiedName& attributeName, Ref<SVGAnimatedLengthList>& animated, AnimationMode animationMode, >+ CalcMode calcMode, bool isAccumulated, bool isAdditive, SVGLengthMode lengthMode) >+ { >+ return adoptRef(*new SVGAnimatedLengthListAnimator(attributeName, animated, animationMode, calcMode, isAccumulated, isAdditive, lengthMode)); >+ } >+ >+private: >+ SVGAnimatedLengthListAnimator(const QualifiedName& attributeName, Ref<SVGAnimatedLengthList>& animated, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive, SVGLengthMode lengthMode) >+ : Base(attributeName, animated, animationMode, calcMode, isAccumulated, isAdditive, lengthMode) >+ { >+ } >+ >+ void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) final >+ { >+ m_function.progress(targetElement, percentage, repeatCount, m_animated->animVal()); >+ } >+}; >+ >+class SVGAnimatedNumberListAnimator final : public SVGAnimatedPropertyAnimator<SVGAnimatedNumberList, SVGAnimationNumberListFunction> { >+ using Base = SVGAnimatedPropertyAnimator<SVGAnimatedNumberList, SVGAnimationNumberListFunction>; >+ using Base::Base; >+ >+public: >+ static auto create(const QualifiedName& attributeName, Ref<SVGAnimatedNumberList>& animated, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return adoptRef(*new SVGAnimatedNumberListAnimator(attributeName, animated, animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+ >+private: >+ void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) final >+ { >+ m_function.progress(targetElement, percentage, repeatCount, m_animated->animVal()); >+ } >+}; >+ >+class SVGAnimatedPointListAnimator final : public SVGAnimatedPropertyAnimator<SVGAnimatedPointList, SVGAnimationPointListFunction> { >+ using Base = SVGAnimatedPropertyAnimator<SVGAnimatedPointList, SVGAnimationPointListFunction>; >+ using Base::Base; >+ >+public: >+ static auto create(const QualifiedName& attributeName, Ref<SVGAnimatedPointList>& animated, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return adoptRef(*new SVGAnimatedPointListAnimator(attributeName, animated, animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+ >+private: >+ void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) final >+ { >+ m_function.progress(targetElement, percentage, repeatCount, m_animated->animVal()); >+ } >+}; >+ >+class SVGAnimatedTransformListAnimator final : public SVGAnimatedPropertyAnimator<SVGAnimatedTransformList, SVGAnimationTransformListFunction> { >+ using Base = SVGAnimatedPropertyAnimator<SVGAnimatedTransformList, SVGAnimationTransformListFunction>; >+ using Base::Base; >+ >+public: >+ static auto create(const QualifiedName& attributeName, Ref<SVGAnimatedTransformList>& animated, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return adoptRef(*new SVGAnimatedTransformListAnimator(attributeName, animated, animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+ >+private: >+ void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) final >+ { >+ m_function.progress(targetElement, percentage, repeatCount, m_animated->animVal()); >+ } >+}; >+ >+class SVGAnimatedPathSegListAnimator final : public SVGAnimatedPropertyAnimator<SVGAnimatedPathSegList, SVGAnimationPathSegListFunction> { >+ using Base = SVGAnimatedPropertyAnimator<SVGAnimatedPathSegList, SVGAnimationPathSegListFunction>; >+ using Base::Base; >+ >+public: >+ static auto create(const QualifiedName& attributeName, Ref<SVGAnimatedPathSegList>& animated, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return adoptRef(*new SVGAnimatedPathSegListAnimator(attributeName, animated, animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+ >+private: >+ void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) final >+ { >+ m_animated->animVal()->pathByteStreamWillChange(); >+ m_function.progress(targetElement, percentage, repeatCount, m_animated->animVal()->pathByteStream()); >+ } >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGAnimatedPropertyPairAnimator.h b/Source/WebCore/svg/properties/SVGAnimatedPropertyPairAnimator.h >index 8b137891791..e1436bce4c3 100644 >--- a/Source/WebCore/svg/properties/SVGAnimatedPropertyPairAnimator.h >+++ b/Source/WebCore/svg/properties/SVGAnimatedPropertyPairAnimator.h >@@ -1 +1,81 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ > >+#pragma once >+ >+#include "SVGAnimator.h" >+ >+namespace WebCore { >+ >+class SVGElement; >+ >+template<typename AnimatedPropertyAnimator1, typename AnimatedPropertyAnimator2> >+class SVGAnimatedPropertyPairAnimator : public SVGAnimator { >+public: >+ using AnimatedProperty1 = typename AnimatedPropertyAnimator1::AnimatorAnimatedProperty; >+ using AnimatedProperty2 = typename AnimatedPropertyAnimator2::AnimatorAnimatedProperty; >+ >+ void appendAnimatedInstance(Ref<AnimatedProperty1>& animated1, Ref<AnimatedProperty2>& animated2) >+ { >+ m_animatedPropertyAnimator1->appendAnimatedInstance(animated1); >+ m_animatedPropertyAnimator2->appendAnimatedInstance(animated2); >+ } >+ >+protected: >+ SVGAnimatedPropertyPairAnimator(const QualifiedName& attributeName, Ref<AnimatedProperty1>& animated1, Ref<AnimatedProperty2>& animated2, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ : SVGAnimator(attributeName) >+ , m_animatedPropertyAnimator1(AnimatedPropertyAnimator1::create(attributeName, animated1, animationMode, calcMode, isAccumulated, isAdditive)) >+ , m_animatedPropertyAnimator2(AnimatedPropertyAnimator2::create(attributeName, animated2, animationMode, calcMode, isAccumulated, isAdditive)) >+ { >+ } >+ >+ void start(SVGElement* targetElement) override >+ { >+ m_animatedPropertyAnimator1->start(targetElement); >+ m_animatedPropertyAnimator2->start(targetElement); >+ } >+ >+ void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) override >+ { >+ m_animatedPropertyAnimator1->progress(targetElement, percentage, repeatCount); >+ m_animatedPropertyAnimator2->progress(targetElement, percentage, repeatCount); >+ } >+ >+ void apply(SVGElement* targetElement) override >+ { >+ applyAnimatedPropertyChange(targetElement); >+ } >+ >+ void stop(SVGElement* targetElement) override >+ { >+ m_animatedPropertyAnimator1->stop(targetElement); >+ m_animatedPropertyAnimator2->stop(targetElement); >+ } >+ >+ Ref<AnimatedPropertyAnimator1> m_animatedPropertyAnimator1; >+ Ref<AnimatedPropertyAnimator2> m_animatedPropertyAnimator2; >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGAnimatedPropertyPairAnimatorImpl.h b/Source/WebCore/svg/properties/SVGAnimatedPropertyPairAnimatorImpl.h >index 8b137891791..85e84b314d6 100644 >--- a/Source/WebCore/svg/properties/SVGAnimatedPropertyPairAnimatorImpl.h >+++ b/Source/WebCore/svg/properties/SVGAnimatedPropertyPairAnimatorImpl.h >@@ -1 +1,195 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ > >+#pragma once >+ >+#include "SVGAnimatedPropertyImpl.h" >+#include "SVGAnimatedPropertyPairAnimator.h" >+#include "SVGMarkerTypes.h" >+ >+namespace WebCore { >+ >+class SVGElement; >+ >+class SVGAnimatedIntegerPairAnimator final : public SVGAnimatedPropertyPairAnimator<SVGAnimatedIntegerAnimator, SVGAnimatedIntegerAnimator> { >+ using Base = SVGAnimatedPropertyPairAnimator<SVGAnimatedIntegerAnimator, SVGAnimatedIntegerAnimator>; >+ using Base::Base; >+ >+public: >+ static auto create(const QualifiedName& attributeName, Ref<SVGAnimatedInteger>& animated1, Ref<SVGAnimatedInteger>& animated2, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return adoptRef(*new SVGAnimatedIntegerPairAnimator(attributeName, animated1, animated2, animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+ >+private: >+ void setFromAndToValues(SVGElement*, const String& from, const String& to) final >+ { >+ auto pairFrom = SVGPropertyTraits<std::pair<int, int>>::fromString(from); >+ auto pairTo = SVGPropertyTraits<std::pair<int, int>>::fromString(to); >+ >+ m_animatedPropertyAnimator1->m_function.m_from = pairFrom.first; >+ m_animatedPropertyAnimator1->m_function.m_to = pairTo.first; >+ >+ m_animatedPropertyAnimator2->m_function.m_from = pairFrom.second; >+ m_animatedPropertyAnimator2->m_function.m_to = pairTo.second; >+ } >+ >+ void setFromAndByValues(SVGElement*, const String& from, const String& by) final >+ { >+ auto pairFrom = SVGPropertyTraits<std::pair<int, int>>::fromString(from); >+ auto pairBy = SVGPropertyTraits<std::pair<int, int>>::fromString(by); >+ >+ m_animatedPropertyAnimator1->m_function.m_from = pairFrom.first; >+ m_animatedPropertyAnimator1->m_function.m_to = pairFrom.first + pairBy.first; >+ >+ m_animatedPropertyAnimator2->m_function.m_from = pairFrom.second; >+ m_animatedPropertyAnimator2->m_function.m_to = pairFrom.second + pairBy.second; >+ } >+ >+ void setToAtEndOfDurationValue(const String& toAtEndOfDuration) final >+ { >+ auto pairToAtEndOfDuration = SVGPropertyTraits<std::pair<int, int>>::fromString(toAtEndOfDuration); >+ m_animatedPropertyAnimator1->m_function.m_toAtEndOfDuration = pairToAtEndOfDuration.first; >+ m_animatedPropertyAnimator2->m_function.m_toAtEndOfDuration = pairToAtEndOfDuration.second; >+ } >+}; >+ >+class SVGAnimatedNumberPairAnimator final : public SVGAnimatedPropertyPairAnimator<SVGAnimatedNumberAnimator, SVGAnimatedNumberAnimator> { >+ using Base = SVGAnimatedPropertyPairAnimator<SVGAnimatedNumberAnimator, SVGAnimatedNumberAnimator>; >+ using Base::Base; >+ >+public: >+ static auto create(const QualifiedName& attributeName, Ref<SVGAnimatedNumber>& animated1, Ref<SVGAnimatedNumber>& animated2, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return adoptRef(*new SVGAnimatedNumberPairAnimator(attributeName, animated1, animated2, animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+ >+private: >+ void setFromAndToValues(SVGElement*, const String& from, const String& to) final >+ { >+ auto pairFrom = SVGPropertyTraits<std::pair<float, float>>::fromString(from); >+ auto pairTo = SVGPropertyTraits<std::pair<float, float>>::fromString(to); >+ >+ m_animatedPropertyAnimator1->m_function.m_from = pairFrom.first; >+ m_animatedPropertyAnimator1->m_function.m_to = pairTo.first; >+ >+ m_animatedPropertyAnimator2->m_function.m_from = pairFrom.second; >+ m_animatedPropertyAnimator2->m_function.m_to = pairTo.second; >+ } >+ >+ void setFromAndByValues(SVGElement*, const String& from, const String& by) final >+ { >+ auto pairFrom = SVGPropertyTraits<std::pair<float, float>>::fromString(from); >+ auto pairBy = SVGPropertyTraits<std::pair<float, float>>::fromString(by); >+ >+ m_animatedPropertyAnimator1->m_function.m_from = pairFrom.first; >+ m_animatedPropertyAnimator1->m_function.m_to = pairFrom.first + pairBy.first; >+ >+ m_animatedPropertyAnimator2->m_function.m_from = pairFrom.second; >+ m_animatedPropertyAnimator2->m_function.m_to = pairFrom.second + pairBy.second; >+ } >+ >+ void setToAtEndOfDurationValue(const String& toAtEndOfDuration) final >+ { >+ auto pairToAtEndOfDuration = SVGPropertyTraits<std::pair<float, float>>::fromString(toAtEndOfDuration); >+ m_animatedPropertyAnimator1->m_function.m_toAtEndOfDuration = pairToAtEndOfDuration.first; >+ m_animatedPropertyAnimator2->m_function.m_toAtEndOfDuration = pairToAtEndOfDuration.second; >+ } >+}; >+ >+class SVGAnimatedAngleOrientAnimator final : public SVGAnimatedPropertyPairAnimator<SVGAnimatedAngleAnimator, SVGAnimatedOrientTypeAnimator> { >+ using Base = SVGAnimatedPropertyPairAnimator<SVGAnimatedAngleAnimator, SVGAnimatedOrientTypeAnimator>; >+ using Base::Base; >+ >+public: >+ static auto create(const QualifiedName& attributeName, Ref<SVGAnimatedAngle>& animated1, Ref<SVGAnimatedOrientType>& animated2, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return adoptRef(*new SVGAnimatedAngleOrientAnimator(attributeName, animated1, animated2, animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+ >+private: >+ void setFromAndToValues(SVGElement*, const String& from, const String& to) final >+ { >+ auto pairFrom = SVGPropertyTraits<std::pair<SVGAngleValue, SVGMarkerOrientType>>::fromString(from); >+ auto pairTo = SVGPropertyTraits<std::pair<SVGAngleValue, SVGMarkerOrientType>>::fromString(to); >+ >+ m_animatedPropertyAnimator1->m_function.m_from = pairFrom.first; >+ m_animatedPropertyAnimator1->m_function.m_to = pairTo.first; >+ >+ m_animatedPropertyAnimator2->m_function.m_from = pairFrom.second; >+ m_animatedPropertyAnimator2->m_function.m_to = pairTo.second; >+ } >+ >+ void setFromAndByValues(SVGElement* targetElement, const String& from, const String& by) final >+ { >+ setFromAndToValues(targetElement, from, by); >+ if (m_animatedPropertyAnimator2->m_function.m_from != SVGMarkerOrientAngle || m_animatedPropertyAnimator2->m_function.m_to != SVGMarkerOrientAngle) >+ return; >+ m_animatedPropertyAnimator1->m_function.addFromAndToValues(targetElement); >+ } >+ >+ void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) final >+ { >+ if (m_animatedPropertyAnimator2->m_function.m_from != m_animatedPropertyAnimator2->m_function.m_to) { >+ // Discrete animation - no linear interpolation possible between values (e.g. auto to angle). >+ m_animatedPropertyAnimator2->progress(targetElement, percentage, repeatCount); >+ >+ SVGAngleValue animatedAngle; >+ if (percentage < 0.5f && m_animatedPropertyAnimator2->m_function.m_from == SVGMarkerOrientAngle) >+ animatedAngle = m_animatedPropertyAnimator1->m_function.m_from; >+ else if (percentage >= 0.5f && m_animatedPropertyAnimator2->m_function.m_to == SVGMarkerOrientAngle) >+ animatedAngle = m_animatedPropertyAnimator1->m_function.m_to; >+ >+ m_animatedPropertyAnimator1->m_animated->setAnimVal(animatedAngle); >+ return; >+ } >+ >+ if (m_animatedPropertyAnimator2->m_function.m_from == SVGMarkerOrientAngle) { >+ // Regular from- toangle animation, with support for smooth interpolation, and additive and accumulated animation. >+ m_animatedPropertyAnimator2->m_animated->setAnimVal(SVGMarkerOrientAngle); >+ >+ m_animatedPropertyAnimator1->progress(targetElement, percentage, repeatCount); >+ return; >+ } >+ >+ // auto, auto-start-reverse, or unknown. >+ m_animatedPropertyAnimator1->m_animated->animVal()->value().setValue(0); >+ >+ if (m_animatedPropertyAnimator2->m_function.m_from == SVGMarkerOrientAuto || m_animatedPropertyAnimator2->m_function.m_from == SVGMarkerOrientAutoStartReverse) >+ m_animatedPropertyAnimator2->m_animated->setAnimVal(m_animatedPropertyAnimator2->m_function.m_from); >+ else >+ m_animatedPropertyAnimator2->m_animated->setAnimVal(SVGMarkerOrientUnknown); >+ } >+ >+ void stop(SVGElement* targetElement) final >+ { >+ if (!m_animatedPropertyAnimator1->m_animated->isAnimating()) >+ return; >+ apply(targetElement); >+ Base::stop(targetElement); >+ } >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGAnimator.cpp b/Source/WebCore/svg/properties/SVGAnimator.cpp >index 8b137891791..bfa40b95d3b 100644 >--- a/Source/WebCore/svg/properties/SVGAnimator.cpp >+++ b/Source/WebCore/svg/properties/SVGAnimator.cpp >@@ -1 +1,120 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ > >+#include "config.h" >+#include "SVGAnimator.h" >+ >+#include "CSSComputedStyleDeclaration.h" >+#include "CSSPropertyParser.h" >+#include "SVGElement.h" >+ >+namespace WebCore { >+ >+bool SVGAnimator::isAnimatedStylePropertyAniamtor(const SVGElement* targetElement) const >+{ >+ return targetElement->isAnimatedStyleAttribute(m_attributeName); >+} >+ >+void SVGAnimator::applyAnimatedStylePropertyChange(SVGElement* element, CSSPropertyID id, const String& value) >+{ >+ ASSERT(element); >+ ASSERT(!element->m_deletionHasBegun); >+ >+ if (!element->ensureAnimatedSMILStyleProperties().setProperty(id, value, false)) >+ return; >+ element->invalidateStyleAndLayerComposition(); >+} >+ >+void SVGAnimator::applyAnimatedStylePropertyChange(SVGElement* targetElement, const String& value) >+{ >+ ASSERT(targetElement); >+ ASSERT(m_attributeName != anyQName()); >+ >+ // FIXME: Do we really need to check both isConnected and !parentNode? >+ if (!targetElement->isConnected() || !targetElement->parentNode()) >+ return; >+ >+ CSSPropertyID id = cssPropertyID(m_attributeName.localName()); >+ >+ SVGElement::InstanceUpdateBlocker blocker(*targetElement); >+ applyAnimatedStylePropertyChange(targetElement, id, value); >+ >+ // If the target element has instances, update them as well, w/o requiring the <use> tree to be rebuilt. >+ for (auto* instance : targetElement->instances()) >+ applyAnimatedStylePropertyChange(instance, id, value); >+} >+ >+void SVGAnimator::removeAnimatedStyleProperty(SVGElement* element, CSSPropertyID id) >+{ >+ ASSERT(element); >+ ASSERT(!element->m_deletionHasBegun); >+ >+ element->ensureAnimatedSMILStyleProperties().removeProperty(id); >+ element->invalidateStyleAndLayerComposition(); >+} >+ >+void SVGAnimator::removeAnimatedStyleProperty(SVGElement* targetElement) >+{ >+ ASSERT(targetElement); >+ ASSERT(m_attributeName != anyQName()); >+ >+ // FIXME: Do we really need to check both isConnected and !parentNode? >+ if (!targetElement->isConnected() || !targetElement->parentNode()) >+ return; >+ >+ CSSPropertyID id = cssPropertyID(m_attributeName.localName()); >+ >+ SVGElement::InstanceUpdateBlocker blocker(*targetElement); >+ removeAnimatedStyleProperty(targetElement, id); >+ >+ // If the target element has instances, update them as well, w/o requiring the <use> tree to be rebuilt. >+ for (auto* instance : targetElement->instances()) >+ removeAnimatedStyleProperty(instance, id); >+} >+ >+void SVGAnimator::applyAnimatedPropertyChange(SVGElement* element, const QualifiedName& attributeName) >+{ >+ ASSERT(!element->m_deletionHasBegun); >+ element->svgAttributeChanged(attributeName); >+} >+ >+void SVGAnimator::applyAnimatedPropertyChange(SVGElement* targetElement) >+{ >+ ASSERT(targetElement); >+ ASSERT(m_attributeName != anyQName()); >+ >+ // FIXME: Do we really need to check both isConnected and !parentNode? >+ if (!targetElement->isConnected() || !targetElement->parentNode()) >+ return; >+ >+ SVGElement::InstanceUpdateBlocker blocker(*targetElement); >+ applyAnimatedPropertyChange(targetElement, m_attributeName); >+ >+ // If the target element has instances, update them as well, w/o requiring the <use> tree to be rebuilt. >+ for (auto* instance : targetElement->instances()) >+ applyAnimatedPropertyChange(instance, m_attributeName); >+} >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGAnimator.h b/Source/WebCore/svg/properties/SVGAnimator.h >index 8b137891791..f177495d209 100644 >--- a/Source/WebCore/svg/properties/SVGAnimator.h >+++ b/Source/WebCore/svg/properties/SVGAnimator.h >@@ -1 +1,77 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ > >+#pragma once >+ >+#include "CSSPropertyNames.h" >+#include "QualifiedName.h" >+#include <wtf/RefCounted.h> >+#include <wtf/StdLibExtras.h> >+ >+namespace WebCore { >+ >+class SVGElement; >+ >+enum class AnimationMode : uint8_t { None, FromTo, FromBy, To, By, Values, Path }; >+enum class CalcMode : uint8_t { Discrete, Linear, Paced, Spline }; >+ >+class SVGAnimator : public RefCounted<SVGAnimator> { >+public: >+ SVGAnimator(const QualifiedName& attributeName) >+ : m_attributeName(attributeName) >+ { >+ } >+ >+ virtual ~SVGAnimator() = default; >+ >+ virtual bool isDiscrete() const { return false; } >+ >+ virtual void setFromAndToValues(SVGElement*, const String&, const String&) { } >+ virtual void setFromAndByValues(SVGElement*, const String&, const String&) { } >+ virtual void setToAtEndOfDurationValue(const String&) { } >+ >+ virtual void start(SVGElement*) = 0; >+ virtual void progress(SVGElement*, float, unsigned) = 0; >+ virtual void apply(SVGElement*) = 0; >+ virtual void stop(SVGElement* targetElement) = 0; >+ >+ virtual float calculateDistance(SVGElement*, const String&, const String&) const { return -1; } >+ virtual RefPtr<SVGAnimator> createSibling(AnimationMode, CalcMode, bool, bool) { return nullptr; } >+ >+protected: >+ bool isAnimatedStylePropertyAniamtor(const SVGElement*) const; >+ >+ static void applyAnimatedStylePropertyChange(SVGElement*, CSSPropertyID, const String& value); >+ static void removeAnimatedStyleProperty(SVGElement*, CSSPropertyID); >+ static void applyAnimatedPropertyChange(SVGElement*, const QualifiedName&); >+ >+ void applyAnimatedStylePropertyChange(SVGElement*, const String& value); >+ void removeAnimatedStyleProperty(SVGElement*); >+ void applyAnimatedPropertyChange(SVGElement*); >+ >+ const QualifiedName& m_attributeName; >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGPrimitivePropertyAnimator.h b/Source/WebCore/svg/properties/SVGPrimitivePropertyAnimator.h >index 8b137891791..fdccd13bad5 100644 >--- a/Source/WebCore/svg/properties/SVGPrimitivePropertyAnimator.h >+++ b/Source/WebCore/svg/properties/SVGPrimitivePropertyAnimator.h >@@ -1 +1,80 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ > >+#pragma once >+ >+#include "SVGPropertyAnimator.h" >+#include "SVGPropertyTraits.h" >+ >+namespace WebCore { >+ >+template<typename PropertyType, typename AnimationFunction> >+class SVGPrimitivePropertyAnimator : public SVGPropertyAnimator<AnimationFunction> { >+ using Base = SVGPropertyAnimator<AnimationFunction>; >+ using Base::Base; >+ using Base::applyAnimatedStylePropertyChange; >+ using Base::computeCSSPropertyValue; >+ using Base::m_function; >+ >+public: >+ void start(SVGElement* targetElement) override >+ { >+ String baseValue = computeCSSPropertyValue(targetElement, cssPropertyID(m_attributeName.localName())); >+ m_property->setValue(SVGPropertyTraits<PropertyType>::fromString(baseValue)); >+ } >+ >+ void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) override >+ { >+ PropertyType& animated = m_property->value(); >+ m_function.progress(targetElement, percentage, repeatCount, animated); >+ } >+ >+ void apply(SVGElement* targetElement) override >+ { >+ applyAnimatedStylePropertyChange(targetElement, SVGPropertyTraits<PropertyType>::toString(m_property->value())); >+ } >+ >+protected: >+ using ValuePropertyType = SVGValueProperty<PropertyType>; >+ using Base::m_attributeName; >+ >+ template<typename... Arguments> >+ SVGPrimitivePropertyAnimator(const QualifiedName& attributeName, Arguments&&... arguments) >+ : Base(attributeName, std::forward<Arguments>(arguments)...) >+ , m_property(ValuePropertyType::create()) >+ { >+ } >+ >+ template<typename... Arguments> >+ SVGPrimitivePropertyAnimator(const QualifiedName& attributeName, Ref<ValuePropertyType>&& property, Arguments&&... arguments) >+ : Base(attributeName, std::forward<Arguments>(arguments)...) >+ , m_property(WTFMove(property)) >+ { >+ } >+ >+ Ref<ValuePropertyType> m_property; >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGPrimitivePropertyAnimatorImpl.h b/Source/WebCore/svg/properties/SVGPrimitivePropertyAnimatorImpl.h >index 8b137891791..16b76c852c8 100644 >--- a/Source/WebCore/svg/properties/SVGPrimitivePropertyAnimatorImpl.h >+++ b/Source/WebCore/svg/properties/SVGPrimitivePropertyAnimatorImpl.h >@@ -1 +1,101 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ > >+#pragma once >+ >+#include "SVGAnimationFunction.h" >+#include "SVGPrimitivePropertyAnimator.h" >+ >+namespace WebCore { >+ >+class SVGColorAnimator final : public SVGPrimitivePropertyAnimator<Color, SVGAnimationColorFunction> { >+ using Base = SVGPrimitivePropertyAnimator<Color, SVGAnimationColorFunction>; >+ using Base::Base; >+ >+public: >+ static Ref<SVGAnimator> create(const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return adoptRef(*new SVGColorAnimator(attributeName, animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+ >+private: >+ RefPtr<SVGAnimator> createSibling(AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) final >+ { >+ return adoptRef(*new SVGColorAnimator(m_attributeName, m_property.copyRef(), animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+}; >+ >+class SVGNumberAnimator : public SVGPrimitivePropertyAnimator<float, SVGAnimationNumberFunction> { >+ using Base = SVGPrimitivePropertyAnimator<float, SVGAnimationNumberFunction>; >+ using Base::Base; >+ >+public: >+ static Ref<SVGAnimator> create(const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return adoptRef(*new SVGNumberAnimator(attributeName, animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+ >+private: >+ RefPtr<SVGAnimator> createSibling(AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) final >+ { >+ return adoptRef(*new SVGNumberAnimator(m_attributeName, m_property.copyRef(), animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+}; >+ >+class SVGRectAnimator : public SVGPrimitivePropertyAnimator<FloatRect, SVGAnimationRectFunction> { >+ using Base = SVGPrimitivePropertyAnimator<FloatRect, SVGAnimationRectFunction>; >+ using Base::Base; >+ >+public: >+ static Ref<SVGAnimator> create(const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return adoptRef(*new SVGRectAnimator(attributeName, animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+ >+private: >+ RefPtr<SVGAnimator> createSibling(AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) final >+ { >+ return adoptRef(*new SVGRectAnimator(m_attributeName, m_property.copyRef(), animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+}; >+ >+class SVGStringAnimator : public SVGPrimitivePropertyAnimator<String, SVGAnimationStringFunction> { >+ using Base = SVGPrimitivePropertyAnimator<String, SVGAnimationStringFunction>; >+ using Base::Base; >+ >+public: >+ static Ref<SVGAnimator> create(const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return adoptRef(*new SVGStringAnimator(attributeName, animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+ >+private: >+ RefPtr<SVGAnimator> createSibling(AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) final >+ { >+ return adoptRef(*new SVGStringAnimator(m_attributeName, m_property.copyRef(), animationMode, calcMode, isAccumulated, isAdditive)); >+ } >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGPropertyAnimator.h b/Source/WebCore/svg/properties/SVGPropertyAnimator.h >index 8b137891791..ee8cb252484 100644 >--- a/Source/WebCore/svg/properties/SVGPropertyAnimator.h >+++ b/Source/WebCore/svg/properties/SVGPropertyAnimator.h >@@ -1 +1,104 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ > >+#pragma once >+ >+#include "CSSComputedStyleDeclaration.h" >+#include "CSSPropertyParser.h" >+#include "SVGAnimator.h" >+#include "SVGElement.h" >+ >+namespace WebCore { >+ >+template<typename AnimationFunction> >+class SVGPropertyAnimator : public SVGAnimator { >+public: >+ bool isDiscrete() const override { return m_function.isDiscrete(); } >+ >+ void setFromAndToValues(SVGElement* targetElement, const String& from, const String& to) override >+ { >+ m_function.setFromAndToValues(targetElement, adjustForInheritance(targetElement, from), adjustForInheritance(targetElement, to)); >+ } >+ >+ void setFromAndByValues(SVGElement* targetElement, const String& from, const String& by) override >+ { >+ m_function.setFromAndByValues(targetElement, from, by); >+ } >+ >+ void setToAtEndOfDurationValue(const String& toAtEndOfDuration) override >+ { >+ m_function.setToAtEndOfDurationValue(toAtEndOfDuration); >+ } >+ >+protected: >+ template<typename... Arguments> >+ SVGPropertyAnimator(const QualifiedName& attributeName, Arguments&&... arguments) >+ : SVGAnimator(attributeName) >+ , m_function(std::forward<Arguments>(arguments)...) >+ { >+ } >+ >+ void stop(SVGElement* targetElement) override >+ { >+ removeAnimatedStyleProperty(targetElement); >+ } >+ >+ float calculateDistance(SVGElement* targetElement, const String& from, const String& to) const override >+ { >+ return m_function.calculateDistance(targetElement, from, to); >+ } >+ >+ String adjustForInheritance(SVGElement* targetElement, const String& value) const >+ { >+ static NeverDestroyed<const AtomicString> inherit("inherit", AtomicString::ConstructFromLiteral); >+ return value == inherit ? computeInheritedCSSPropertyValue(targetElement) : value; >+ } >+ >+ String computeCSSPropertyValue(SVGElement* targetElement, CSSPropertyID id) const >+ { >+ ASSERT(targetElement); >+ >+ // Don't include any properties resulting from CSS Transitions/Animations or SMIL animations, as we want to retrieve the "base value". >+ targetElement->setUseOverrideComputedStyle(true); >+ RefPtr<CSSValue> value = ComputedStyleExtractor(targetElement).propertyValue(id); >+ targetElement->setUseOverrideComputedStyle(false); >+ return value ? value->cssText() : String(); >+ } >+ >+ String computeInheritedCSSPropertyValue(SVGElement* targetElement) const >+ { >+ ASSERT(targetElement); >+ auto parent = makeRefPtr(targetElement->parentElement()); >+ if (!parent || !parent->isSVGElement()) >+ return emptyString(); >+ >+ SVGElement& svgParent = downcast<SVGElement>(*parent); >+ return computeCSSPropertyValue(&svgParent, cssPropertyID(m_attributeName.localName())); >+ } >+ >+ AnimationFunction m_function; >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGPropertyAnimatorCreator.h b/Source/WebCore/svg/properties/SVGPropertyAnimatorCreator.h >index 8b137891791..533c859ab1d 100644 >--- a/Source/WebCore/svg/properties/SVGPropertyAnimatorCreator.h >+++ b/Source/WebCore/svg/properties/SVGPropertyAnimatorCreator.h >@@ -1 +1,173 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ > >+#pragma once >+ >+#include "SVGNames.h" >+#include "SVGPrimitivePropertyAnimatorImpl.h" >+#include "SVGValuePropertyAnimatorImpl.h" >+#include "SVGValuePropertyListAnimatorImpl.h" >+ >+namespace WebCore { >+ >+class SVGPropertyAnimatorCreator { >+public: >+ SVGPropertyAnimatorCreator() = default; >+ >+ static bool isKnownAttribute(const QualifiedName& attributeName) >+ { >+ return attributeAnimatorCreator().contains(attributeName.impl()); >+ } >+ >+ RefPtr<SVGAnimator> createAnimator(const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ auto creatorIterator = attributeAnimatorCreator().find(attributeName.impl()); >+ if (creatorIterator == attributeAnimatorCreator().end()) >+ return nullptr; >+ >+ auto addResult = m_attributeAnimator.ensure(attributeName, [&creatorIterator, &attributeName, animationMode, calcMode, isAccumulated, isAdditive]() { >+ return creatorIterator->value(attributeName, animationMode, calcMode, isAccumulated, isAdditive); >+ }); >+ >+ if (addResult.isNewEntry) >+ return addResult.iterator->value.copyRef(); >+ >+ return addResult.iterator->value->createSibling(animationMode, calcMode, isAccumulated, isAdditive); >+ } >+ >+ void animatorWillBeDeleted(const Ref<SVGAnimator>&) >+ { >+ // FIXME: Delete the entry of SVGAnimator from m_attributeAnimator. >+ } >+ >+private: >+ using AttributeAnimatorCreator = HashMap< >+ QualifiedName::QualifiedNameImpl*, >+ std::function<Ref<SVGAnimator>(const QualifiedName&, AnimationMode, CalcMode, bool, bool)> >+ >; >+ >+ static const AttributeAnimatorCreator& attributeAnimatorCreator() >+ { >+ static NeverDestroyed<AttributeAnimatorCreator> map = AttributeAnimatorCreator({ >+ { SVGNames::colorAttr->impl(), SVGPropertyAnimatorCreator::createColorAnimator }, >+ { SVGNames::fillAttr->impl(), SVGPropertyAnimatorCreator::createColorAnimator }, >+ { SVGNames::flood_colorAttr->impl(), SVGPropertyAnimatorCreator::createColorAnimator }, >+ { SVGNames::lighting_colorAttr->impl(), SVGPropertyAnimatorCreator::createColorAnimator }, >+ { SVGNames::stop_colorAttr->impl(), SVGPropertyAnimatorCreator::createColorAnimator }, >+ { SVGNames::strokeAttr->impl(), SVGPropertyAnimatorCreator::createColorAnimator }, >+ >+ { SVGNames::font_sizeAttr->impl(), SVGPropertyAnimatorCreator::createLengthAnimator }, >+ { SVGNames::kerningAttr->impl(), SVGPropertyAnimatorCreator::createLengthAnimator }, >+ { SVGNames::letter_spacingAttr->impl(), SVGPropertyAnimatorCreator::createLengthAnimator }, >+ { SVGNames::stroke_dashoffsetAttr->impl(), SVGPropertyAnimatorCreator::createLengthAnimator }, >+ { SVGNames::stroke_widthAttr->impl(), SVGPropertyAnimatorCreator::createLengthAnimator }, >+ { SVGNames::word_spacingAttr->impl(), SVGPropertyAnimatorCreator::createLengthAnimator }, >+ >+ { SVGNames::stroke_dasharrayAttr->impl(), SVGPropertyAnimatorCreator::createLengthListAnimator }, >+ >+ { SVGNames::fill_opacityAttr->impl(), SVGPropertyAnimatorCreator::createNumberAnimator }, >+ { SVGNames::flood_opacityAttr->impl(), SVGPropertyAnimatorCreator::createNumberAnimator }, >+ { SVGNames::opacityAttr->impl(), SVGPropertyAnimatorCreator::createNumberAnimator }, >+ { SVGNames::stop_opacityAttr->impl(), SVGPropertyAnimatorCreator::createNumberAnimator }, >+ { SVGNames::stroke_miterlimitAttr->impl(), SVGPropertyAnimatorCreator::createNumberAnimator }, >+ { SVGNames::stroke_opacityAttr->impl(), SVGPropertyAnimatorCreator::createNumberAnimator }, >+ >+ { SVGNames::clipAttr->impl(), SVGPropertyAnimatorCreator::createRectAnimator }, >+ >+ { SVGNames::alignment_baselineAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::baseline_shiftAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::buffered_renderingAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::clip_pathAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::clip_ruleAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::color_interpolationAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::color_interpolation_filtersAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::color_profileAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::color_renderingAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::cursorAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::displayAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::dominant_baselineAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::fill_ruleAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::filterAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::font_familyAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::font_stretchAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::font_styleAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::font_variantAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::font_weightAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::image_renderingAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::marker_endAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::marker_midAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::marker_startAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::maskAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::mask_typeAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::overflowAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::paint_orderAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::pointer_eventsAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::shape_renderingAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::stroke_linecapAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::stroke_linejoinAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::text_anchorAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::text_decorationAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::text_renderingAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::vector_effectAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator }, >+ { SVGNames::visibilityAttr->impl(), SVGPropertyAnimatorCreator::createStringAnimator } >+ }); >+ return map; >+ } >+ >+ static Ref<SVGAnimator> createColorAnimator(const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return SVGColorAnimator::create(attributeName, animationMode, calcMode, isAccumulated, isAdditive); >+ } >+ >+ static Ref<SVGAnimator> createLengthAnimator(const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return SVGLengthAnimator::create(attributeName, animationMode, calcMode, isAccumulated, isAdditive); >+ } >+ >+ static Ref<SVGAnimator> createLengthListAnimator(const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return SVGLengthListAnimator::create(attributeName, animationMode, calcMode, isAccumulated, isAdditive); >+ } >+ >+ static Ref<SVGAnimator> createNumberAnimator(const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return SVGNumberAnimator::create(attributeName, animationMode, calcMode, isAccumulated, isAdditive); >+ } >+ >+ static Ref<SVGAnimator> createRectAnimator(const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return SVGRectAnimator::create(attributeName, animationMode, calcMode, isAccumulated, isAdditive); >+ } >+ >+ static Ref<SVGAnimator> createStringAnimator(const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return SVGStringAnimator::create(attributeName, animationMode, calcMode, isAccumulated, isAdditive); >+ } >+ >+ using AttributeAnimator = HashMap<QualifiedName, Ref<SVGAnimator>>; >+ AttributeAnimator m_attributeAnimator; >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGValuePropertyAnimator.h b/Source/WebCore/svg/properties/SVGValuePropertyAnimator.h >index 8b137891791..cac280bb1c8 100644 >--- a/Source/WebCore/svg/properties/SVGValuePropertyAnimator.h >+++ b/Source/WebCore/svg/properties/SVGValuePropertyAnimator.h >@@ -1 +1,71 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ > >+#pragma once >+ >+#include "SVGPropertyAnimator.h" >+ >+namespace WebCore { >+ >+template<typename PropertyType, typename AnimationFunction> >+class SVGValuePropertyAnimator : public SVGPropertyAnimator<AnimationFunction> { >+ using Base = SVGPropertyAnimator<AnimationFunction>; >+ using Base::Base; >+ using Base::applyAnimatedStylePropertyChange; >+ using Base::m_function; >+ >+public: >+ void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) override >+ { >+ m_function.progress(targetElement, percentage, repeatCount, m_property->value()); >+ } >+ >+ void apply(SVGElement* targetElement) override >+ { >+ applyAnimatedStylePropertyChange(targetElement, m_property->valueAsString()); >+ } >+ >+protected: >+ using Base::computeCSSPropertyValue; >+ using Base::m_attributeName; >+ >+ template<typename... Arguments> >+ SVGValuePropertyAnimator(const QualifiedName& attributeName, Arguments&&... arguments) >+ : Base(attributeName, std::forward<Arguments>(arguments)...) >+ , m_property(PropertyType::create()) >+ { >+ } >+ >+ template<typename... Arguments> >+ SVGValuePropertyAnimator(const QualifiedName& attributeName, Ref<PropertyType>&& property, Arguments&&... arguments) >+ : Base(attributeName, std::forward<Arguments>(arguments)...) >+ , m_property(WTFMove(property)) >+ { >+ } >+ >+ Ref<PropertyType> m_property; >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGValuePropertyAnimatorImpl.h b/Source/WebCore/svg/properties/SVGValuePropertyAnimatorImpl.h >index 8b137891791..c55941db3c3 100644 >--- a/Source/WebCore/svg/properties/SVGValuePropertyAnimatorImpl.h >+++ b/Source/WebCore/svg/properties/SVGValuePropertyAnimatorImpl.h >@@ -1 +1,60 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ > >+#pragma once >+ >+#include "SVGAnimationFunction.h" >+#include "SVGValuePropertyAnimator.h" >+ >+namespace WebCore { >+ >+class SVGLengthAnimator final : public SVGValuePropertyAnimator<SVGLength, SVGAnimationLengthFunction> { >+ using Base = SVGValuePropertyAnimator<SVGLength, SVGAnimationLengthFunction>; >+ using Base::Base; >+ using Base::m_attributeName; >+ using Base::m_property; >+ >+public: >+ static Ref<SVGAnimator> create(const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return adoptRef(*new SVGLengthAnimator(attributeName, animationMode, calcMode, isAccumulated, isAdditive, LengthModeOther)); >+ } >+ >+ void start(SVGElement* targetElement) override >+ { >+ String baseValue = computeCSSPropertyValue(targetElement, cssPropertyID(m_attributeName.localName())); >+ SVGLengthValue value(LengthModeOther); >+ if (!value.setValueAsString(baseValue).hasException()) >+ m_property->setValue(value); >+ } >+ >+private: >+ RefPtr<SVGAnimator> createSibling(AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) final >+ { >+ return adoptRef(*new SVGLengthAnimator(m_attributeName, m_property.copyRef(), animationMode, calcMode, isAccumulated, isAdditive, LengthModeOther)); >+ } >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGValuePropertyListAnimator.h b/Source/WebCore/svg/properties/SVGValuePropertyListAnimator.h >index 8b137891791..2eb36a2c078 100644 >--- a/Source/WebCore/svg/properties/SVGValuePropertyListAnimator.h >+++ b/Source/WebCore/svg/properties/SVGValuePropertyListAnimator.h >@@ -1 +1,71 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ > >+#pragma once >+ >+#include "SVGPropertyAnimator.h" >+ >+namespace WebCore { >+ >+template<typename ListType, typename AnimationFunction> >+class SVGValuePropertyListAnimator : public SVGPropertyAnimator<AnimationFunction> { >+ using Base = SVGPropertyAnimator<AnimationFunction>; >+ using Base::Base; >+ using Base::applyAnimatedStylePropertyChange; >+ using Base::m_function; >+ >+public: >+ void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) override >+ { >+ m_function.progress(targetElement, percentage, repeatCount, m_list); >+ } >+ >+ void apply(SVGElement* targetElement) override >+ { >+ applyAnimatedStylePropertyChange(targetElement, m_list->valueAsString()); >+ } >+ >+protected: >+ using Base::computeCSSPropertyValue; >+ using Base::m_attributeName; >+ >+ template<typename... Arguments> >+ SVGValuePropertyListAnimator(const QualifiedName& attributeName, Arguments&&... arguments) >+ : Base(attributeName, std::forward<Arguments>(arguments)...) >+ , m_list(ListType::create()) >+ { >+ } >+ >+ template<typename... Arguments> >+ SVGValuePropertyListAnimator(const QualifiedName& attributeName, RefPtr<ListType>&& list, Arguments&&... arguments) >+ : Base(attributeName, std::forward<Arguments>(arguments)...) >+ , m_list(WTFMove(list)) >+ { >+ } >+ >+ RefPtr<ListType> m_list; >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGValuePropertyListAnimatorImpl.h b/Source/WebCore/svg/properties/SVGValuePropertyListAnimatorImpl.h >index 8b137891791..f4e6ca4e2dc 100644 >--- a/Source/WebCore/svg/properties/SVGValuePropertyListAnimatorImpl.h >+++ b/Source/WebCore/svg/properties/SVGValuePropertyListAnimatorImpl.h >@@ -1 +1,59 @@ >+/* >+ * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ > >+#pragma once >+ >+#include "SVGAnimationFunction.h" >+#include "SVGValuePropertyListAnimator.h" >+ >+namespace WebCore { >+ >+class SVGLengthListAnimator final : public SVGValuePropertyListAnimator<SVGLengthList, SVGAnimationLengthListFunction> { >+ using Base = SVGValuePropertyListAnimator<SVGLengthList, SVGAnimationLengthListFunction>; >+ using Base::Base; >+ using Base::m_attributeName; >+ using Base::m_list; >+ >+public: >+ static Ref<SVGAnimator> create(const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ { >+ return adoptRef(*new SVGLengthListAnimator(attributeName, animationMode, calcMode, isAccumulated, isAdditive, LengthModeOther)); >+ } >+ >+ void start(SVGElement* targetElement) override >+ { >+ String baseValue = computeCSSPropertyValue(targetElement, cssPropertyID(m_attributeName.localName())); >+ if (!m_list->parse(baseValue)) >+ m_list->clearItems(); >+ } >+ >+private: >+ RefPtr<SVGAnimator> createSibling(AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) final >+ { >+ return adoptRef(*new SVGLengthListAnimator(m_attributeName, m_list.copyRef(), animationMode, calcMode, isAccumulated, isAdditive, LengthModeOther)); >+ } >+}; >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 191237
:
353808
|
353812
|
353815
|
353817
|
353818
|
353820
|
353824
|
353825
|
355382
|
355386
|
355388
|
355393
|
355568
|
355574
|
355575
|
355577
|
355580
|
355582
|
355585
|
355666
|
355672
|
355693
|
355699
|
355711
|
355752
|
355777
|
355820
|
356333
|
356334
|
356338
|
356340
|
356342
|
356344
|
356346
|
356351
|
356352
|
356358
|
356360
|
356380
|
356497
|
356500
|
356507
|
356579
|
356607
|
356728
|
356729
|
356730
|
356731
|
356732
|
356733
|
356752
|
356810
|
356811
|
356879
|
356880
|
356881
|
356882
|
356883
|
356884
|
356885
|
356887
|
356888
|
356889
|
356892
|
356895
|
356896
|
359721
|
359735
|
359747
|
363581
|
363595
|
363613
|
363690
|
364172
|
364180
|
366512
|
366557
|
366636