WebKit Bugzilla
Attachment 356507 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]
7-SVGAnimationFunction
7-SVGAnimationFunction.patch (text/plain), 54.00 KB, created by
Said Abou-Hallawa
on 2018-12-04 09:45:02 PST
(
hide
)
Description:
7-SVGAnimationFunction
Filename:
MIME Type:
Creator:
Said Abou-Hallawa
Created:
2018-12-04 09:45:02 PST
Size:
54.00 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 2e6fa5f2965..c3e491fcb50 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,72 @@ >+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 SVGAnimationFunction is responsible for progressing an animated >+ property. The type of animation function can be: >+ >+ 1. Discrete: where the value of the animated property can be one of two. >+ The animation function will progress to the second value if the >+ percentage is greater than 0.5. >+ >+ 2. Additive: where the value of the animated property sweeps on a range >+ between two values 'from' and 'to'. The current value can be calculated >+ like this: >+ value = (to - from) * percentage + from; >+ >+ 3. AdditiveList: this is the case where, the animated property, 'from' >+ and 'to' values are all of SVGList types. Usually the calculation >+ happens per item using the same formula used for the 'Additive' >+ animation function. >+ >+ The plan is use the SVGAnimationFunction by the SVG animator and apply the >+ results on the SVG animated properties and the SVG style properties. >+ >+ Note: most of the code in the Impl files are copied from the existing >+ animator code, for example SVGAnimationLengthFunction::progress() were >+ copied from SVGAnimatedLengthAnimator::calculateAnimatedValue(). >+ >+ * Sources.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ * svg/properties/SVGAnimationAdditiveFunction.h: Added. >+ (WebCore::SVGAnimationAdditiveFunction::SVGAnimationAdditiveFunction): >+ (WebCore::SVGAnimationAdditiveFunction::progress): >+ * svg/properties/SVGAnimationAdditiveListFunction.h: Added. >+ (WebCore::SVGAnimationAdditiveListFunction::SVGAnimationAdditiveListFunction): >+ (WebCore::SVGAnimationAdditiveListFunction::toAtEndOfDuration const): >+ (WebCore::SVGAnimationAdditiveListFunction::adjustAnimatedList): >+ * svg/properties/SVGAnimationAdditiveListFunctionImpl.h: Added. >+ (WebCore::SVGAnimationLengthListFunction::SVGAnimationLengthListFunction): >+ (WebCore::SVGAnimationLengthListFunction::progress): >+ (WebCore::SVGAnimationNumberListFunction::progress): >+ (WebCore::SVGAnimationPointListFunction::progress): >+ (WebCore::SVGAnimationTransformListFunction::progress): >+ * svg/properties/SVGAnimationAdditiveValueFunction.h: Added. >+ (WebCore::SVGAnimationAdditiveValueFunction::toAtEndOfDuration const): >+ * svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp: Added. >+ (WebCore::SVGAnimationColorFunction::colorFromString): >+ * svg/properties/SVGAnimationAdditiveValueFunctionImpl.h: Added. >+ (WebCore::SVGAnimationNumberFunction::progress): >+ (WebCore::SVGAnimationIntegerFunction::progress): >+ (WebCore::SVGAnimationRectFunction::progress): >+ (WebCore::SVGAnimationColorFunction::progress): >+ (WebCore::SVGAnimationAngleFunction::progress): >+ (WebCore::SVGAnimationLengthFunction::SVGAnimationLengthFunction): >+ (WebCore::SVGAnimationLengthFunction::progress): >+ (WebCore::SVGAnimationPathSegListFunction::progress): >+ * svg/properties/SVGAnimationDiscreteFunction.h: Added. >+ (WebCore::SVGAnimationDiscreteFunction::SVGAnimationDiscreteFunction): >+ (WebCore::SVGAnimationDiscreteFunction::progress): >+ * svg/properties/SVGAnimationDiscreteFunctionImpl.h: Added. >+ * svg/properties/SVGAnimationFunction.h: Added. >+ (WebCore::SVGAnimationFunction::isDiscrete const): >+ (WebCore::SVGAnimationFunction::calculateDistance const): >+ (WebCore::SVGAnimationFunction::SVGAnimationFunction): >+ (WebCore::SVGAnimationFunction::addFromAndToValues): >+ > 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 e745cd5a009..883714d6e68 100644 >--- a/Source/WebCore/Sources.txt >+++ b/Source/WebCore/Sources.txt >@@ -2342,6 +2342,7 @@ svg/graphics/filters/SVGFilterBuilder.cpp > > svg/properties/SVGAnimatedPathSegListPropertyTearOff.cpp > svg/properties/SVGAnimatedProperty.cpp >+svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp > > workers/AbstractWorker.cpp > workers/DedicatedWorkerGlobalScope.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 703fafc756f..841415721df 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -9333,6 +9333,15 @@ > 72227A8121B6DC6E008EC3E4 /* SVGAnimatedPrimitiveProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPrimitiveProperty.h; sourceTree = "<group>"; }; > 72227A8221B6DC6F008EC3E4 /* SVGAnimatedPropertyList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyList.h; sourceTree = "<group>"; }; > 72227A8321B6DC6F008EC3E4 /* SVGAnimatedValueProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedValueProperty.h; sourceTree = "<group>"; }; >+ 72227A8421B6EAA0008EC3E4 /* SVGAnimationAdditiveValueFunctionImpl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimationAdditiveValueFunctionImpl.cpp; sourceTree = "<group>"; }; >+ 72227A8521B6EAA1008EC3E4 /* SVGAnimationDiscreteFunctionImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimationDiscreteFunctionImpl.h; sourceTree = "<group>"; }; >+ 72227A8621B6EAA1008EC3E4 /* SVGAnimationAdditiveListFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimationAdditiveListFunction.h; sourceTree = "<group>"; }; >+ 72227A8721B6EAA2008EC3E4 /* SVGAnimationAdditiveValueFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimationAdditiveValueFunction.h; sourceTree = "<group>"; }; >+ 72227A8821B6EAA2008EC3E4 /* SVGAnimationAdditiveValueFunctionImpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimationAdditiveValueFunctionImpl.h; sourceTree = "<group>"; }; >+ 72227A8921B6EAA3008EC3E4 /* SVGAnimationFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimationFunction.h; sourceTree = "<group>"; }; >+ 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>"; }; > 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>"; }; >@@ -15777,6 +15786,15 @@ > 08525E621278C00100A84778 /* SVGAnimatedStaticPropertyTearOff.h */, > 085A15921289A8DD002710E3 /* SVGAnimatedTransformListPropertyTearOff.h */, > 72227A8321B6DC6F008EC3E4 /* SVGAnimatedValueProperty.h */, >+ 72227A8C21B6EAA4008EC3E4 /* SVGAnimationAdditiveFunction.h */, >+ 72227A8621B6EAA1008EC3E4 /* SVGAnimationAdditiveListFunction.h */, >+ 72227A8B21B6EAA4008EC3E4 /* SVGAnimationAdditiveListFunctionImpl.h */, >+ 72227A8721B6EAA2008EC3E4 /* SVGAnimationAdditiveValueFunction.h */, >+ 72227A8421B6EAA0008EC3E4 /* SVGAnimationAdditiveValueFunctionImpl.cpp */, >+ 72227A8821B6EAA2008EC3E4 /* SVGAnimationAdditiveValueFunctionImpl.h */, >+ 72227A8A21B6EAA3008EC3E4 /* SVGAnimationDiscreteFunction.h */, >+ 72227A8521B6EAA1008EC3E4 /* SVGAnimationDiscreteFunctionImpl.h */, >+ 72227A8921B6EAA3008EC3E4 /* SVGAnimationFunction.h */, > 55FA7FEF210FA386005AEFE7 /* SVGAttribute.h */, > 55FA7FF4210FB688005AEFE7 /* SVGAttributeAccessor.h */, > 55346AF021150FAF0059BCDD /* SVGAttributeOwnerProxy.h */, >diff --git a/Source/WebCore/svg/properties/SVGAnimationAdditiveFunction.h b/Source/WebCore/svg/properties/SVGAnimationAdditiveFunction.h >index 8b137891791..d47ffd518fb 100644 >--- a/Source/WebCore/svg/properties/SVGAnimationAdditiveFunction.h >+++ b/Source/WebCore/svg/properties/SVGAnimationAdditiveFunction.h >@@ -1 +1,76 @@ >+/* >+ * 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" >+ >+namespace WebCore { >+ >+class SVGAnimationAdditiveFunction : public SVGAnimationFunction { >+public: >+ SVGAnimationAdditiveFunction(AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) >+ : SVGAnimationFunction(animationMode) >+ , m_calcMode(calcMode) >+ , m_isAccumulated(isAccumulated) >+ , m_isAdditive(isAdditive) >+ { >+ } >+ >+ void setFromAndByValues(SVGElement* targetElement, const String& from, const String& by) override >+ { >+ setFromAndToValues(targetElement, from, by); >+ addFromAndToValues(targetElement); >+ } >+ >+ void setToAtEndOfDurationValue(const String&) override >+ { >+ ASSERT_NOT_REACHED(); >+ } >+ >+protected: >+ float progress(float percentage, unsigned repeatCount, float from, float to, float toAtEndOfDuration, float animated) >+ { >+ float number; >+ if (m_calcMode == CalcMode::Discrete) >+ number = percentage < 0.5 ? from : to; >+ else >+ number = (to - from) * percentage + from; >+ >+ if (m_isAccumulated && repeatCount) >+ number += toAtEndOfDuration * repeatCount; >+ >+ if (m_isAdditive && m_animationMode != AnimationMode::To) >+ number += animated; >+ >+ return number; >+ } >+ >+ CalcMode m_calcMode; >+ bool m_isAccumulated; >+ bool m_isAdditive; >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGAnimationAdditiveListFunction.h b/Source/WebCore/svg/properties/SVGAnimationAdditiveListFunction.h >index 8b137891791..164b9e27619 100644 >--- a/Source/WebCore/svg/properties/SVGAnimationAdditiveListFunction.h >+++ b/Source/WebCore/svg/properties/SVGAnimationAdditiveListFunction.h >@@ -1 +1,70 @@ >+/* >+ * 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 "SVGAnimationAdditiveFunction.h" >+ >+namespace WebCore { >+ >+template<typename ListType> >+class SVGAnimationAdditiveListFunction : public SVGAnimationAdditiveFunction { >+public: >+ template<typename... Arguments> >+ SVGAnimationAdditiveListFunction(AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive, Arguments&&... arguments) >+ : SVGAnimationAdditiveFunction(animationMode, calcMode, isAccumulated, isAdditive) >+ , m_from(ListType::create(std::forward<Arguments>(arguments)...)) >+ , m_to(ListType::create(std::forward<Arguments>(arguments)...)) >+ , m_toAtEndOfDuration(ListType::create(std::forward<Arguments>(arguments)...)) >+ { >+ } >+ >+protected: >+ const Ref<ListType>& toAtEndOfDuration() const { return !m_toAtEndOfDuration->isEmpty() ? m_toAtEndOfDuration : m_to; } >+ >+ bool adjustAnimatedList(AnimationMode animationMode, float percentage, RefPtr<ListType>& animated, bool resizeAnimatedIfNeeded = true) >+ { >+ if (!m_to->numberOfItems()) >+ return false; >+ >+ if (m_from->numberOfItems() && m_from->size() != m_to->size()) { >+ if (percentage >= 0.5) >+ *animated = m_to; >+ else if (animationMode != AnimationMode::To) >+ *animated = m_from; >+ return false; >+ } >+ >+ if (resizeAnimatedIfNeeded && animated->size() < m_to->size()) >+ animated->resize(m_to->size()); >+ return true; >+ } >+ >+ Ref<ListType> m_from; >+ Ref<ListType> m_to; >+ Ref<ListType> m_toAtEndOfDuration; >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGAnimationAdditiveListFunctionImpl.h b/Source/WebCore/svg/properties/SVGAnimationAdditiveListFunctionImpl.h >index 8b137891791..5948cd8ee1b 100644 >--- a/Source/WebCore/svg/properties/SVGAnimationAdditiveListFunctionImpl.h >+++ b/Source/WebCore/svg/properties/SVGAnimationAdditiveListFunctionImpl.h >@@ -1 +1,277 @@ >+/* >+ * 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 "SVGAngleValue.h" >+#include "SVGAnimationAdditiveListFunction.h" >+#include "SVGLengthContext.h" >+#include "SVGLengthList.h" >+#include "SVGLengthValue.h" >+#include "SVGNumberList.h" >+#include "SVGPointList.h" >+#include "SVGTransformDistance.h" >+#include "SVGTransformList.h" >+ >+namespace WebCore { >+ >+class SVGElement; >+ >+class SVGAnimationLengthListFunction : public SVGAnimationAdditiveListFunction<SVGLengthList> { >+ using Base = SVGAnimationAdditiveListFunction<SVGLengthList>; >+ >+public: >+ SVGAnimationLengthListFunction(AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive, SVGLengthMode lengthMode) >+ : Base(animationMode, calcMode, isAccumulated, isAdditive, lengthMode) >+ { >+ } >+ >+ void setFromAndToValues(SVGElement*, const String& from, const String& to) override >+ { >+ m_from->parse(from); >+ m_to->parse(to); >+ } >+ >+ void setToAtEndOfDurationValue(const String& toAtEndOfDuration) override >+ { >+ m_toAtEndOfDuration->parse(toAtEndOfDuration); >+ } >+ >+ void progress(SVGElement* targetElement, float percentage, unsigned repeatCount, RefPtr<SVGLengthList>& animated) >+ { >+ if (!adjustAnimatedList(m_animationMode, percentage, animated)) >+ return; >+ >+ const Vector<Ref<SVGLength>>& fromItems = m_animationMode == AnimationMode::To ? animated->items() : m_from->items(); >+ const Vector<Ref<SVGLength>>& toItems = m_to->items(); >+ const Vector<Ref<SVGLength>>& toAtEndOfDurationItems = toAtEndOfDuration()->items(); >+ Vector<Ref<SVGLength>>& animatedItems = animated->items(); >+ SVGLengthMode lengthMode = animated->lengthMode(); >+ >+ SVGLengthContext lengthContext(targetElement); >+ for (unsigned i = 0; i < toItems.size(); ++i) { >+ SVGLengthType unitType = (i < fromItems.size() && percentage < 0.5 ? fromItems : toItems)[i]->value().unitType(); >+ >+ float from = i < fromItems.size() ? fromItems[i]->value().value(lengthContext) : 0; >+ float to = toItems[i]->value().value(lengthContext); >+ float toAtEndOfDuration = i < toAtEndOfDurationItems.size() ? toAtEndOfDurationItems[i]->value().value(lengthContext) : 0; >+ float value = animatedItems[i]->value().value(lengthContext); >+ >+ value = Base::progress(percentage, repeatCount, from, to, toAtEndOfDuration, value); >+ animatedItems[i]->value().setValue(lengthContext, value, lengthMode, unitType); >+ } >+ } >+ >+private: >+ void addFromAndToValues(SVGElement* targetElement) override >+ { >+ const Vector<Ref<SVGLength>>& fromItems = m_from->items(); >+ const Vector<Ref<SVGLength>>& toItems = m_to->items(); >+ >+ if (!fromItems.size() || fromItems.size() != toItems.size()) >+ return; >+ >+ SVGLengthContext lengthContext(targetElement); >+ for (unsigned i = 0; i < fromItems.size(); ++i) { >+ const SVGLengthValue& fromValue = fromItems[i]->value(); >+ SVGLengthValue& toValue = toItems[i]->value(); >+ toValue.setValue(toValue.value(lengthContext) + fromValue.value(lengthContext), lengthContext); >+ } >+ } >+}; >+ >+class SVGAnimationNumberListFunction : public SVGAnimationAdditiveListFunction<SVGNumberList> { >+public: >+ using Base = SVGAnimationAdditiveListFunction<SVGNumberList>; >+ using Base::Base; >+ >+ void setFromAndToValues(SVGElement*, const String& from, const String& to) override >+ { >+ m_from->parse(from); >+ m_to->parse(to); >+ } >+ >+ void setToAtEndOfDurationValue(const String& toAtEndOfDuration) override >+ { >+ m_toAtEndOfDuration->parse(toAtEndOfDuration); >+ } >+ >+ void progress(SVGElement*, float percentage, unsigned repeatCount, RefPtr<SVGNumberList>& animated) >+ { >+ if (!adjustAnimatedList(m_animationMode, percentage, animated)) >+ return; >+ >+ const Vector<Ref<SVGNumber>>& fromItems = m_animationMode == AnimationMode::To ? animated->items() : m_from->items(); >+ const Vector<Ref<SVGNumber>>& toItems = m_to->items(); >+ const Vector<Ref<SVGNumber>>& toAtEndOfDurationItems = toAtEndOfDuration()->items(); >+ Vector<Ref<SVGNumber>>& animatedItems = animated->items(); >+ >+ for (unsigned i = 0; i < toItems.size(); ++i) { >+ float from = i < fromItems.size() ? fromItems[i]->value() : 0; >+ float to = toItems[i]->value(); >+ float toAtEndOfDuration = i < toAtEndOfDurationItems.size() ? toAtEndOfDurationItems[i]->value() : 0; >+ >+ float& value = animatedItems[i]->value(); >+ value = Base::progress(percentage, repeatCount, from, to, toAtEndOfDuration, value); >+ } >+ } >+ >+private: >+ void addFromAndToValues(SVGElement*) override >+ { >+ const Vector<Ref<SVGNumber>>& fromItems = m_from->items(); >+ Vector<Ref<SVGNumber>>& toItems = m_to->items(); >+ >+ if (!fromItems.size() || fromItems.size() != toItems.size()) >+ return; >+ >+ for (unsigned i = 0; i < fromItems.size(); ++i) >+ toItems[i]->setValue(fromItems[i]->value() + toItems[i]->value()); >+ } >+}; >+ >+class SVGAnimationPointListFunction : public SVGAnimationAdditiveListFunction<SVGPointList> { >+public: >+ using Base = SVGAnimationAdditiveListFunction<SVGPointList>; >+ using Base::Base; >+ >+ void setFromAndToValues(SVGElement*, const String& from, const String& to) override >+ { >+ m_from->parse(from); >+ m_to->parse(to); >+ } >+ >+ void setToAtEndOfDurationValue(const String& toAtEndOfDuration) override >+ { >+ m_toAtEndOfDuration->parse(toAtEndOfDuration); >+ } >+ >+ void progress(SVGElement*, float percentage, unsigned repeatCount, RefPtr<SVGPointList>& animated) >+ { >+ if (!adjustAnimatedList(m_animationMode, percentage, animated)) >+ return; >+ >+ const Vector<Ref<SVGPoint>>& fromItems = m_animationMode == AnimationMode::To ? animated->items() : m_from->items(); >+ const Vector<Ref<SVGPoint>>& toItems = m_to->items(); >+ const Vector<Ref<SVGPoint>>& toAtEndOfDurationItems = toAtEndOfDuration()->items(); >+ Vector<Ref<SVGPoint>>& animatedItems = animated->items(); >+ >+ for (unsigned i = 0; i < toItems.size(); ++i) { >+ FloatPoint from = i < fromItems.size() ? fromItems[i]->value() : FloatPoint(); >+ FloatPoint to = toItems[i]->value(); >+ FloatPoint toAtEndOfDuration = i < toAtEndOfDurationItems.size() ? toAtEndOfDurationItems[i]->value() : FloatPoint(); >+ FloatPoint& animated = animatedItems[i]->value(); >+ >+ float animatedX = Base::progress(percentage, repeatCount, from.x(), to.x(), toAtEndOfDuration.x(), animated.x()); >+ float animatedY = Base::progress(percentage, repeatCount, from.y(), to.y(), toAtEndOfDuration.y(), animated.y()); >+ >+ animated = { animatedX, animatedY }; >+ } >+ } >+ >+private: >+ void addFromAndToValues(SVGElement*) override >+ { >+ const Vector<Ref<SVGPoint>>& fromItems = m_from->items(); >+ Vector<Ref<SVGPoint>>& toItems = m_to->items(); >+ >+ if (!fromItems.size() || fromItems.size() != toItems.size()) >+ return; >+ >+ for (unsigned i = 0; i < fromItems.size(); ++i) >+ toItems[i]->setValue(fromItems[i]->value() + toItems[i]->value()); >+ } >+}; >+ >+class SVGAnimationTransformListFunction : public SVGAnimationAdditiveListFunction<SVGTransformList> { >+public: >+ using Base = SVGAnimationAdditiveListFunction<SVGTransformList>; >+ using Base::Base; >+ >+ void setFromAndToValues(SVGElement*, const String& from, const String& to) override >+ { >+ m_from->parse(from); >+ m_to->parse(to); >+ } >+ >+ void setToAtEndOfDurationValue(const String& toAtEndOfDuration) override >+ { >+ m_toAtEndOfDuration->parse(toAtEndOfDuration); >+ } >+ >+ void progress(SVGElement*, float percentage, unsigned repeatCount, RefPtr<SVGTransformList>& animated) >+ { >+ // Pass false to 'resizeAnimatedIfNeeded', as the special post-multiplication behavior of <animateTransform> needs to be respected below. >+ if (!adjustAnimatedList(m_animationMode, percentage, animated, false)) >+ return; >+ >+ // Spec: To animations provide specific functionality to get a smooth change from the underlying >+ // value to the âtoâ attribute value, which conflicts mathematically with the requirement for >+ // additive transform animations to be post-multiplied. As a consequence, in SVG 1.1 the behavior >+ // of to animations for âanimateTransformâ is undefined. >+ const Vector<Ref<SVGTransform>>& fromItems = m_from->items(); >+ const Vector<Ref<SVGTransform>>& toItems = m_to->items(); >+ const Vector<Ref<SVGTransform>>& toAtEndOfDurationItems = toAtEndOfDuration()->items(); >+ Vector<Ref<SVGTransform>>& animatedItems = animated->items(); >+ >+ // Never resize the animatedList to the m_to size, instead either clear the list >+ // or append to it. >+ if (!animatedItems.isEmpty() && (!m_isAdditive || m_animationMode == AnimationMode::To)) >+ animatedItems.clear(); >+ >+ auto fromItemsSize = fromItems.size(); >+ >+ static const AffineTransform zerosAffineTransform = { 0, 0, 0, 0, 0, 0 }; >+ const SVGTransformValue& to = toItems[0]->value(); >+ const SVGTransformValue zerosTransform = SVGTransformValue(to.type(), zerosAffineTransform); >+ >+ const SVGTransformValue& from = fromItemsSize ? fromItems[0]->value() : zerosTransform; >+ SVGTransformValue current = SVGTransformDistance(from, to).scaledDistance(percentage).addToSVGTransform(from); >+ >+ if (m_isAccumulated && repeatCount) { >+ const SVGTransformValue& toAtEndOfDuration = toAtEndOfDurationItems.size() ? toAtEndOfDurationItems[0]->value() : zerosTransform; >+ animatedItems.append(SVGTransform::create(SVGTransformDistance::addSVGTransforms(current, toAtEndOfDuration, repeatCount))); >+ } else >+ animatedItems.append(SVGTransform::create(current)); >+ } >+ >+private: >+ void addFromAndToValues(SVGElement*) override >+ { >+ const Vector<Ref<SVGTransform>>& fromItems = m_from->items(); >+ Vector<Ref<SVGTransform>>& toItems = m_to->items(); >+ >+ if (!fromItems.size() || fromItems.size() != toItems.size()) >+ return; >+ >+ ASSERT(fromItems.size() == 1); >+ const Ref<SVGTransform>& from = fromItems[0]; >+ Ref<SVGTransform>& to = toItems[0]; >+ >+ to->setValue(SVGTransformDistance::addSVGTransforms(from->value(), to->value())); >+ } >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunction.h b/Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunction.h >index 8b137891791..8709bcc81dc 100644 >--- a/Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunction.h >+++ b/Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunction.h >@@ -1 +1,45 @@ >+/* >+ * 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 "SVGAnimationAdditiveFunction.h" >+ >+namespace WebCore { >+ >+template<typename ValueType> >+class SVGAnimationAdditiveValueFunction : public SVGAnimationAdditiveFunction { >+public: >+ using SVGAnimationAdditiveFunction::SVGAnimationAdditiveFunction; >+ >+protected: >+ ValueType toAtEndOfDuration() const { return m_toAtEndOfDuration ? *m_toAtEndOfDuration : m_to; } >+ >+ ValueType m_from; >+ ValueType m_to; >+ std::optional<ValueType> m_toAtEndOfDuration; >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp b/Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp >index 8b137891791..26fc77093d3 100644 >--- a/Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp >+++ b/Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp >@@ -1 +1,44 @@ >+/* >+ * 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 "SVGAnimationAdditiveValueFunctionImpl.h" >+ >+namespace WebCore { >+ >+Color SVGAnimationColorFunction::colorFromString(SVGElement* targetElement, const String& string) >+{ >+ static NeverDestroyed<const AtomicString> currentColor("currentColor", AtomicString::ConstructFromLiteral); >+ >+ if (string != currentColor.get()) >+ return SVGPropertyTraits<Color>::fromString(string); >+ >+ if (auto* renderer = targetElement->renderer()) >+ return renderer->style().visitedDependentColor(CSSPropertyColor); >+ >+ return { }; >+} >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunctionImpl.h b/Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunctionImpl.h >index 8b137891791..4b8a8705f69 100644 >--- a/Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunctionImpl.h >+++ b/Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunctionImpl.h >@@ -1 +1,331 @@ >+/* >+ * 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 "SVGAnimationAdditiveValueFunction.h" >+#include "SVGLengthContext.h" >+#include "SVGLengthList.h" >+#include "SVGPathByteStream.h" >+#include "SVGPropertyTraits.h" >+ >+namespace WebCore { >+ >+class SVGAnimationNumberFunction : public SVGAnimationAdditiveValueFunction<float> { >+ friend class SVGAnimatedNumberPairAnimator; >+ >+public: >+ using Base = SVGAnimationAdditiveValueFunction<float>; >+ using Base::Base; >+ >+ void setFromAndToValues(SVGElement*, const String& from, const String& to) override >+ { >+ m_from = SVGPropertyTraits<float>::fromString(from); >+ m_to = SVGPropertyTraits<float>::fromString(to); >+ } >+ >+ void setToAtEndOfDurationValue(const String& toAtEndOfDuration) override >+ { >+ m_toAtEndOfDuration = SVGPropertyTraits<float>::fromString(toAtEndOfDuration); >+ } >+ >+ void progress(SVGElement*, float percentage, unsigned repeatCount, float& animated) >+ { >+ float from = m_animationMode == AnimationMode::To ? animated : m_from; >+ animated = Base::progress(percentage, repeatCount, from, m_to, toAtEndOfDuration(), animated); >+ } >+ >+ float calculateDistance(SVGElement*, const String& from, const String& to) const override >+ { >+ float fromNumber = 0; >+ float toNumber = 0; >+ parseNumberFromString(from, fromNumber); >+ parseNumberFromString(to, toNumber); >+ return fabsf(toNumber - fromNumber); >+ } >+ >+private: >+ void addFromAndToValues(SVGElement*) override >+ { >+ m_to += m_from; >+ } >+}; >+ >+class SVGAnimationIntegerFunction : public SVGAnimationAdditiveValueFunction<int> { >+ friend class SVGAnimatedIntegerPairAnimator; >+ >+public: >+ using Base = SVGAnimationAdditiveValueFunction<int>; >+ using Base::Base; >+ >+ void setFromAndToValues(SVGElement*, const String& from, const String& to) override >+ { >+ m_from = SVGPropertyTraits<int>::fromString(from); >+ m_to = SVGPropertyTraits<int>::fromString(to); >+ } >+ >+ void setToAtEndOfDurationValue(const String& toAtEndOfDuration) override >+ { >+ m_toAtEndOfDuration = SVGPropertyTraits<int>::fromString(toAtEndOfDuration); >+ } >+ >+ void progress(SVGElement*, float percentage, unsigned repeatCount, int& animated) >+ { >+ animated = static_cast<int>(roundf(Base::progress(percentage, repeatCount, m_from, m_to, toAtEndOfDuration(), animated))); >+ } >+ >+ float calculateDistance(SVGElement*, const String& from, const String& to) const override >+ { >+ return std::abs(to.toIntStrict() - from.toIntStrict()); >+ } >+ >+private: >+ void addFromAndToValues(SVGElement*) override >+ { >+ m_to += m_from; >+ } >+}; >+ >+class SVGAnimationRectFunction : public SVGAnimationAdditiveValueFunction<FloatRect> { >+public: >+ using Base = SVGAnimationAdditiveValueFunction<FloatRect>; >+ using Base::Base; >+ >+ void setFromAndToValues(SVGElement*, const String& from, const String& to) override >+ { >+ m_from = SVGPropertyTraits<FloatRect>::fromString(from); >+ m_to = SVGPropertyTraits<FloatRect>::fromString(to); >+ } >+ >+ void setToAtEndOfDurationValue(const String& toAtEndOfDuration) override >+ { >+ m_toAtEndOfDuration = SVGPropertyTraits<FloatRect>::fromString(toAtEndOfDuration); >+ } >+ >+ void progress(SVGElement*, float percentage, unsigned repeatCount, FloatRect& animated) >+ { >+ FloatRect from = m_animationMode == AnimationMode::To ? animated : m_from; >+ >+ float x = Base::progress(percentage, repeatCount, from.x(), m_to.x(), toAtEndOfDuration().x(), animated.x()); >+ float y = Base::progress(percentage, repeatCount, from.y(), m_to.y(), toAtEndOfDuration().y(), animated.y()); >+ float width = Base::progress(percentage, repeatCount, from.width(), m_to.width(), toAtEndOfDuration().width(), animated.width()); >+ float height = Base::progress(percentage, repeatCount, from.height(), m_to.height(), toAtEndOfDuration().height(), animated.height()); >+ >+ animated = { x, y, width, height }; >+ } >+ >+private: >+ void addFromAndToValues(SVGElement*) override >+ { >+ m_to += m_from; >+ } >+}; >+ >+class SVGAnimationColorFunction : public SVGAnimationAdditiveValueFunction<Color> { >+public: >+ using Base = SVGAnimationAdditiveValueFunction<Color>; >+ using Base::Base; >+ >+ void setFromAndToValues(SVGElement* targetElement, const String& from, const String& to) override >+ { >+ m_from = colorFromString(targetElement, from); >+ m_to = colorFromString(targetElement, to); >+ } >+ >+ void setToAtEndOfDurationValue(const String& toAtEndOfDuration) override >+ { >+ m_toAtEndOfDuration = SVGPropertyTraits<Color>::fromString(toAtEndOfDuration); >+ } >+ >+ void progress(SVGElement*, float percentage, unsigned repeatCount, Color& animated) >+ { >+ Color from = m_animationMode == AnimationMode::To ? animated : m_from; >+ >+ float red = Base::progress(percentage, repeatCount, from.red(), m_to.red(), toAtEndOfDuration().red(), animated.red()); >+ float green = Base::progress(percentage, repeatCount, from.green(), m_to.green(), toAtEndOfDuration().green(), animated.green()); >+ float blue = Base::progress(percentage, repeatCount, from.blue(), m_to.blue(), toAtEndOfDuration().blue(), animated.blue()); >+ float alpha = Base::progress(percentage, repeatCount, from.alpha(), m_to.alpha(), toAtEndOfDuration().alpha(), animated.alpha()); >+ >+ animated = { roundAndClampColorChannel(red), roundAndClampColorChannel(green), roundAndClampColorChannel(blue), roundAndClampColorChannel(alpha) }; >+ } >+ >+ float calculateDistance(SVGElement*, const String& from, const String& to) const override >+ { >+ Color fromColor = CSSParser::parseColor(from.stripWhiteSpace()); >+ if (!fromColor.isValid()) >+ return -1; >+ Color toColor = CSSParser::parseColor(to.stripWhiteSpace()); >+ if (!toColor.isValid()) >+ return -1; >+ float red = fromColor.red() - toColor.red(); >+ float green = fromColor.green() - toColor.green(); >+ float blue = fromColor.blue() - toColor.blue(); >+ return sqrtf(red * red + green * green + blue * blue); >+ } >+ >+private: >+ void addFromAndToValues(SVGElement*) override >+ { >+ // Ignores any alpha and sets alpha on result to 100% opaque. >+ m_to = { >+ roundAndClampColorChannel(m_to.red() + m_from.red()), >+ roundAndClampColorChannel(m_to.green() + m_from.green()), >+ roundAndClampColorChannel(m_to.blue() + m_from.blue()) >+ }; >+ } >+ >+ static Color colorFromString(SVGElement*, const String&); >+}; >+ >+class SVGAnimationAngleFunction : public SVGAnimationAdditiveValueFunction<SVGAngleValue> { >+public: >+ using Base = SVGAnimationAdditiveValueFunction<SVGAngleValue>; >+ using Base::Base; >+ >+ void setFromAndToValues(SVGElement*, const String&, const String&) override >+ { >+ // Values will be set by SVGAnimatedAngleOrientAnimator. >+ ASSERT_NOT_REACHED(); >+ } >+ >+ void progress(SVGElement*, float percentage, unsigned repeatCount, SVGAngleValue& animated) >+ { >+ float number = animated.value(); >+ number = Base::progress(percentage, repeatCount, m_from.value(), m_to.value(), toAtEndOfDuration().value(), number); >+ animated.setValue(number); >+ } >+ >+private: >+ friend class SVGAnimatedAngleOrientAnimator; >+ >+ void addFromAndToValues(SVGElement*) override >+ { >+ m_to.setValue(m_to.value() + m_from.value()); >+ } >+}; >+ >+class SVGAnimationLengthFunction : public SVGAnimationAdditiveValueFunction<SVGLengthValue> { >+ using Base = SVGAnimationAdditiveValueFunction<SVGLengthValue>; >+ >+public: >+ SVGAnimationLengthFunction(AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive, SVGLengthMode lengthMode) >+ : Base(animationMode, calcMode, isAccumulated, isAdditive) >+ , m_lengthMode(lengthMode) >+ { >+ } >+ >+ void setFromAndToValues(SVGElement*, const String& from, const String& to) override >+ { >+ m_from = SVGLengthValue(m_lengthMode, from); >+ m_to = SVGLengthValue(m_lengthMode, to); >+ } >+ >+ void setToAtEndOfDurationValue(const String& toAtEndOfDuration) override >+ { >+ m_toAtEndOfDuration = SVGLengthValue(m_lengthMode, toAtEndOfDuration); >+ } >+ >+ void progress(SVGElement* targetElement, float percentage, unsigned repeatCount, SVGLengthValue& animated) >+ { >+ SVGLengthContext lengthContext(targetElement); >+ SVGLengthType unitType = percentage < 0.5 ? m_from.unitType() : m_to.unitType(); >+ >+ float from = (m_animationMode == AnimationMode::To ? animated : m_from).value(lengthContext); >+ float to = m_to.value(lengthContext); >+ float toAtEndOfDuration = this->toAtEndOfDuration().value(lengthContext); >+ float value = animated.value(lengthContext); >+ >+ value = Base::progress(percentage, repeatCount, from, to, toAtEndOfDuration, value); >+ animated = { lengthContext, value, m_lengthMode, unitType }; >+ } >+ >+ float calculateDistance(SVGElement* targetElement, const String& from, const String& to) const override >+ { >+ SVGLengthContext lengthContext(targetElement); >+ auto fromLength = SVGLengthValue(m_lengthMode, from); >+ auto toLength = SVGLengthValue(m_lengthMode, to); >+ return fabsf(toLength.value(lengthContext) - fromLength.value(lengthContext)); >+ } >+ >+private: >+ void addFromAndToValues(SVGElement* targetElement) override >+ { >+ SVGLengthContext lengthContext(targetElement); >+ m_to.setValue(m_to.value(lengthContext) + m_from.value(lengthContext), lengthContext); >+ } >+ >+ SVGLengthMode m_lengthMode; >+}; >+ >+class SVGAnimationPathSegListFunction : public SVGAnimationAdditiveValueFunction<SVGPathByteStream> { >+public: >+ using Base = SVGAnimationAdditiveValueFunction<SVGPathByteStream>; >+ using Base::Base; >+ >+ void setFromAndToValues(SVGElement*, const String& from, const String& to) override >+ { >+ m_from = SVGPropertyTraits<SVGPathByteStream>::fromString(from); >+ m_to = SVGPropertyTraits<SVGPathByteStream>::fromString(to); >+ } >+ >+ void setToAtEndOfDurationValue(const String& toAtEndOfDuration) override >+ { >+ m_toAtEndOfDuration = SVGPropertyTraits<SVGPathByteStream>::fromString(toAtEndOfDuration); >+ } >+ >+ void progress(SVGElement*, float percentage, unsigned repeatCount, SVGPathByteStream& animated) >+ { >+ SVGPathByteStream underlyingPath; >+ if (m_animationMode == AnimationMode::To) >+ underlyingPath = animated; >+ >+ const SVGPathByteStream& from = m_animationMode == AnimationMode::To ? underlyingPath : m_from; >+ >+ // Cache the current animated value before the buildAnimatedSVGPathByteStream() clears animatedPath. >+ SVGPathByteStream lastAnimated; >+ if (!from.size() || (m_isAdditive && m_animationMode != AnimationMode::To)) >+ lastAnimated = animated; >+ >+ buildAnimatedSVGPathByteStream(from, m_to, animated, percentage); >+ >+ // Handle additive='sum'. >+ if (!lastAnimated.isEmpty()) >+ addToSVGPathByteStream(animated, lastAnimated); >+ >+ // Handle accumulate='sum'. >+ if (m_isAccumulated && repeatCount) >+ addToSVGPathByteStream(animated, toAtEndOfDuration(), repeatCount); >+ } >+ >+private: >+ void addFromAndToValues(SVGElement*) override >+ { >+ if (!m_from.size() || m_from.size() != m_to.size()) >+ return; >+ addToSVGPathByteStream(m_to, m_from); >+ } >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGAnimationDiscreteFunction.h b/Source/WebCore/svg/properties/SVGAnimationDiscreteFunction.h >index 8b137891791..f1dd15bde1f 100644 >--- a/Source/WebCore/svg/properties/SVGAnimationDiscreteFunction.h >+++ b/Source/WebCore/svg/properties/SVGAnimationDiscreteFunction.h >@@ -1 +1,63 @@ >+/* >+ * 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 >+ >+namespace WebCore { >+ >+template<typename ValueType> >+class SVGAnimationDiscreteFunction : public SVGAnimationFunction { >+public: >+ SVGAnimationDiscreteFunction(AnimationMode animationMode, CalcMode, bool, bool) >+ : SVGAnimationFunction(animationMode) >+ { >+ } >+ >+ bool isDiscrete() const override { return true; } >+ >+ void setToAtEndOfDurationValue(const String&) override >+ { >+ ASSERT_NOT_REACHED(); >+ } >+ >+ void setFromAndByValues(SVGElement*, const String&, const String&) override >+ { >+ ASSERT_NOT_REACHED(); >+ } >+ >+ void progress(SVGElement*, float percentage, unsigned, ValueType& animated) >+ { >+ if ((m_animationMode == AnimationMode::FromTo && percentage > 0.5) || m_animationMode == AnimationMode::To || percentage == 1) >+ animated = m_to; >+ else >+ animated = m_from; >+ } >+ >+protected: >+ ValueType m_from; >+ ValueType m_to; >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGAnimationDiscreteFunctionImpl.h b/Source/WebCore/svg/properties/SVGAnimationDiscreteFunctionImpl.h >index 8b137891791..7c840963c15 100644 >--- a/Source/WebCore/svg/properties/SVGAnimationDiscreteFunctionImpl.h >+++ b/Source/WebCore/svg/properties/SVGAnimationDiscreteFunctionImpl.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 "SVGAnimationDiscreteFunction.h" >+#include "SVGMarkerTypes.h" >+#include "SVGPropertyTraits.h" >+ >+namespace WebCore { >+ >+class SVGAnimationBooleanFunction : public SVGAnimationDiscreteFunction<bool> { >+public: >+ using Base = SVGAnimationDiscreteFunction<bool>; >+ using Base::Base; >+ >+ void setFromAndToValues(SVGElement*, const String& from, const String& to) override >+ { >+ m_from = SVGPropertyTraits<bool>::fromString(from); >+ m_to = SVGPropertyTraits<bool>::fromString(to); >+ } >+}; >+ >+template<typename EnumType> >+class SVGAnimationEnumerationFunction : public SVGAnimationDiscreteFunction<EnumType> { >+ using Base = SVGAnimationDiscreteFunction<EnumType>; >+ using Base::m_from; >+ using Base::m_to; >+ >+public: >+ using Base::Base; >+ >+ void setFromAndToValues(SVGElement*, const String& from, const String& to) override >+ { >+ m_from = SVGPropertyTraits<EnumType>::fromString(from); >+ m_to = SVGPropertyTraits<EnumType>::fromString(to); >+ } >+}; >+ >+class SVGAnimationPreserveAspectRatioFunction : public SVGAnimationDiscreteFunction<SVGPreserveAspectRatioValue> { >+public: >+ using Base = SVGAnimationDiscreteFunction<SVGPreserveAspectRatioValue>; >+ using Base::Base; >+ >+ void setFromAndToValues(SVGElement*, const String& from, const String& to) override >+ { >+ m_from = SVGPreserveAspectRatioValue(from); >+ m_to = SVGPreserveAspectRatioValue(to); >+ } >+}; >+ >+class SVGAnimationStringFunction : public SVGAnimationDiscreteFunction<String> { >+public: >+ using Base = SVGAnimationDiscreteFunction<String>; >+ using Base::Base; >+ >+ void setFromAndToValues(SVGElement*, const String& from, const String& to) override >+ { >+ m_from = from; >+ m_to = to; >+ } >+}; >+ >+class SVGAnimationOrientTypeFunction : public SVGAnimationDiscreteFunction<SVGMarkerOrientType> { >+public: >+ using Base = SVGAnimationDiscreteFunction<SVGMarkerOrientType>; >+ using Base::Base; >+ >+ void setFromAndToValues(SVGElement*, const String&, const String&) override >+ { >+ // Values will be set by SVGAnimatedAngleOrientAnimator. >+ ASSERT_NOT_REACHED(); >+ } >+ >+private: >+ friend class SVGAnimatedAngleOrientAnimator; >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGAnimationFunction.h b/Source/WebCore/svg/properties/SVGAnimationFunction.h >index 8b137891791..61f7ab2657b 100644 >--- a/Source/WebCore/svg/properties/SVGAnimationFunction.h >+++ b/Source/WebCore/svg/properties/SVGAnimationFunction.h >@@ -1 +1,55 @@ >+/* >+ * 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 >+ >+namespace WebCore { >+ >+class SVGElement; >+ >+class SVGAnimationFunction { >+public: >+ virtual ~SVGAnimationFunction() = default; >+ >+ virtual bool isDiscrete() const { return false; } >+ >+ virtual void setFromAndToValues(SVGElement* targetElement, const String&, const String&) = 0; >+ virtual void setFromAndByValues(SVGElement* targetElement, const String&, const String&) = 0; >+ virtual void setToAtEndOfDurationValue(const String&) = 0; >+ >+ virtual float calculateDistance(SVGElement*, const String&, const String&) const { return -1; } >+ >+protected: >+ SVGAnimationFunction(AnimationMode animationMode) >+ : m_animationMode(animationMode) >+ { >+ } >+ >+ virtual void addFromAndToValues(SVGElement*) { } >+ >+ AnimationMode m_animationMode; >+}; >+ >+}
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