Diff
Modified: trunk/LayoutTests/ChangeLog (89832 => 89833)
--- trunk/LayoutTests/ChangeLog 2011-06-27 17:26:32 UTC (rev 89832)
+++ trunk/LayoutTests/ChangeLog 2011-06-27 17:33:59 UTC (rev 89833)
@@ -1,3 +1,20 @@
+2011-06-27 Dirk Schulze <[email protected]>
+
+ Reviewed by Nikolas Zimmermann.
+
+ SVGAnimatedType should support SVGPreserveAspectRatio animation
+ https://bugs.webkit.org/show_bug.cgi?id=63456
+
+ Test for animation of SVGPreserveAspectRatio.
+
+ * svg/animations/script-tests/svgPreserveAspectRatio-animation-1.js: Added.
+ (sample1):
+ (sample2):
+ (sample3):
+ (executeTest):
+ * svg/animations/svgPreserveAspectRatio-animation-1-expected.txt: Added.
+ * svg/animations/svgPreserveAspectRatio-animation-1.html: Added.
+
2011-06-27 Ryosuke Niwa <[email protected]>
Reviewed by Kent Tamura.
Modified: trunk/LayoutTests/platform/mac-wk2/Skipped (89832 => 89833)
--- trunk/LayoutTests/platform/mac-wk2/Skipped 2011-06-27 17:26:32 UTC (rev 89832)
+++ trunk/LayoutTests/platform/mac-wk2/Skipped 2011-06-27 17:33:59 UTC (rev 89833)
@@ -485,6 +485,7 @@
svg/animations/svgnumberoptionalnumber-animation-4.html
svg/animations/svgpointlist-animation-1.html
svg/animations/svgpointlist-animation-2.html
+svg/animations/svgPreserveAspectRatio-animation-1.html
svg/animations/svgrect-animation-1.html
svg/animations/svgrect-animation-2.html
svg/animations/svgstring-animation-fallback-to-discrete.html
Added: trunk/LayoutTests/svg/animations/script-tests/svgPreserveAspectRatio-animation-1.js (0 => 89833)
--- trunk/LayoutTests/svg/animations/script-tests/svgPreserveAspectRatio-animation-1.js (rev 0)
+++ trunk/LayoutTests/svg/animations/script-tests/svgPreserveAspectRatio-animation-1.js 2011-06-27 17:33:59 UTC (rev 89833)
@@ -0,0 +1,55 @@
+description("Test 'to' animation of SVGPreserveAspectRatio.");
+createSVGTestCase();
+
+// Setup test document
+rootSVGElement.setAttribute("id", "root");
+rootSVGElement.setAttribute("preserveAspectRatio", "xMaxYMin meet");
+
+var rect = createSVGElement("rect");
+rect.setAttribute("id", "rect");
+rect.setAttribute("width", "100");
+rect.setAttribute("height", "100");
+rect.setAttribute("fill", "green");
+rect.setAttribute("onclick", "executeTest()");
+rootSVGElement.appendChild(rect);
+
+var animate = createSVGElement("animate");
+animate.setAttribute("id", "animation");
+animate.setAttribute("attributeName", "preserveAspectRatio");
+animate.setAttribute("begin", "rect.click");
+animate.setAttribute("dur", "4s");
+animate.setAttribute("from", "xMinYMin meet");
+animate.setAttribute("to", "xMaxYMid slice");
+rootSVGElement.appendChild(animate);
+
+// Setup animation test
+function sample1() {
+ shouldBe("rootSVGElement.preserveAspectRatio.animVal.align", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN");
+ shouldBe("rootSVGElement.preserveAspectRatio.animVal.meetOrSlice", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
+}
+
+function sample2() {
+ shouldBe("rootSVGElement.preserveAspectRatio.animVal.align", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN");
+ shouldBe("rootSVGElement.preserveAspectRatio.animVal.meetOrSlice", "SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET");
+}
+
+function sample3() {
+ shouldBe("rootSVGElement.preserveAspectRatio.animVal.align", "SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMID");
+ shouldBe("rootSVGElement.preserveAspectRatio.animVal.meetOrSlice", "SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE");
+}
+
+function executeTest() {
+ const expectedValues = [
+ // [animationId, time, elementId, sampleCallback]
+ ["animation", 0.0, "root", sample1],
+ ["animation", 2.0, "root", sample2],
+ ["animation", 3.9999, "root", sample3],
+ ["animation", 4.0 , "root", sample1]
+ ];
+
+ runAnimationTest(expectedValues);
+}
+
+// Begin test async
+window.setTimeout("triggerUpdate(50, 50)", 0);
+var successfullyParsed = true;
Added: trunk/LayoutTests/svg/animations/svgPreserveAspectRatio-animation-1-expected.txt (0 => 89833)
--- trunk/LayoutTests/svg/animations/svgPreserveAspectRatio-animation-1-expected.txt (rev 0)
+++ trunk/LayoutTests/svg/animations/svgPreserveAspectRatio-animation-1-expected.txt 2011-06-27 17:33:59 UTC (rev 89833)
@@ -0,0 +1,19 @@
+SVG 1.1 dynamic animation tests
+
+Test 'to' animation of SVGPreserveAspectRatio.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS rootSVGElement.preserveAspectRatio.animVal.align is SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN
+PASS rootSVGElement.preserveAspectRatio.animVal.meetOrSlice is SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET
+PASS rootSVGElement.preserveAspectRatio.animVal.align is SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMINYMIN
+PASS rootSVGElement.preserveAspectRatio.animVal.meetOrSlice is SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET
+PASS rootSVGElement.preserveAspectRatio.animVal.align is SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMID
+PASS rootSVGElement.preserveAspectRatio.animVal.meetOrSlice is SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE
+PASS rootSVGElement.preserveAspectRatio.animVal.align is SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMAXYMIN
+PASS rootSVGElement.preserveAspectRatio.animVal.meetOrSlice is SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/svg/animations/svgPreserveAspectRatio-animation-1.html (0 => 89833)
--- trunk/LayoutTests/svg/animations/svgPreserveAspectRatio-animation-1.html (rev 0)
+++ trunk/LayoutTests/svg/animations/svgPreserveAspectRatio-animation-1.html 2011-06-27 17:33:59 UTC (rev 89833)
@@ -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 (89832 => 89833)
--- trunk/Source/WebCore/CMakeLists.txt 2011-06-27 17:26:32 UTC (rev 89832)
+++ trunk/Source/WebCore/CMakeLists.txt 2011-06-27 17:33:59 UTC (rev 89833)
@@ -1665,6 +1665,7 @@
svg/SVGAnimatedNumberOptionalNumber.cpp
svg/SVGAnimatedPath.cpp
svg/SVGAnimatedPointList.cpp
+ svg/SVGAnimatedPreserveAspectRatio.cpp
svg/SVGAnimatedRect.cpp
svg/SVGAnimatedString.cpp
svg/SVGAnimatedType.cpp
Modified: trunk/Source/WebCore/ChangeLog (89832 => 89833)
--- trunk/Source/WebCore/ChangeLog 2011-06-27 17:26:32 UTC (rev 89832)
+++ trunk/Source/WebCore/ChangeLog 2011-06-27 17:33:59 UTC (rev 89833)
@@ -1,3 +1,52 @@
+2011-06-27 Dirk Schulze <[email protected]>
+
+ Reviewed by Nikolas Zimmermann.
+
+ SVGAnimatedType should support SVGPreserveAspectRatio animation
+ https://bugs.webkit.org/show_bug.cgi?id=63456
+
+ 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 SVGAnimatedPreserveAspectRatio.
+
+ The new animator does not affect any behavior, since it was animated with SVGAnimatedString before. The new animator is still needed
+ to support animVal and baseVal later.
+
+ Test: svg/animations/svgPreserveAspectRatio-animation-1.html
+
+ * CMakeLists.txt: Added new file.
+ * GNUmakefile.list.am: Ditto.
+ * WebCore.gypi: Ditto.
+ * WebCore.pro: Ditto.
+ * WebCore.xcodeproj/project.pbxproj: Ditto.
+ * svg/SVGAllInOne.cpp: Ditto.
+ * svg/SVGAnimateElement.cpp: Handle AnimatedPreserveAspectRatio.
+ (WebCore::SVGAnimateElement::determineAnimatedAttributeType):
+ (WebCore::SVGAnimateElement::calculateAnimatedValue):
+ (WebCore::SVGAnimateElement::calculateFromAndToValues):
+ (WebCore::SVGAnimateElement::calculateFromAndByValues):
+ (WebCore::SVGAnimateElement::resetToBaseValue):
+ (WebCore::SVGAnimateElement::applyResultsToTarget):
+ (WebCore::SVGAnimateElement::calculateDistance):
+ * svg/SVGAnimatedPreserveAspectRatio.cpp: Added. New animator for SVGAnimatedPreserveAspectRatio.
+ (WebCore::SVGAnimatedPreserveAspectRatioAnimator::SVGAnimatedPreserveAspectRatioAnimator):
+ (WebCore::SVGAnimatedPreserveAspectRatioAnimator::constructFromString):
+ (WebCore::SVGAnimatedPreserveAspectRatioAnimator::calculateFromAndToValues):
+ (WebCore::SVGAnimatedPreserveAspectRatioAnimator::calculateFromAndByValues):
+ (WebCore::SVGAnimatedPreserveAspectRatioAnimator::calculateAnimatedValue):
+ (WebCore::SVGAnimatedPreserveAspectRatioAnimator::calculateDistance):
+ * svg/SVGAnimatedPreserveAspectRatio.h:
+ (WebCore::SVGAnimatedPreserveAspectRatioAnimator::~SVGAnimatedPreserveAspectRatioAnimator):
+ * svg/SVGAnimatedType.cpp: Support for SVGPreserveAspectRatio.
+ (WebCore::SVGAnimatedType::~SVGAnimatedType):
+ (WebCore::SVGAnimatedType::createPreserveAspectRatio):
+ (WebCore::SVGAnimatedType::preserveAspectRatio):
+ (WebCore::SVGAnimatedType::valueAsString):
+ (WebCore::SVGAnimatedType::setValueAsString):
+ (WebCore::SVGAnimatedType::setPreserveAspectRatioBaseValue):
+ * svg/SVGAnimatedType.h:
+ * svg/SVGAnimatorFactory.h:
+ (WebCore::SVGAnimatorFactory::create):
+
2011-06-27 Alexis Menard <[email protected]>
Reviewed by Kenneth Rohde Christiansen.
Modified: trunk/Source/WebCore/GNUmakefile.list.am (89832 => 89833)
--- trunk/Source/WebCore/GNUmakefile.list.am 2011-06-27 17:26:32 UTC (rev 89832)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2011-06-27 17:33:59 UTC (rev 89833)
@@ -3442,6 +3442,7 @@
Source/WebCore/svg/SVGAnimatedPath.h \
Source/WebCore/svg/SVGAnimatedPointList.cpp \
Source/WebCore/svg/SVGAnimatedPointList.h \
+ Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.cpp \
Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.h \
Source/WebCore/svg/SVGAnimatedRect.cpp \
Source/WebCore/svg/SVGAnimatedRect.h \
Modified: trunk/Source/WebCore/WebCore.gypi (89832 => 89833)
--- trunk/Source/WebCore/WebCore.gypi 2011-06-27 17:26:32 UTC (rev 89832)
+++ trunk/Source/WebCore/WebCore.gypi 2011-06-27 17:33:59 UTC (rev 89833)
@@ -5716,6 +5716,7 @@
'svg/SVGAnimatedNumberOptionalNumber.cpp',
'svg/SVGAnimatedPath.cpp',
'svg/SVGAnimatedPointList.cpp',
+ 'svg/SVGAnimatedPreserveAspectRatio.cpp',
'svg/SVGAnimatedRect.cpp',
'svg/SVGAnimatedString.cpp',
'svg/SVGAnimatedType.cpp',
Modified: trunk/Source/WebCore/WebCore.pro (89832 => 89833)
--- trunk/Source/WebCore/WebCore.pro 2011-06-27 17:26:32 UTC (rev 89832)
+++ trunk/Source/WebCore/WebCore.pro 2011-06-27 17:33:59 UTC (rev 89833)
@@ -3339,6 +3339,7 @@
svg/SVGAnimatedNumberOptionalNumber.cpp \
svg/SVGAnimatedPath.cpp \
svg/SVGAnimatedPointList.cpp \
+ svg/SVGAnimatedPreserveAspectRatio.cpp \
svg/SVGAnimatedRect.cpp \
svg/SVGAnimatedString.cpp \
svg/SVGAnimatedType.cpp \
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (89832 => 89833)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-06-27 17:26:32 UTC (rev 89832)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-06-27 17:33:59 UTC (rev 89833)
@@ -934,6 +934,7 @@
431A2F9C13B6F2B0007791E4 /* SVGAnimatedNumberOptionalNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = 431A2F9A13B6F2B0007791E4 /* SVGAnimatedNumberOptionalNumber.h */; };
431A2F9D13B6F2B0007791E4 /* SVGAnimatedNumberOptionalNumber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 431A2F9B13B6F2B0007791E4 /* SVGAnimatedNumberOptionalNumber.cpp */; };
431A2FD713B7707A007791E4 /* SVGAnimatedLengthList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 431A2FD613B7707A007791E4 /* SVGAnimatedLengthList.cpp */; };
+ 431A302113B89DCC007791E4 /* SVGAnimatedPreserveAspectRatio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 431A302013B89DCC007791E4 /* SVGAnimatedPreserveAspectRatio.cpp */; };
4331AC7813B6870000A9E5AE /* SVGAnimatedNumberList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4331AC7713B6870000A9E5AE /* SVGAnimatedNumberList.cpp */; };
4358E86A1360A21600E4748C /* DOMSVGFEDropShadowElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4358E8671360A21600E4748C /* DOMSVGFEDropShadowElement.h */; };
4358E86B1360A21600E4748C /* DOMSVGFEDropShadowElement.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4358E8681360A21600E4748C /* DOMSVGFEDropShadowElement.mm */; };
@@ -7397,6 +7398,7 @@
431A2F9A13B6F2B0007791E4 /* SVGAnimatedNumberOptionalNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedNumberOptionalNumber.h; sourceTree = "<group>"; };
431A2F9B13B6F2B0007791E4 /* SVGAnimatedNumberOptionalNumber.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedNumberOptionalNumber.cpp; sourceTree = "<group>"; };
431A2FD613B7707A007791E4 /* SVGAnimatedLengthList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedLengthList.cpp; sourceTree = "<group>"; };
+ 431A302013B89DCC007791E4 /* SVGAnimatedPreserveAspectRatio.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedPreserveAspectRatio.cpp; sourceTree = "<group>"; };
4331AC7713B6870000A9E5AE /* SVGAnimatedNumberList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedNumberList.cpp; sourceTree = "<group>"; };
4358E8671360A21600E4748C /* DOMSVGFEDropShadowElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMSVGFEDropShadowElement.h; sourceTree = "<group>"; };
4358E8681360A21600E4748C /* DOMSVGFEDropShadowElement.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DOMSVGFEDropShadowElement.mm; sourceTree = "<group>"; };
@@ -17423,6 +17425,7 @@
0863951413B5FE5700BB344D /* SVGAnimatedPath.h */,
43B9336713B261B1004584BF /* SVGAnimatedPointList.h */,
43B9336813B261B1004584BF /* SVGAnimatedPointList.cpp */,
+ 431A302013B89DCC007791E4 /* SVGAnimatedPreserveAspectRatio.cpp */,
08FE0BC4127E2AC1000C4FB5 /* SVGAnimatedPreserveAspectRatio.h */,
B22277F40D00BF1F0071B782 /* SVGAnimatedPreserveAspectRatio.idl */,
43142E7913B1E97700F1C871 /* SVGAnimatedRect.cpp */,
@@ -25843,6 +25846,7 @@
4331AC7813B6870000A9E5AE /* SVGAnimatedNumberList.cpp in Sources */,
431A2F9D13B6F2B0007791E4 /* SVGAnimatedNumberOptionalNumber.cpp in Sources */,
431A2FD713B7707A007791E4 /* SVGAnimatedLengthList.cpp in Sources */,
+ 431A302113B89DCC007791E4 /* SVGAnimatedPreserveAspectRatio.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: trunk/Source/WebCore/svg/SVGAllInOne.cpp (89832 => 89833)
--- trunk/Source/WebCore/svg/SVGAllInOne.cpp 2011-06-27 17:26:32 UTC (rev 89832)
+++ trunk/Source/WebCore/svg/SVGAllInOne.cpp 2011-06-27 17:33:59 UTC (rev 89833)
@@ -39,6 +39,7 @@
#include "SVGAnimatedNumberOptionalNumber.cpp"
#include "SVGAnimatedPath.cpp"
#include "SVGAnimatedPointList.cpp"
+#include "SVGAnimatedPreserveAspectRatio.cpp"
#include "SVGAnimatedRect.cpp"
#include "SVGAnimatedString.cpp"
#include "SVGAnimatedType.cpp"
Modified: trunk/Source/WebCore/svg/SVGAnimateElement.cpp (89832 => 89833)
--- trunk/Source/WebCore/svg/SVGAnimateElement.cpp 2011-06-27 17:26:32 UTC (rev 89832)
+++ trunk/Source/WebCore/svg/SVGAnimateElement.cpp 2011-06-27 17:33:59 UTC (rev 89833)
@@ -104,14 +104,12 @@
if (type == AnimatedUnknown || (hasTagName(SVGNames::animateColorTag) && type != AnimatedColor))
return AnimatedUnknown;
- // FIXME: We need type specific animations in the future. Many animations marked as AnimatedString today will
- // support continuous animations.
+ // FIXME: Animator for AnimatedBoolean and AnimatedEnumeration missing.
switch (type) {
case AnimatedAngle:
return AnimatedAngle;
case AnimatedBoolean:
case AnimatedEnumeration:
- case AnimatedPreserveAspectRatio:
case AnimatedString:
return AnimatedString;
case AnimatedColor:
@@ -131,6 +129,8 @@
return AnimatedPath;
case AnimatedPoints:
return AnimatedPoints;
+ case AnimatedPreserveAspectRatio:
+ return AnimatedPreserveAspectRatio;
case AnimatedRect:
return AnimatedRect;
case AnimatedTransformList:
@@ -171,6 +171,7 @@
case AnimatedNumberOptionalNumber:
case AnimatedPath:
case AnimatedPoints:
+ case AnimatedPreserveAspectRatio:
case AnimatedRect:
case AnimatedString: {
ASSERT(m_animator);
@@ -239,6 +240,7 @@
case AnimatedNumberOptionalNumber:
case AnimatedPath:
case AnimatedPoints:
+ case AnimatedPreserveAspectRatio:
case AnimatedRect:
case AnimatedString:
ensureAnimator()->calculateFromAndToValues(m_fromType, m_toType, fromString, toString);
@@ -267,6 +269,7 @@
case AnimatedNumberList:
case AnimatedNumberOptionalNumber:
case AnimatedPoints:
+ case AnimatedPreserveAspectRatio:
case AnimatedRect:
case AnimatedString:
ensureAnimator()->calculateFromAndByValues(m_fromType, m_toType, fromString, byString);
@@ -296,6 +299,7 @@
case AnimatedNumberOptionalNumber:
case AnimatedPath:
case AnimatedPoints:
+ case AnimatedPreserveAspectRatio:
case AnimatedRect:
case AnimatedString: {
if (!m_animatedType)
@@ -323,6 +327,7 @@
case AnimatedNumberOptionalNumber:
case AnimatedPath:
case AnimatedPoints:
+ case AnimatedPreserveAspectRatio:
case AnimatedRect:
case AnimatedString:
valueToApply = m_animatedType->valueAsString();
@@ -350,6 +355,7 @@
case AnimatedNumberOptionalNumber:
case AnimatedPath:
case AnimatedPoints:
+ case AnimatedPreserveAspectRatio:
case AnimatedRect:
case AnimatedString:
return ensureAnimator()->calculateDistance(fromString, toString);
Added: trunk/Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.cpp (0 => 89833)
--- trunk/Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.cpp (rev 0)
+++ trunk/Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.cpp 2011-06-27 17:33:59 UTC (rev 89833)
@@ -0,0 +1,83 @@
+/*
+ * 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 "SVGAnimatedPreserveAspectRatio.h"
+
+#include "SVGAnimateElement.h"
+
+namespace WebCore {
+
+SVGAnimatedPreserveAspectRatioAnimator::SVGAnimatedPreserveAspectRatioAnimator(SVGAnimationElement* animationElement, SVGElement* contextElement)
+ : SVGAnimatedTypeAnimator(AnimatedPreserveAspectRatio, animationElement, contextElement)
+{
+}
+
+PassOwnPtr<SVGAnimatedType> SVGAnimatedPreserveAspectRatioAnimator::constructFromString(const String& string)
+{
+ OwnPtr<SVGAnimatedType> animatedType = SVGAnimatedType::createPreserveAspectRatio(new SVGPreserveAspectRatio);
+ SVGPreserveAspectRatio::parsePreserveAspectRatio(animatedType.get(), string);
+ return animatedType.release();
+}
+
+void SVGAnimatedPreserveAspectRatioAnimator::calculateFromAndToValues(OwnPtr<SVGAnimatedType>& from, OwnPtr<SVGAnimatedType>& to, const String& fromString, const String& toString)
+{
+ ASSERT(m_contextElement);
+ ASSERT(m_animationElement);
+
+ from = constructFromString(fromString);
+ to = constructFromString(toString);
+}
+
+void SVGAnimatedPreserveAspectRatioAnimator::calculateFromAndByValues(OwnPtr<SVGAnimatedType>& from, OwnPtr<SVGAnimatedType>& to, const String& fromString, const String& byString)
+{
+ ASSERT(m_contextElement);
+ ASSERT(m_animationElement);
+
+ // Not specified what to do on 'by'-animations with SVGPreserveAspectRatio. Fallback to 'to'-animation right now.
+ from = constructFromString(fromString);
+ to = constructFromString(byString);
+}
+
+void SVGAnimatedPreserveAspectRatioAnimator::calculateAnimatedValue(float percentage, unsigned,
+ 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();
+ SVGPreserveAspectRatio& animateString = animated->preserveAspectRatio();
+ if ((animationMode == FromToAnimation && percentage > 0.5) || animationMode == ToAnimation || percentage == 1)
+ animateString = to->preserveAspectRatio();
+ else
+ animateString = from->preserveAspectRatio();
+}
+
+float SVGAnimatedPreserveAspectRatioAnimator::calculateDistance(const String&, const String&)
+{
+ // No paced animations for SVGPreserveAspectRatio.
+ return -1;
+}
+
+}
+
+#endif // ENABLE(SVG) && ENABLE(SVG_ANIMATION)
Modified: trunk/Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.h (89832 => 89833)
--- trunk/Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.h 2011-06-27 17:26:32 UTC (rev 89832)
+++ trunk/Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.h 2011-06-27 17:33:59 UTC (rev 89833)
@@ -22,6 +22,7 @@
#if ENABLE(SVG)
#include "SVGAnimatedPropertyTearOff.h"
+#include "SVGAnimatedTypeAnimator.h"
#include "SVGPreserveAspectRatio.h"
namespace WebCore {
@@ -35,6 +36,26 @@
#define DEFINE_ANIMATED_PRESERVEASPECTRATIO(OwnerType, DOMAttribute, UpperProperty, LowerProperty) \
DEFINE_ANIMATED_PROPERTY(OwnerType, DOMAttribute, DOMAttribute.localName(), SVGAnimatedPreserveAspectRatio, SVGPreserveAspectRatio, UpperProperty, LowerProperty)
+
+#if ENABLE(SVG_ANIMATION)
+class SVGAnimationElement;
+
+class SVGAnimatedPreserveAspectRatioAnimator : public SVGAnimatedTypeAnimator {
+
+public:
+ SVGAnimatedPreserveAspectRatioAnimator(SVGAnimationElement*, SVGElement*);
+ virtual ~SVGAnimatedPreserveAspectRatioAnimator() { }
+
+ 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 (89832 => 89833)
--- trunk/Source/WebCore/svg/SVGAnimatedType.cpp 2011-06-27 17:26:32 UTC (rev 89832)
+++ trunk/Source/WebCore/svg/SVGAnimatedType.cpp 2011-06-27 17:33:59 UTC (rev 89833)
@@ -31,6 +31,7 @@
#include "SVGParserUtilities.h"
#include "SVGPathParserFactory.h"
#include "SVGPointList.h"
+#include "SVGPreserveAspectRatio.h"
using namespace std;
@@ -71,6 +72,9 @@
case AnimatedPoints:
delete m_data.pointList;
break;
+ case AnimatedPreserveAspectRatio:
+ delete m_data.preserveAspectRatio;
+ break;
case AnimatedRect:
delete m_data.rect;
break;
@@ -155,6 +159,14 @@
return animatedType.release();
}
+PassOwnPtr<SVGAnimatedType> SVGAnimatedType::createPreserveAspectRatio(SVGPreserveAspectRatio* preserveAspectRatio)
+{
+ ASSERT(preserveAspectRatio);
+ OwnPtr<SVGAnimatedType> animatedType = adoptPtr(new SVGAnimatedType(AnimatedPreserveAspectRatio));
+ animatedType->m_data.preserveAspectRatio = preserveAspectRatio;
+ return animatedType.release();
+}
+
PassOwnPtr<SVGAnimatedType> SVGAnimatedType::createRect(FloatRect* rect)
{
ASSERT(rect);
@@ -225,6 +237,12 @@
return *m_data.pointList;
}
+SVGPreserveAspectRatio& SVGAnimatedType::preserveAspectRatio()
+{
+ ASSERT(m_type == AnimatedPreserveAspectRatio);
+ return *m_data.preserveAspectRatio;
+}
+
FloatRect& SVGAnimatedType::rect()
{
ASSERT(m_type == AnimatedRect);
@@ -270,6 +288,9 @@
case AnimatedPoints:
ASSERT(m_data.pointList);
return m_data.pointList->valueAsString();
+ case AnimatedPreserveAspectRatio:
+ ASSERT(m_data.preserveAspectRatio);
+ return m_data.preserveAspectRatio->valueAsString();
case AnimatedRect:
ASSERT(m_data.rect);
return String::number(m_data.rect->x()) + ' ' + String::number(m_data.rect->y()) + ' '
@@ -329,6 +350,10 @@
m_data.pointList->clear();
pointsListFromSVGData(*m_data.pointList, value);
break;
+ case AnimatedPreserveAspectRatio:
+ ASSERT(m_data.preserveAspectRatio);
+ SVGPreserveAspectRatio::parsePreserveAspectRatio(this, value);
+ break;
case AnimatedRect:
ASSERT(m_data.rect);
parseRect(value, *m_data.rect);
@@ -344,6 +369,13 @@
return !ec;
}
+void SVGAnimatedType::setPreserveAspectRatioBaseValue(const SVGPreserveAspectRatio& preserveAspectRatio)
+{
+ ASSERT(m_type == AnimatedPreserveAspectRatio);
+ *m_data.preserveAspectRatio = preserveAspectRatio;
+}
+
+
} // namespace WebCore
#endif // ENABLE(SVG) && ENABLE(SVG_ANIMATION)
Modified: trunk/Source/WebCore/svg/SVGAnimatedType.h (89832 => 89833)
--- trunk/Source/WebCore/svg/SVGAnimatedType.h 2011-06-27 17:26:32 UTC (rev 89832)
+++ trunk/Source/WebCore/svg/SVGAnimatedType.h 2011-06-27 17:33:59 UTC (rev 89833)
@@ -33,6 +33,7 @@
class SVGNumberList;
class SVGPathByteStream;
class SVGPointList;
+class SVGPreserveAspectRatio;
class SVGAnimatedType {
WTF_MAKE_FAST_ALLOCATED;
@@ -48,6 +49,7 @@
static PassOwnPtr<SVGAnimatedType> createNumberOptionalNumber(std::pair<float, float>*);
static PassOwnPtr<SVGAnimatedType> createPath(PassOwnPtr<SVGPathByteStream>);
static PassOwnPtr<SVGAnimatedType> createPointList(SVGPointList*);
+ static PassOwnPtr<SVGAnimatedType> createPreserveAspectRatio(SVGPreserveAspectRatio*);
static PassOwnPtr<SVGAnimatedType> createRect(FloatRect*);
static PassOwnPtr<SVGAnimatedType> createString(String*);
@@ -62,11 +64,15 @@
std::pair<float, float>& numberOptionalNumber();
SVGPathByteStream* path();
SVGPointList& pointList();
+ SVGPreserveAspectRatio& preserveAspectRatio();
FloatRect& rect();
String& string();
String valueAsString();
bool setValueAsString(const QualifiedName&, const String&);
+
+ // Used for parsing a String to a SVGPreserveAspectRatio object.
+ void setPreserveAspectRatioBaseValue(const SVGPreserveAspectRatio&);
private:
SVGAnimatedType(AnimatedAttributeType);
@@ -79,7 +85,6 @@
{
}
- // FIXME: More SVG primitive types need to be added step by step.
SVGAngle* angle;
Color* color;
SVGLength* length;
@@ -88,6 +93,7 @@
SVGNumberList* numberList;
std::pair<float, float>* numberOptionalNumber;
SVGPathByteStream* path;
+ SVGPreserveAspectRatio* preserveAspectRatio;
SVGPointList* pointList;
FloatRect* rect;
String* string;
Modified: trunk/Source/WebCore/svg/SVGAnimatorFactory.h (89832 => 89833)
--- trunk/Source/WebCore/svg/SVGAnimatorFactory.h 2011-06-27 17:26:32 UTC (rev 89832)
+++ trunk/Source/WebCore/svg/SVGAnimatorFactory.h 2011-06-27 17:33:59 UTC (rev 89833)
@@ -30,6 +30,7 @@
#include "SVGAnimatedNumberOptionalNumber.h"
#include "SVGAnimatedPath.h"
#include "SVGAnimatedPointList.h"
+#include "SVGAnimatedPreserveAspectRatio.h"
#include "SVGAnimatedRect.h"
#include "SVGAnimatedString.h"
@@ -64,6 +65,8 @@
return adoptPtr(new SVGAnimatedPathAnimator(animationElement, contextElement));
case AnimatedPoints:
return adoptPtr(new SVGAnimatedPointListAnimator(animationElement, contextElement));
+ case AnimatedPreserveAspectRatio:
+ return adoptPtr(new SVGAnimatedPreserveAspectRatioAnimator(animationElement, contextElement));
case AnimatedRect:
return adoptPtr(new SVGAnimatedRectAnimator(animationElement, contextElement));
case AnimatedString: