Diff
Modified: trunk/LayoutTests/ChangeLog (90217 => 90218)
--- trunk/LayoutTests/ChangeLog 2011-07-01 07:52:20 UTC (rev 90217)
+++ trunk/LayoutTests/ChangeLog 2011-07-01 08:37:49 UTC (rev 90218)
@@ -1,3 +1,21 @@
+2011-07-01 Dirk Schulze <[email protected]>
+
+ Reviewed by Nikolas Zimmermann.
+
+ SVGAnimatedType should support SVGAnimatedInteger animation
+ https://bugs.webkit.org/show_bug.cgi?id=63789
+
+ Test animation of SVGAnimatedInteger. Added the test to the wk2 skip list.
+
+ * platform/mac-wk2/Skipped:
+ * svg/animations/script-tests/svginteger-animation-1.js: Added.
+ (sample1):
+ (sample2):
+ (sample3):
+ (executeTest):
+ * svg/animations/svginteger-animation-1-expected.txt: Added.
+ * svg/animations/svginteger-animation-1.html: Added.
+
2011-07-01 Kent Tamura <[email protected]>
[Chromium] More test expectation update for r90089
Modified: trunk/LayoutTests/platform/wk2/Skipped (90217 => 90218)
--- trunk/LayoutTests/platform/wk2/Skipped 2011-07-01 07:52:20 UTC (rev 90217)
+++ trunk/LayoutTests/platform/wk2/Skipped 2011-07-01 08:37:49 UTC (rev 90218)
@@ -455,6 +455,7 @@
svg/animations/svgangle-animation-rad-to-deg.html
svg/animations/svgangle-animation-rad-to-grad.html
svg/animations/svgboolean-animation-1.html
+svg/animations/svginteger-animation-1.html
svg/animations/svglength-animation-LengthModeHeight.html
svg/animations/svglength-animation-LengthModeOther.html
svg/animations/svglength-animation-LengthModeWidth.html
Added: trunk/LayoutTests/svg/animations/script-tests/svginteger-animation-1.js (0 => 90218)
--- trunk/LayoutTests/svg/animations/script-tests/svginteger-animation-1.js (rev 0)
+++ trunk/LayoutTests/svg/animations/script-tests/svginteger-animation-1.js 2011-07-01 08:37:49 UTC (rev 90218)
@@ -0,0 +1,67 @@
+description("Test animation of SVGInteger.");
+createSVGTestCase();
+
+// Setup test document
+var defs = createSVGElement("defs");
+rootSVGElement.appendChild(defs);
+
+var filter = createSVGElement("filter");
+filter.setAttribute("id", "filter");
+defs.appendChild(filter);
+
+var rect = createSVGElement("rect");
+rect.setAttribute("id", "rect");
+rect.setAttribute("width", "200");
+rect.setAttribute("height", "200");
+rect.setAttribute("fill", "green");
+rect.setAttribute("filter", "url(#filter)");
+rect.setAttribute("onclick", "executeTest()");
+rootSVGElement.appendChild(rect);
+
+var feConvolveMatrix = createSVGElement("feConvolveMatrix");
+feConvolveMatrix.setAttribute("id", "feConvlveMatrix");
+feConvolveMatrix.setAttribute("order", "3");
+feConvolveMatrix.setAttribute("kernelMatrix", "0 0 0 0 1 0 0 0 0");
+feConvolveMatrix.setAttribute("targetX", "0");
+filter.appendChild(feConvolveMatrix);
+
+var animate = createSVGElement("animate");
+animate.setAttribute("id", "animation");
+animate.setAttribute("attributeName", "targetX");
+animate.setAttribute("begin", "rect.click");
+animate.setAttribute("dur", "4s");
+animate.setAttribute("from", "0");
+animate.setAttribute("to", "2");
+feConvlveMatrix.appendChild(animate);
+
+// Setup animation test
+function sample1() {
+ shouldBe("feConvolveMatrix.targetX.animVal", "0");
+ // shouldBe("feConvolveMatrix.targetX.baseVal", "0");
+}
+
+function sample2() {
+ shouldBe("feConvolveMatrix.targetX.animVal", "1");
+ // shouldBe("feConvolveMatrix.targetX.baseVal", "0");
+}
+
+function sample3() {
+ shouldBe("feConvolveMatrix.targetX.animVal", "2");
+ // shouldBe("feConvolveMatrix.targetX.baseVal", "0");
+}
+
+function executeTest() {
+ const expectedValues = [
+ // [animationId, time, elementId, sampleCallback]
+ ["animation", 0.0, "feConvolveMatrix", sample1],
+ ["animation", 2.0, "feConvolveMatrix", sample2],
+ ["animation", 3.9999, "feConvolveMatrix", sample3],
+ ["animation", 4.1 , "feConvolveMatrix", sample1]
+ ];
+
+ runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(51, 49)", 0);
+var successfullyParsed = true;
Added: trunk/LayoutTests/svg/animations/svginteger-animation-1-expected.txt (0 => 90218)
--- trunk/LayoutTests/svg/animations/svginteger-animation-1-expected.txt (rev 0)
+++ trunk/LayoutTests/svg/animations/svginteger-animation-1-expected.txt 2011-07-01 08:37:49 UTC (rev 90218)
@@ -0,0 +1,15 @@
+SVG 1.1 dynamic animation tests
+
+Test animation of SVGInteger.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS feConvolveMatrix.targetX.animVal is 0
+PASS feConvolveMatrix.targetX.animVal is 1
+PASS feConvolveMatrix.targetX.animVal is 2
+PASS feConvolveMatrix.targetX.animVal is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/svg/animations/svginteger-animation-1.html (0 => 90218)
--- trunk/LayoutTests/svg/animations/svginteger-animation-1.html (rev 0)
+++ trunk/LayoutTests/svg/animations/svginteger-animation-1.html 2011-07-01 08:37:49 UTC (rev 90218)
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href=""
+<script src=""
+<script src=""
+<script src=""
+</head>
+<body>
+<h1>SVG 1.1 dynamic animation tests</h1>
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/CMakeLists.txt (90217 => 90218)
--- trunk/Source/WebCore/CMakeLists.txt 2011-07-01 07:52:20 UTC (rev 90217)
+++ trunk/Source/WebCore/CMakeLists.txt 2011-07-01 08:37:49 UTC (rev 90218)
@@ -1658,6 +1658,7 @@
svg/SVGAnimatedAngle.cpp
svg/SVGAnimatedBoolean.cpp
svg/SVGAnimatedColor.cpp
+ svg/SVGAnimatedInteger.cpp
svg/SVGAnimatedLength.cpp
svg/SVGAnimatedLengthList.cpp
svg/SVGAnimatedNumber.cpp
Modified: trunk/Source/WebCore/ChangeLog (90217 => 90218)
--- trunk/Source/WebCore/ChangeLog 2011-07-01 07:52:20 UTC (rev 90217)
+++ trunk/Source/WebCore/ChangeLog 2011-07-01 08:37:49 UTC (rev 90218)
@@ -1,3 +1,50 @@
+2011-07-01 Dirk Schulze <[email protected]>
+
+ Reviewed by Nikolas Zimmermann.
+
+ SVGAnimatedType should support SVGAnimatedInteger animation
+ https://bugs.webkit.org/show_bug.cgi?id=63789
+
+ Follow up of "SVGAnimation should use direct unit animation for SVGLength": https://bugs.webkit.org/show_bug.cgi?id=61368
+ This patch continues the conversion to the new concept of SVGAnimatorFactory with SVGAnimatedInteger.
+
+ SVGAnimatedInteger is used for some attributes of SVG filter effects. The animation of those attributes work after this patch.
+
+ Test: svg/animations/svginteger-animation-1.html
+
+ * CMakeLists.txt: Added file to build system.
+ * GNUmakefile.list.am: Ditto.
+ * WebCore.gypi: Ditto.
+ * WebCore.pro: Ditto.
+ * WebCore.xcodeproj/project.pbxproj: Ditto.
+ * svg/SVGAllInOne.cpp: Ditto.
+ * svg/SVGAnimateElement.cpp: Make use of AnimatedInteger.
+ (WebCore::SVGAnimateElement::determineAnimatedAttributeType):
+ (WebCore::SVGAnimateElement::calculateAnimatedValue):
+ (WebCore::SVGAnimateElement::calculateFromAndToValues):
+ (WebCore::SVGAnimateElement::calculateFromAndByValues):
+ (WebCore::SVGAnimateElement::resetToBaseValue):
+ (WebCore::SVGAnimateElement::applyResultsToTarget):
+ (WebCore::SVGAnimateElement::calculateDistance):
+ * svg/SVGAnimatedInteger.cpp: Added. The new animator for SVGAnimatedInteger.
+ (WebCore::SVGAnimatedIntegerAnimator::SVGAnimatedIntegerAnimator):
+ (WebCore::SVGAnimatedIntegerAnimator::constructFromString):
+ (WebCore::SVGAnimatedIntegerAnimator::calculateFromAndToValues):
+ (WebCore::SVGAnimatedIntegerAnimator::calculateFromAndByValues):
+ (WebCore::SVGAnimatedIntegerAnimator::calculateAnimatedValue):
+ (WebCore::SVGAnimatedIntegerAnimator::calculateDistance):
+ * svg/SVGAnimatedInteger.h:
+ (WebCore::SVGAnimatedIntegerAnimator::~SVGAnimatedIntegerAnimator):
+ * svg/SVGAnimatedType.cpp: Added handler for AnimatedInteger.
+ (WebCore::SVGAnimatedType::~SVGAnimatedType):
+ (WebCore::SVGAnimatedType::createInteger):
+ (WebCore::SVGAnimatedType::integer):
+ (WebCore::SVGAnimatedType::valueAsString):
+ (WebCore::SVGAnimatedType::setValueAsString):
+ * svg/SVGAnimatedType.h:
+ * svg/SVGAnimatorFactory.h:
+ (WebCore::SVGAnimatorFactory::create):
+
2011-06-30 Eugene Klyuchnikov <[email protected]>
Reviewed by Pavel Feldman.
Modified: trunk/Source/WebCore/GNUmakefile.list.am (90217 => 90218)
--- trunk/Source/WebCore/GNUmakefile.list.am 2011-07-01 07:52:20 UTC (rev 90217)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2011-07-01 08:37:49 UTC (rev 90218)
@@ -3435,6 +3435,7 @@
Source/WebCore/svg/SVGAnimatedColor.cpp \
Source/WebCore/svg/SVGAnimatedColor.h \
Source/WebCore/svg/SVGAnimatedEnumeration.h \
+ Source/WebCore/svg/SVGAnimatedInteger.cpp \
Source/WebCore/svg/SVGAnimatedInteger.h \
Source/WebCore/svg/SVGAnimatedLength.cpp \
Source/WebCore/svg/SVGAnimatedLength.h \
Modified: trunk/Source/WebCore/WebCore.gypi (90217 => 90218)
--- trunk/Source/WebCore/WebCore.gypi 2011-07-01 07:52:20 UTC (rev 90217)
+++ trunk/Source/WebCore/WebCore.gypi 2011-07-01 08:37:49 UTC (rev 90218)
@@ -5718,6 +5718,7 @@
'svg/SVGAnimatedAngle.cpp',
'svg/SVGAnimatedBoolean.cpp',
'svg/SVGAnimatedColor.cpp',
+ 'svg/SVGAnimatedInteger.cpp',
'svg/SVGAnimatedLength.cpp',
'svg/SVGAnimatedLengthList.cpp',
'svg/SVGAnimatedNumber.cpp',
Modified: trunk/Source/WebCore/WebCore.pro (90217 => 90218)
--- trunk/Source/WebCore/WebCore.pro 2011-07-01 07:52:20 UTC (rev 90217)
+++ trunk/Source/WebCore/WebCore.pro 2011-07-01 08:37:49 UTC (rev 90218)
@@ -3332,6 +3332,7 @@
svg/SVGAnimatedAngle.cpp \
svg/SVGAnimatedBoolean.cpp \
svg/SVGAnimatedColor.cpp \
+ svg/SVGAnimatedInteger.cpp \
svg/SVGAnimatedLength.cpp \
svg/SVGAnimatedLengthList.cpp \
svg/SVGAnimatedNumber.cpp \
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (90217 => 90218)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-07-01 07:52:20 UTC (rev 90217)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-07-01 08:37:49 UTC (rev 90218)
@@ -1012,6 +1012,7 @@
43B9336913B261B1004584BF /* SVGAnimatedPointList.h in Headers */ = {isa = PBXBuildFile; fileRef = 43B9336713B261B1004584BF /* SVGAnimatedPointList.h */; };
43B9336A13B261B1004584BF /* SVGAnimatedPointList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B9336813B261B1004584BF /* SVGAnimatedPointList.cpp */; };
43C092BC12D9E4EE00A989C3 /* RenderSVGForeignObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 43C092BA12D9E4EE00A989C3 /* RenderSVGForeignObject.h */; };
+ 43F6FD9613BCD0B100224052 /* SVGAnimatedInteger.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43F6FD9513BCD0B100224052 /* SVGAnimatedInteger.cpp */; };
4415292E0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4415292C0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
4415292F0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4415292D0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.cpp */; };
441B055C0CD77A2D007C1F18 /* DOMHTMLEmbedElementPrivate.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 4429AAFB0CB84E88007647C5 /* DOMHTMLEmbedElementPrivate.h */; };
@@ -7505,6 +7506,7 @@
43B9336813B261B1004584BF /* SVGAnimatedPointList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedPointList.cpp; sourceTree = "<group>"; };
43C092B912D9E4EE00A989C3 /* RenderSVGForeignObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGForeignObject.cpp; sourceTree = "<group>"; };
43C092BA12D9E4EE00A989C3 /* RenderSVGForeignObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSVGForeignObject.h; sourceTree = "<group>"; };
+ 43F6FD9513BCD0B100224052 /* SVGAnimatedInteger.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedInteger.cpp; sourceTree = "<group>"; };
4415292C0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLPlugInImageElement.h; sourceTree = "<group>"; };
4415292D0E1AE8A000C4A2D0 /* HTMLPlugInImageElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLPlugInImageElement.cpp; sourceTree = "<group>"; };
4429AAFB0CB84E88007647C5 /* DOMHTMLEmbedElementPrivate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMHTMLEmbedElementPrivate.h; sourceTree = "<group>"; };
@@ -17400,6 +17402,7 @@
43A625F613B3304000AC94B8 /* SVGAnimatedColor.h */,
08D46CE2127AD5FC0089694B /* SVGAnimatedEnumeration.h */,
B22277E80D00BF1F0071B782 /* SVGAnimatedEnumeration.idl */,
+ 43F6FD9513BCD0B100224052 /* SVGAnimatedInteger.cpp */,
0823D158127AD6AC000EBC95 /* SVGAnimatedInteger.h */,
B22277E90D00BF1F0071B782 /* SVGAnimatedInteger.idl */,
4381763A13A697D4007D1187 /* SVGAnimatedLength.cpp */,
@@ -25843,6 +25846,7 @@
431A2FD713B7707A007791E4 /* SVGAnimatedLengthList.cpp in Sources */,
431A302113B89DCC007791E4 /* SVGAnimatedPreserveAspectRatio.cpp in Sources */,
431A308813B8F978007791E4 /* SVGAnimatedBoolean.cpp in Sources */,
+ 43F6FD9613BCD0B100224052 /* SVGAnimatedInteger.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: trunk/Source/WebCore/svg/SVGAllInOne.cpp (90217 => 90218)
--- trunk/Source/WebCore/svg/SVGAllInOne.cpp 2011-07-01 07:52:20 UTC (rev 90217)
+++ trunk/Source/WebCore/svg/SVGAllInOne.cpp 2011-07-01 08:37:49 UTC (rev 90218)
@@ -33,6 +33,7 @@
#include "SVGAnimatedAngle.cpp"
#include "SVGAnimatedBoolean.cpp"
#include "SVGAnimatedColor.cpp"
+#include "SVGAnimatedInteger.cpp"
#include "SVGAnimatedLength.cpp"
#include "SVGAnimatedLengthList.cpp"
#include "SVGAnimatedNumber.cpp"
Modified: trunk/Source/WebCore/svg/SVGAnimateElement.cpp (90217 => 90218)
--- trunk/Source/WebCore/svg/SVGAnimateElement.cpp 2011-07-01 07:52:20 UTC (rev 90217)
+++ trunk/Source/WebCore/svg/SVGAnimateElement.cpp 2011-07-01 08:37:49 UTC (rev 90218)
@@ -115,11 +115,12 @@
return AnimatedString;
case AnimatedColor:
return AnimatedColor;
+ case AnimatedInteger:
+ return AnimatedInteger;
case AnimatedLength:
return AnimatedLength;
case AnimatedLengthList:
return AnimatedLengthList;
- case AnimatedInteger:
case AnimatedNumber:
return AnimatedNumber;
case AnimatedNumberList:
@@ -166,6 +167,7 @@
case AnimatedAngle:
case AnimatedBoolean:
case AnimatedColor:
+ case AnimatedInteger:
case AnimatedLength:
case AnimatedLengthList:
case AnimatedNumber:
@@ -236,6 +238,7 @@
case AnimatedAngle:
case AnimatedBoolean:
case AnimatedColor:
+ case AnimatedInteger:
case AnimatedLength:
case AnimatedLengthList:
case AnimatedNumber:
@@ -267,6 +270,7 @@
case AnimatedAngle:
case AnimatedBoolean:
case AnimatedColor:
+ case AnimatedInteger:
case AnimatedLength:
case AnimatedLengthList:
case AnimatedNumber:
@@ -297,6 +301,7 @@
case AnimatedAngle:
case AnimatedBoolean:
case AnimatedColor:
+ case AnimatedInteger:
case AnimatedLength:
case AnimatedLengthList:
case AnimatedNumber:
@@ -326,6 +331,7 @@
case AnimatedAngle:
case AnimatedBoolean:
case AnimatedColor:
+ case AnimatedInteger:
case AnimatedLength:
case AnimatedLengthList:
case AnimatedNumber:
@@ -355,6 +361,7 @@
case AnimatedAngle:
case AnimatedBoolean:
case AnimatedColor:
+ case AnimatedInteger:
case AnimatedLength:
case AnimatedLengthList:
case AnimatedNumber:
Added: trunk/Source/WebCore/svg/SVGAnimatedInteger.cpp (0 => 90218)
--- trunk/Source/WebCore/svg/SVGAnimatedInteger.cpp (rev 0)
+++ trunk/Source/WebCore/svg/SVGAnimatedInteger.cpp 2011-07-01 08:37:49 UTC (rev 90218)
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) Research In Motion Limited 2011. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#if ENABLE(SVG) && ENABLE(SVG_ANIMATION)
+#include "SVGAnimatedInteger.h"
+
+#include "SVGAnimateElement.h"
+#include "SVGAnimatedNumber.h"
+#include <wtf/MathExtras.h>
+
+namespace WebCore {
+
+SVGAnimatedIntegerAnimator::SVGAnimatedIntegerAnimator(SVGAnimationElement* animationElement, SVGElement* contextElement)
+ : SVGAnimatedTypeAnimator(AnimatedInteger, animationElement, contextElement)
+{
+}
+
+PassOwnPtr<SVGAnimatedType> SVGAnimatedIntegerAnimator::constructFromString(const String& string)
+{
+ OwnPtr<SVGAnimatedType> animtedType = SVGAnimatedType::createInteger(new int);
+ animtedType->integer() = string.toIntStrict();
+ return animtedType.release();
+}
+
+void SVGAnimatedIntegerAnimator::calculateFromAndToValues(OwnPtr<SVGAnimatedType>& from, OwnPtr<SVGAnimatedType>& to, const String& fromString, const String& toString)
+{
+ ASSERT(m_contextElement);
+ ASSERT(m_animationElement);
+ SVGAnimateElement* animationElement = static_cast<SVGAnimateElement*>(m_animationElement);
+ animationElement->determinePropertyValueTypes(fromString, toString);
+
+ from = constructFromString(fromString);
+ to = constructFromString(toString);
+}
+
+void SVGAnimatedIntegerAnimator::calculateFromAndByValues(OwnPtr<SVGAnimatedType>& from, OwnPtr<SVGAnimatedType>& to, const String& fromString, const String& byString)
+{
+ ASSERT(m_contextElement);
+ ASSERT(m_animationElement);
+ SVGAnimateElement* animationElement = static_cast<SVGAnimateElement*>(m_animationElement);
+ animationElement->determinePropertyValueTypes(fromString, byString);
+
+ from = constructFromString(fromString);
+ to = constructFromString(byString);
+
+ to->integer() += from->integer();
+}
+
+void SVGAnimatedIntegerAnimator::calculateAnimatedValue(float percentage, unsigned repeatCount,
+ OwnPtr<SVGAnimatedType>& from, OwnPtr<SVGAnimatedType>& to, OwnPtr<SVGAnimatedType>& animated)
+{
+ ASSERT(m_animationElement);
+ ASSERT(m_contextElement);
+
+ SVGAnimateElement* animationElement = static_cast<SVGAnimateElement*>(m_animationElement);
+ AnimationMode animationMode = animationElement->animationMode();
+
+ // To animation uses contributions from the lower priority animations as the base value.
+ int& animatedInt = animated->integer();
+ if (animationMode == ToAnimation)
+ from->integer() = animatedInt;
+
+ float result = animatedInt;
+ SVGAnimatedNumberAnimator::calculateAnimatedNumber(animationElement, percentage, repeatCount, result, from->integer(), to->integer());
+ animatedInt = static_cast<int>(roundf(result));
+}
+
+float SVGAnimatedIntegerAnimator::calculateDistance(const String& fromString, const String& toString)
+{
+ ASSERT(m_contextElement);
+ int from = fromString.toIntStrict();
+ int to = toString.toIntStrict();
+ return abs(to - from);
+}
+
+}
+
+#endif // ENABLE(SVG) && ENABLE(SVG_ANIMATION)
Modified: trunk/Source/WebCore/svg/SVGAnimatedInteger.h (90217 => 90218)
--- trunk/Source/WebCore/svg/SVGAnimatedInteger.h 2011-07-01 07:52:20 UTC (rev 90217)
+++ trunk/Source/WebCore/svg/SVGAnimatedInteger.h 2011-07-01 08:37:49 UTC (rev 90218)
@@ -23,6 +23,7 @@
#if ENABLE(SVG)
#include "SVGAnimatedPropertyMacros.h"
#include "SVGAnimatedStaticPropertyTearOff.h"
+#include "SVGAnimatedTypeAnimator.h"
namespace WebCore {
@@ -38,6 +39,27 @@
#define DEFINE_ANIMATED_INTEGER_MULTIPLE_WRAPPERS(OwnerType, DOMAttribute, SVGDOMAttributeIdentifier, UpperProperty, LowerProperty) \
DEFINE_ANIMATED_PROPERTY(OwnerType, DOMAttribute, SVGDOMAttributeIdentifier, SVGAnimatedInteger, long, UpperProperty, LowerProperty)
+#if ENABLE(SVG_ANIMATION)
+class SVGAnimationElement;
+
+class SVGAnimatedIntegerAnimator : public SVGAnimatedTypeAnimator {
+
+public:
+ SVGAnimatedIntegerAnimator(SVGAnimationElement*, SVGElement*);
+ virtual ~SVGAnimatedIntegerAnimator() { }
+
+ static void calculateAnimatedNumber(SVGAnimationElement*, float percentage, unsigned repeatCount, float& animatedNumber, float fromNumber, float toNumber);
+
+ virtual PassOwnPtr<SVGAnimatedType> constructFromString(const String&);
+
+ virtual void calculateFromAndToValues(OwnPtr<SVGAnimatedType>& fromValue, OwnPtr<SVGAnimatedType>& toValue, const String& fromString, const String& toString);
+ virtual void calculateFromAndByValues(OwnPtr<SVGAnimatedType>& fromValue, OwnPtr<SVGAnimatedType>& toValue, const String& fromString, const String& byString);
+ virtual void calculateAnimatedValue(float percentage, unsigned repeatCount,
+ OwnPtr<SVGAnimatedType>& fromValue, OwnPtr<SVGAnimatedType>& toValue, OwnPtr<SVGAnimatedType>& animatedValue);
+ virtual float calculateDistance(const String& fromString, const String& toString);
+};
+#endif // ENABLE(SVG_ANIMATION)
+
} // namespace WebCore
#endif // ENABLE(SVG)
Modified: trunk/Source/WebCore/svg/SVGAnimatedType.cpp (90217 => 90218)
--- trunk/Source/WebCore/svg/SVGAnimatedType.cpp 2011-07-01 07:52:20 UTC (rev 90217)
+++ trunk/Source/WebCore/svg/SVGAnimatedType.cpp 2011-07-01 08:37:49 UTC (rev 90218)
@@ -54,6 +54,9 @@
case AnimatedColor:
delete m_data.color;
break;
+ case AnimatedInteger:
+ delete m_data.integer;
+ break;
case AnimatedLength:
delete m_data.length;
break;
@@ -114,6 +117,14 @@
return animatedType.release();
}
+PassOwnPtr<SVGAnimatedType> SVGAnimatedType::createInteger(int* integer)
+{
+ ASSERT(integer);
+ OwnPtr<SVGAnimatedType> animatedType = adoptPtr(new SVGAnimatedType(AnimatedInteger));
+ animatedType->m_data.integer = integer;
+ return animatedType.release();
+}
+
PassOwnPtr<SVGAnimatedType> SVGAnimatedType::createLength(SVGLength* length)
{
ASSERT(length);
@@ -212,6 +223,12 @@
return *m_data.color;
}
+int& SVGAnimatedType::integer()
+{
+ ASSERT(m_type == AnimatedInteger);
+ return *m_data.integer;
+}
+
SVGLength& SVGAnimatedType::length()
{
ASSERT(m_type == AnimatedLength);
@@ -284,6 +301,9 @@
case AnimatedColor:
ASSERT(m_data.color);
return m_data.color->serialized();
+ case AnimatedInteger:
+ ASSERT(m_data.integer);
+ return String::number(*m_data.integer);
case AnimatedLength:
ASSERT(m_data.length);
return m_data.length->valueAsString();
@@ -341,6 +361,14 @@
ASSERT(m_data.color);
*m_data.color = value.isEmpty() ? Color() : SVGColor::colorFromRGBColorString(value);
break;
+ case AnimatedInteger: {
+ ASSERT(m_data.integer);
+ bool ok;
+ *m_data.integer = value.toIntStrict(&ok);
+ if (!ok)
+ ec = 1; // Arbitary value > 0, it doesn't matter as we don't report the exception code.
+ break;
+ }
case AnimatedLength:
ASSERT(m_data.length);
m_data.length->setValueAsString(value, SVGLength::lengthModeForAnimatedLengthAttribute(attrName), ec);
Modified: trunk/Source/WebCore/svg/SVGAnimatedType.h (90217 => 90218)
--- trunk/Source/WebCore/svg/SVGAnimatedType.h 2011-07-01 07:52:20 UTC (rev 90217)
+++ trunk/Source/WebCore/svg/SVGAnimatedType.h 2011-07-01 08:37:49 UTC (rev 90218)
@@ -43,6 +43,7 @@
static PassOwnPtr<SVGAnimatedType> createAngle(SVGAngle*);
static PassOwnPtr<SVGAnimatedType> createBoolean(bool*);
static PassOwnPtr<SVGAnimatedType> createColor(Color*);
+ static PassOwnPtr<SVGAnimatedType> createInteger(int*);
static PassOwnPtr<SVGAnimatedType> createLength(SVGLength*);
static PassOwnPtr<SVGAnimatedType> createLengthList(SVGLengthList*);
static PassOwnPtr<SVGAnimatedType> createNumber(float*);
@@ -59,6 +60,7 @@
SVGAngle& angle();
bool& boolean();
Color& color();
+ int& integer();
SVGLength& length();
SVGLengthList& lengthList();
float& number();
@@ -90,6 +92,7 @@
SVGAngle* angle;
bool* boolean;
Color* color;
+ int* integer;
SVGLength* length;
SVGLengthList* lengthList;
float* number;
Modified: trunk/Source/WebCore/svg/SVGAnimatorFactory.h (90217 => 90218)
--- trunk/Source/WebCore/svg/SVGAnimatorFactory.h 2011-07-01 07:52:20 UTC (rev 90217)
+++ trunk/Source/WebCore/svg/SVGAnimatorFactory.h 2011-07-01 08:37:49 UTC (rev 90218)
@@ -24,6 +24,7 @@
#include "SVGAnimatedAngle.h"
#include "SVGAnimatedBoolean.h"
#include "SVGAnimatedColor.h"
+#include "SVGAnimatedInteger.h"
#include "SVGAnimatedLength.h"
#include "SVGAnimatedLengthList.h"
#include "SVGAnimatedNumber.h"
@@ -53,11 +54,12 @@
return adoptPtr(new SVGAnimatedBooleanAnimator(animationElement, contextElement));
case AnimatedColor:
return adoptPtr(new SVGAnimatedColorAnimator(animationElement, contextElement));
+ case AnimatedInteger:
+ return adoptPtr(new SVGAnimatedIntegerAnimator(animationElement, contextElement));
case AnimatedLength:
return adoptPtr(new SVGAnimatedLengthAnimator(animationElement, contextElement));
case AnimatedLengthList:
return adoptPtr(new SVGAnimatedLengthListAnimator(animationElement, contextElement));
- case AnimatedInteger: // Integer is animated as Number right now.
case AnimatedNumber:
return adoptPtr(new SVGAnimatedNumberAnimator(animationElement, contextElement));
case AnimatedNumberList: