Remove the argument 'resultElement' from the SVG animation functions
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Oct 2019 22:15:17 +0000 (22:15 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Oct 2019 22:15:17 +0000 (22:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=202052

 Reviewed by Simon Fraser.

 This is a clean-up patch, which does the following:

 -- It removes the argument 'resultElement' from all the SVG animation
   functions except from SVGSMILElement::progress(). In this function, we
   need to start the animation only with the first animation.

 -- It renames resetAnimatedType() and clearAnimatedType() to startAnimation()
   and stopAnimation() respectively. These functions were named for the
   type SVGAnimatedType which had been deleted. The real purpose of these
   functions is to start/stop the animation.

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2019-10-30

* svg/SVGAnimateElementBase.cpp:
(WebCore::SVGAnimateElementBase::startAnimation):
(WebCore::SVGAnimateElementBase::calculateAnimatedValue):
(WebCore::SVGAnimateElementBase::stopAnimation):
(WebCore::SVGAnimateElementBase::resetAnimatedType): Deleted.
(WebCore::SVGAnimateElementBase::clearAnimatedType): Deleted.
* svg/SVGAnimateElementBase.h:
* svg/SVGAnimateMotionElement.cpp:
(WebCore::SVGAnimateMotionElement::startAnimation):
(WebCore::SVGAnimateMotionElement::stopAnimation):
(WebCore::SVGAnimateMotionElement::calculateAnimatedValue):
(WebCore::SVGAnimateMotionElement::resetAnimatedType): Deleted.
(WebCore::SVGAnimateMotionElement::clearAnimatedType): Deleted.
* svg/SVGAnimateMotionElement.h:
* svg/SVGAnimationElement.cpp:
(WebCore::SVGAnimationElement::updateAnimation):
* svg/SVGAnimationElement.h:
* svg/animation/SMILTimeContainer.cpp:
(WebCore::SMILTimeContainer::updateAnimations):
* svg/animation/SVGSMILElement.cpp:
(WebCore::SVGSMILElement::reset):
(WebCore::SVGSMILElement::setAttributeName):
(WebCore::SVGSMILElement::setTargetElement):
(WebCore::SVGSMILElement::progress):
* svg/animation/SVGSMILElement.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251809 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/svg/SVGAnimateElementBase.cpp
Source/WebCore/svg/SVGAnimateElementBase.h
Source/WebCore/svg/SVGAnimateMotionElement.cpp
Source/WebCore/svg/SVGAnimateMotionElement.h
Source/WebCore/svg/SVGAnimationElement.cpp
Source/WebCore/svg/SVGAnimationElement.h
Source/WebCore/svg/animation/SMILTimeContainer.cpp
Source/WebCore/svg/animation/SVGSMILElement.cpp
Source/WebCore/svg/animation/SVGSMILElement.h

index 8425f5c..caeb2e5 100644 (file)
@@ -1,3 +1,47 @@
+2019-10-30  Said Abou-Hallawa  <sabouhallawa@apple.com>
+
+        Remove the argument 'resultElement' from the SVG animation functions
+        https://bugs.webkit.org/show_bug.cgi?id=202052
+
+         Reviewed by Simon Fraser.
+
+         This is a clean-up patch, which does the following:
+
+         -- It removes the argument 'resultElement' from all the SVG animation
+           functions except from SVGSMILElement::progress(). In this function, we
+           need to start the animation only with the first animation.
+
+         -- It renames resetAnimatedType() and clearAnimatedType() to startAnimation()
+           and stopAnimation() respectively. These functions were named for the
+           type SVGAnimatedType which had been deleted. The real purpose of these
+           functions is to start/stop the animation.
+
+        * svg/SVGAnimateElementBase.cpp:
+        (WebCore::SVGAnimateElementBase::startAnimation):
+        (WebCore::SVGAnimateElementBase::calculateAnimatedValue):
+        (WebCore::SVGAnimateElementBase::stopAnimation):
+        (WebCore::SVGAnimateElementBase::resetAnimatedType): Deleted.
+        (WebCore::SVGAnimateElementBase::clearAnimatedType): Deleted.
+        * svg/SVGAnimateElementBase.h:
+        * svg/SVGAnimateMotionElement.cpp:
+        (WebCore::SVGAnimateMotionElement::startAnimation):
+        (WebCore::SVGAnimateMotionElement::stopAnimation):
+        (WebCore::SVGAnimateMotionElement::calculateAnimatedValue):
+        (WebCore::SVGAnimateMotionElement::resetAnimatedType): Deleted.
+        (WebCore::SVGAnimateMotionElement::clearAnimatedType): Deleted.
+        * svg/SVGAnimateMotionElement.h:
+        * svg/SVGAnimationElement.cpp:
+        (WebCore::SVGAnimationElement::updateAnimation):
+        * svg/SVGAnimationElement.h:
+        * svg/animation/SMILTimeContainer.cpp:
+        (WebCore::SMILTimeContainer::updateAnimations):
+        * svg/animation/SVGSMILElement.cpp:
+        (WebCore::SVGSMILElement::reset):
+        (WebCore::SVGSMILElement::setAttributeName):
+        (WebCore::SVGSMILElement::setTargetElement):
+        (WebCore::SVGSMILElement::progress):
+        * svg/animation/SVGSMILElement.h:
+
 2019-10-30  Zalan Bujtas  <zalan@apple.com>
 
         ASSERTION FAILED: !object || !isRuby(object->parent()) || is<RenderRubyRun>(*object) || (object->isInline() && (object->isBeforeContent() || object->isAfterContent())) || (object->isAnonymous() && is<RenderBlock>(*object) && object->style().display() == D
index f1f749e..c924e5d 100644 (file)
@@ -146,7 +146,7 @@ bool SVGAnimateElementBase::calculateToAtEndOfDurationValue(const String& toAtEn
     return false;
 }
 
-void SVGAnimateElementBase::resetAnimatedType()
+void SVGAnimateElementBase::startAnimation()
 {
     if (!targetElement())
         return;
@@ -155,7 +155,7 @@ void SVGAnimateElementBase::resetAnimatedType()
         protectedAnimator->start(targetElement());
 }
 
-void SVGAnimateElementBase::calculateAnimatedValue(float progress, unsigned repeatCount, SVGSMILElement*)
+void SVGAnimateElementBase::calculateAnimatedValue(float progress, unsigned repeatCount)
 {
     if (!targetElement())
         return;
@@ -180,7 +180,7 @@ void SVGAnimateElementBase::applyResultsToTarget()
         animator->apply(targetElement());
 }
 
-void SVGAnimateElementBase::clearAnimatedType(SVGElement* targetElement)
+void SVGAnimateElementBase::stopAnimation(SVGElement* targetElement)
 {
     if (!targetElement)
         return;
index 398cd19..d133e61 100644 (file)
@@ -53,10 +53,10 @@ private:
     bool calculateFromAndByValues(const String& fromString, const String& byString) override;
     bool calculateToAtEndOfDurationValue(const String& toAtEndOfDurationString) override;
 
-    void resetAnimatedType() override;
-    void calculateAnimatedValue(float progress, unsigned repeatCount, SVGSMILElement* resultElement) override;
+    void startAnimation() override;
+    void calculateAnimatedValue(float progress, unsigned repeatCount) override;
     void applyResultsToTarget() override;
-    void clearAnimatedType(SVGElement* targetElement) override;
+    void stopAnimation(SVGElement* targetElement) override;
     Optional<float> calculateDistance(const String& fromString, const String& toString) override;
 
     bool hasInvalidCSSAttributeType() const;
index 2f2beb8..fd34544 100644 (file)
@@ -139,7 +139,7 @@ void SVGAnimateMotionElement::updateAnimationPath()
     updateAnimationMode();
 }
 
-void SVGAnimateMotionElement::resetAnimatedType()
+void SVGAnimateMotionElement::startAnimation()
 {
     if (!hasValidAttributeType())
         return;
@@ -150,7 +150,7 @@ void SVGAnimateMotionElement::resetAnimatedType()
         transform->makeIdentity();
 }
 
-void SVGAnimateMotionElement::clearAnimatedType(SVGElement* targetElement)
+void SVGAnimateMotionElement::stopAnimation(SVGElement* targetElement)
 {
     if (!targetElement)
         return;
@@ -208,7 +208,7 @@ void SVGAnimateMotionElement::buildTransformForProgress(AffineTransform* transfo
     transform->rotate(angle);
 }
 
-void SVGAnimateMotionElement::calculateAnimatedValue(float percentage, unsigned repeatCount, SVGSMILElement*)
+void SVGAnimateMotionElement::calculateAnimatedValue(float percentage, unsigned repeatCount)
 {
     auto targetElement = makeRefPtr(this->targetElement());
     if (!targetElement)
index fabaac5..0ae9dd5 100644 (file)
@@ -41,12 +41,12 @@ private:
 
     void parseAttribute(const QualifiedName&, const AtomString&) override;
 
-    void resetAnimatedType() override;
-    void clearAnimatedType(SVGElement* targetElement) override;
+    void startAnimation() override;
+    void stopAnimation(SVGElement* targetElement) override;
     bool calculateToAtEndOfDurationValue(const String& toAtEndOfDurationString) override;
     bool calculateFromAndToValues(const String& fromString, const String& toString) override;
     bool calculateFromAndByValues(const String& fromString, const String& byString) override;
-    void calculateAnimatedValue(float percentage, unsigned repeatCount, SVGSMILElement* resultElement) override;
+    void calculateAnimatedValue(float percentage, unsigned repeatCount) override;
     void applyResultsToTarget() override;
     Optional<float> calculateDistance(const String& fromString, const String& toString) override;
 
index 1241922..1b461b4 100644 (file)
@@ -562,7 +562,7 @@ void SVGAnimationElement::startedActiveInterval()
         m_animationValid = calcMode == CalcMode::Paced || !hasAttributeWithoutSynchronization(SVGNames::keyPointsAttr) || (m_keyTimes.size() > 1 && m_keyTimes.size() == m_keyPoints.size());
 }
 
-void SVGAnimationElement::updateAnimation(float percent, unsigned repeatCount, SVGSMILElement* resultElement)
+void SVGAnimationElement::updateAnimation(float percent, unsigned repeatCount)
 {    
     if (!m_animationValid)
         return;
@@ -590,7 +590,7 @@ void SVGAnimationElement::updateAnimation(float percent, unsigned repeatCount, S
     else
         effectivePercent = percent;
 
-    calculateAnimatedValue(effectivePercent, repeatCount, resultElement);
+    calculateAnimatedValue(effectivePercent, repeatCount);
 }
 
 void SVGAnimationElement::computeCSSPropertyValue(SVGElement* element, CSSPropertyID id, String& valueString)
index 8b1fb7f..f36da6c 100644 (file)
@@ -102,7 +102,7 @@ protected:
 
     // from SVGSMILElement
     void startedActiveInterval() override;
-    void updateAnimation(float percent, unsigned repeat, SVGSMILElement* resultElement) override;
+    void updateAnimation(float percent, unsigned repeat) override;
 
     AnimatedPropertyValueType m_fromPropertyValueType { RegularPropertyValue };
     AnimatedPropertyValueType m_toPropertyValueType { RegularPropertyValue };
@@ -120,7 +120,7 @@ private:
     virtual bool calculateToAtEndOfDurationValue(const String& toAtEndOfDurationString) = 0;
     virtual bool calculateFromAndToValues(const String& fromString, const String& toString) = 0;
     virtual bool calculateFromAndByValues(const String& fromString, const String& byString) = 0;
-    virtual void calculateAnimatedValue(float percent, unsigned repeatCount, SVGSMILElement* resultElement) = 0;
+    virtual void calculateAnimatedValue(float percent, unsigned repeatCount) = 0;
     virtual Optional<float> calculateDistance(const String& /*fromString*/, const String& /*toString*/) = 0;
 
     void currentValuesForValuesAnimation(float percent, float& effectivePercent, String& from, String& to);
index 4c3da65..66fdfb5 100644 (file)
@@ -278,7 +278,7 @@ void SMILTimeContainer::updateAnimations(SMILTime elapsed, bool seekToTime)
             }
 
             // This will calculate the contribution from the animation and add it to the resultsElement.
-            if (!animation->progress(elapsed, firstAnimation.get(), seekToTime) && firstAnimation == animation)
+            if (!animation->progress(elapsed, *firstAnimation, seekToTime) && firstAnimation == animation)
                 firstAnimation = nullptr;
 
             SMILTime nextFireTime = animation->nextProgressTime();
index 3ab5829..449b14c 100644 (file)
@@ -245,7 +245,7 @@ static inline void clearTimesWithDynamicOrigins(Vector<SMILTimeWithOrigin>& time
 
 void SVGSMILElement::reset()
 {
-    clearAnimatedType(m_targetElement);
+    stopAnimation(m_targetElement);
 
     m_activeState = Inactive;
     m_isWaitingForFirstInterval = true;
@@ -610,7 +610,7 @@ void SVGSMILElement::setAttributeName(const QualifiedName& attributeName)
 
     // Only clear the animated type, if we had a target before.
     if (m_targetElement)
-        clearAnimatedType(m_targetElement);
+        stopAnimation(m_targetElement);
 }
 
 void SVGSMILElement::setTargetElement(SVGElement* target)
@@ -624,7 +624,7 @@ void SVGSMILElement::setTargetElement(SVGElement* target)
 
     if (m_targetElement) {
         // Clear values that may depend on the previous target.
-        clearAnimatedType(m_targetElement);
+        stopAnimation(m_targetElement);
         disconnectConditions();
     }
 
@@ -1070,9 +1070,8 @@ bool SVGSMILElement::isContributing(SMILTime elapsed) const
     return (m_activeState == Active && (fill() == FillFreeze || elapsed <= m_intervalBegin + repeatingDuration())) || m_activeState == Frozen;
 }
     
-bool SVGSMILElement::progress(SMILTime elapsed, SVGSMILElement* resultElement, bool seekToTime)
+bool SVGSMILElement::progress(SMILTime elapsed, SVGSMILElement& firstAnimation, bool seekToTime)
 {
-    ASSERT(resultElement);
     ASSERT(m_timeContainer);
     ASSERT(m_isWaitingForFirstInterval || m_intervalBegin.isFinite());
 
@@ -1085,9 +1084,9 @@ bool SVGSMILElement::progress(SMILTime elapsed, SVGSMILElement* resultElement, b
     if (elapsed < m_intervalBegin) {
         ASSERT(m_activeState != Active);
         if (m_activeState == Frozen) {
-            if (this == resultElement)
-                resetAnimatedType();
-            updateAnimation(m_lastPercent, m_lastRepeat, resultElement);
+            if (this == &firstAnimation)
+                startAnimation();
+            updateAnimation(m_lastPercent, m_lastRepeat);
         }
         m_nextProgressTime = m_intervalBegin;
         return false;
@@ -1118,15 +1117,15 @@ bool SVGSMILElement::progress(SMILTime elapsed, SVGSMILElement* resultElement, b
     m_activeState = determineActiveState(elapsed);
     bool animationIsContributing = isContributing(elapsed);
 
-    // Only reset the animated type to the base value once for the lowest priority animation that animates and contributes to a particular element/attribute pair.
-    if (this == resultElement && animationIsContributing)
-        resetAnimatedType();
-
     if (animationIsContributing) {
+        // Only start the animation of the lowest priority animation that animates and contributes to a particular element/attribute pair.
+        if (this == &firstAnimation)
+            startAnimation();
+
         if (oldActiveState == Inactive)
             startedActiveInterval();
 
-        updateAnimation(percent, repeat, resultElement);
+        updateAnimation(percent, repeat);
         m_lastPercent = percent;
         m_lastRepeat = repeat;
     }
@@ -1135,7 +1134,7 @@ bool SVGSMILElement::progress(SMILTime elapsed, SVGSMILElement* resultElement, b
         smilEndEventSender().dispatchEventSoon(*this);
         endedActiveInterval();
         if (m_activeState != Frozen)
-            clearAnimatedType(m_targetElement);
+            stopAnimation(m_targetElement);
     } else if (oldActiveState != Active && m_activeState == Active)
         smilBeginEventSender().dispatchEventSoon(*this);
 
index 069bc83..1850065 100644 (file)
@@ -82,7 +82,7 @@ public:
     SMILTime simpleDuration() const;
 
     void seekToIntervalCorrespondingToTime(SMILTime elapsed);
-    bool progress(SMILTime elapsed, SVGSMILElement* resultsElement, bool seekToTime);
+    bool progress(SMILTime elapsed, SVGSMILElement& firstAnimation, bool seekToTime);
     SMILTime nextProgressTime() const;
 
     void reset();
@@ -98,8 +98,8 @@ public:
     void setDocumentOrderIndex(unsigned index) { m_documentOrderIndex = index; }
 
     virtual bool isAdditive() const = 0;
-    virtual void resetAnimatedType() = 0;
-    virtual void clearAnimatedType(SVGElement* targetElement) = 0;
+    virtual void startAnimation() = 0;
+    virtual void stopAnimation(SVGElement* targetElement) = 0;
     virtual void applyResultsToTarget() = 0;
 
     void connectConditions();
@@ -129,7 +129,7 @@ private:
 
     virtual void startedActiveInterval() = 0;
     void endedActiveInterval();
-    virtual void updateAnimation(float percent, unsigned repeat, SVGSMILElement* resultElement) = 0;
+    virtual void updateAnimation(float percent, unsigned repeat) = 0;
 
     static bool isSupportedAttribute(const QualifiedName&);
     QualifiedName constructAttributeName() const;