Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (89748 => 89749)
--- trunk/Source/WebCore/CMakeLists.txt 2011-06-25 21:20:22 UTC (rev 89748)
+++ trunk/Source/WebCore/CMakeLists.txt 2011-06-25 21:36:56 UTC (rev 89749)
@@ -1660,6 +1660,7 @@
svg/SVGAnimatedColor.cpp
svg/SVGAnimatedLength.cpp
svg/SVGAnimatedNumber.cpp
+ svg/SVGAnimatedPath.cpp
svg/SVGAnimatedPointList.cpp
svg/SVGAnimatedRect.cpp
svg/SVGAnimatedString.cpp
Modified: trunk/Source/WebCore/ChangeLog (89748 => 89749)
--- trunk/Source/WebCore/ChangeLog 2011-06-25 21:20:22 UTC (rev 89748)
+++ trunk/Source/WebCore/ChangeLog 2011-06-25 21:36:56 UTC (rev 89749)
@@ -1,3 +1,56 @@
+2011-06-25 Nikolas Zimmermann <[email protected]>
+
+ Reviewed by Dirk Schulze.
+
+ Convert SVGPath to SVGAnimatorFactory concept
+ https://bugs.webkit.org/show_bug.cgi?id=63336
+
+ Convert <animate attributeName="d"> parsing to the new SVGAnimatorFactory concept, removing
+ the last special data types from SVGAnimateElement: SVGPathByteStream m_fromPath/m_toPath/m_animatedPath.
+ All existing non-string primitives have been converted to the new concept.
+
+ Doesn't change any functionality.
+
+ * CMakeLists.txt: Added SVGAnimatedPath.*.
+ * GNUmakefile.list.am: Ditto.
+ * WebCore.gypi: Ditto.
+ * WebCore.pro: Ditto.
+ * WebCore.vcproj/WebCore.vcproj: Ditto.
+ * WebCore.xcodeproj/project.pbxproj: Ditto.
+ * svg/SVGAllInOne.cpp: Ditto.
+ * svg/SVGAnimateElement.cpp:
+ (WebCore::SVGAnimateElement::SVGAnimateElement):
+ (WebCore::SVGAnimateElement::calculateAnimatedValue):
+ (WebCore::SVGAnimateElement::calculateFromAndToValues):
+ (WebCore::SVGAnimateElement::calculateFromAndByValues):
+ (WebCore::SVGAnimateElement::resetToBaseValue):
+ (WebCore::SVGAnimateElement::applyResultsToTarget):
+ * svg/SVGAnimateElement.h:
+ * svg/SVGAnimatedPath.cpp: Added.
+ (WebCore::SVGAnimatedPathAnimator::SVGAnimatedPathAnimator):
+ (WebCore::SVGAnimatedPathAnimator::constructFromString):
+ (WebCore::SVGAnimatedPathAnimator::calculateFromAndToValues):
+ (WebCore::SVGAnimatedPathAnimator::calculateFromAndByValues):
+ (WebCore::SVGAnimatedPathAnimator::calculateAnimatedValue):
+ (WebCore::SVGAnimatedPathAnimator::calculateDistance):
+ * svg/SVGAnimatedPath.h: Added.
+ (WebCore::SVGAnimatedPathAnimator::~SVGAnimatedPathAnimator):
+ * svg/SVGAnimatedType.cpp:
+ (WebCore::SVGAnimatedType::~SVGAnimatedType):
+ (WebCore::SVGAnimatedType::createPath):
+ (WebCore::SVGAnimatedType::path):
+ (WebCore::SVGAnimatedType::valueAsString):
+ (WebCore::SVGAnimatedType::setValueAsString):
+ * svg/SVGAnimatedType.h:
+ * svg/SVGAnimatorFactory.h:
+ (WebCore::SVGAnimatorFactory::create):
+ * svg/SVGPathByteStream.h:
+ (WebCore::SVGPathByteStream::initializeFrom):
+ * svg/SVGPathParserFactory.cpp:
+ (WebCore::SVGPathParserFactory::buildSVGPathByteStreamFromSVGPathSegList):
+ (WebCore::SVGPathParserFactory::buildSVGPathByteStreamFromString):
+ (WebCore::SVGPathParserFactory::buildAnimatedSVGPathByteStream):
+
2011-06-25 Jer Noble <[email protected]>
Reviewed by Maciej Stachowiak.
Modified: trunk/Source/WebCore/GNUmakefile.list.am (89748 => 89749)
--- trunk/Source/WebCore/GNUmakefile.list.am 2011-06-25 21:20:22 UTC (rev 89748)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2011-06-25 21:36:56 UTC (rev 89749)
@@ -3434,6 +3434,8 @@
Source/WebCore/svg/SVGAnimatedNumber.cpp \
Source/WebCore/svg/SVGAnimatedNumber.h \
Source/WebCore/svg/SVGAnimatedNumberList.h \
+ Source/WebCore/svg/SVGAnimatedPath.cpp \
+ Source/WebCore/svg/SVGAnimatedPath.h \
Source/WebCore/svg/SVGAnimatedPointList.cpp \
Source/WebCore/svg/SVGAnimatedPointList.h \
Source/WebCore/svg/SVGAnimatedPreserveAspectRatio.h \
Modified: trunk/Source/WebCore/WebCore.gypi (89748 => 89749)
--- trunk/Source/WebCore/WebCore.gypi 2011-06-25 21:20:22 UTC (rev 89748)
+++ trunk/Source/WebCore/WebCore.gypi 2011-06-25 21:36:56 UTC (rev 89749)
@@ -1052,6 +1052,7 @@
'svg/SVGAnimatedLengthList.h',
'svg/SVGAnimatedNumber.h',
'svg/SVGAnimatedNumberList.h',
+ 'svg/SVGAnimatedPath.h',
'svg/SVGAnimatedPointList.h',
'svg/SVGAnimatedPreserveAspectRatio.h',
'svg/SVGAnimatedRect.h',
@@ -5711,6 +5712,7 @@
'svg/SVGAnimatedColor.cpp',
'svg/SVGAnimatedLength.cpp',
'svg/SVGAnimatedNumber.cpp',
+ 'svg/SVGAnimatedPath.cpp',
'svg/SVGAnimatedPointList.cpp',
'svg/SVGAnimatedRect.cpp',
'svg/SVGAnimatedString.cpp',
Modified: trunk/Source/WebCore/WebCore.pro (89748 => 89749)
--- trunk/Source/WebCore/WebCore.pro 2011-06-25 21:20:22 UTC (rev 89748)
+++ trunk/Source/WebCore/WebCore.pro 2011-06-25 21:36:56 UTC (rev 89749)
@@ -2335,6 +2335,7 @@
svg/SVGAnimatedLengthList.h \
svg/SVGAnimatedNumber.h \
svg/SVGAnimatedNumberList.h \
+ svg/SVGAnimatedPath.h \
svg/SVGAnimatedPreserveAspectRatio.h \
svg/SVGAnimatedPointList.h \
svg/SVGAnimatedRect.h \
@@ -3338,6 +3339,7 @@
svg/SVGAnimatedColor.cpp \
svg/SVGAnimatedLength.cpp \
svg/SVGAnimatedNumber.cpp \
+ svg/SVGAnimatedPath.cpp \
svg/SVGAnimatedPointList.cpp \
svg/SVGAnimatedRect.cpp \
svg/SVGAnimatedString.cpp \
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (89748 => 89749)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-06-25 21:20:22 UTC (rev 89748)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-06-25 21:36:56 UTC (rev 89749)
@@ -65402,6 +65402,10 @@
>
</File>
<File
+ RelativePath="..\svg\SVGAnimatedPath.h"
+ >
+ </File>
+ <File
RelativePath="..\svg\SVGAnimatedPreserveAspectRatio.h"
>
</File>
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (89748 => 89749)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-06-25 21:20:22 UTC (rev 89748)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-06-25 21:36:56 UTC (rev 89749)
@@ -110,6 +110,7 @@
085B92BA0EFDE73D00E6123C /* FormDataBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 085B92B80EFDE73D00E6123C /* FormDataBuilder.cpp */; };
085B92BB0EFDE73D00E6123C /* FormDataBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 085B92B90EFDE73D00E6123C /* FormDataBuilder.h */; settings = {ATTRIBUTES = (); }; };
085CD275138BB8E000907F2D /* SVGTextRunRenderingContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 085CD274138BB8E000907F2D /* SVGTextRunRenderingContext.h */; };
+ 0863951613B5FE5700BB344D /* SVGAnimatedPath.h in Headers */ = {isa = PBXBuildFile; fileRef = 0863951413B5FE5700BB344D /* SVGAnimatedPath.h */; settings = {ATTRIBUTES = (Private, ); }; };
08641D4712142F7D008DE9F6 /* RenderImageResourceStyleImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08641D4512142F7D008DE9F6 /* RenderImageResourceStyleImage.cpp */; };
08641D4812142F7D008DE9F6 /* RenderImageResourceStyleImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 08641D4612142F7D008DE9F6 /* RenderImageResourceStyleImage.h */; settings = {ATTRIBUTES = (Private, ); }; };
086BBD0F136039C2008B15D8 /* Glyph.h in Headers */ = {isa = PBXBuildFile; fileRef = 086BBD0E136039C2008B15D8 /* Glyph.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -147,6 +148,7 @@
08A48A6E0E86CF6D00E225DD /* JSSVGElementInstanceCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08A48A6D0E86CF6D00E225DD /* JSSVGElementInstanceCustom.cpp */; };
08B35B13127B6A7C005314DD /* SVGAnimatedNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = 08B35B12127B6A7C005314DD /* SVGAnimatedNumber.h */; settings = {ATTRIBUTES = (Private, ); }; };
08B35B17127B6A88005314DD /* SVGAnimatedNumberList.h in Headers */ = {isa = PBXBuildFile; fileRef = 08B35B16127B6A88005314DD /* SVGAnimatedNumberList.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 08B5F25513B5FFF2002959EC /* SVGAnimatedPath.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0863951313B5FE5700BB344D /* SVGAnimatedPath.cpp */; };
08C7136E128956A3001B107E /* SVGTransformListPropertyTearOff.h in Headers */ = {isa = PBXBuildFile; fileRef = 08C7136D128956A3001B107E /* SVGTransformListPropertyTearOff.h */; settings = {ATTRIBUTES = (Private, ); }; };
08C7A2C710DC7462002D368B /* SVGNames.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 656581E909D1508D000E61D7 /* SVGNames.h */; };
08C859C01274575400A5728D /* SVGAnimatedRect.h in Headers */ = {isa = PBXBuildFile; fileRef = 08C859BF1274575300A5728D /* SVGAnimatedRect.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -6477,6 +6479,8 @@
085B92B80EFDE73D00E6123C /* FormDataBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FormDataBuilder.cpp; sourceTree = "<group>"; };
085B92B90EFDE73D00E6123C /* FormDataBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FormDataBuilder.h; sourceTree = "<group>"; };
085CD274138BB8E000907F2D /* SVGTextRunRenderingContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGTextRunRenderingContext.h; sourceTree = "<group>"; };
+ 0863951313B5FE5700BB344D /* SVGAnimatedPath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedPath.cpp; sourceTree = "<group>"; };
+ 0863951413B5FE5700BB344D /* SVGAnimatedPath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPath.h; sourceTree = "<group>"; };
08641D4512142F7D008DE9F6 /* RenderImageResourceStyleImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderImageResourceStyleImage.cpp; sourceTree = "<group>"; };
08641D4612142F7D008DE9F6 /* RenderImageResourceStyleImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderImageResourceStyleImage.h; sourceTree = "<group>"; };
086BBD0E136039C2008B15D8 /* Glyph.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Glyph.h; sourceTree = "<group>"; };
@@ -17403,6 +17407,8 @@
B22277EC0D00BF1F0071B782 /* SVGAnimatedNumber.idl */,
08B35B16127B6A88005314DD /* SVGAnimatedNumberList.h */,
B22277ED0D00BF1F0071B782 /* SVGAnimatedNumberList.idl */,
+ 0863951313B5FE5700BB344D /* SVGAnimatedPath.cpp */,
+ 0863951413B5FE5700BB344D /* SVGAnimatedPath.h */,
43B9336713B261B1004584BF /* SVGAnimatedPointList.h */,
43B9336813B261B1004584BF /* SVGAnimatedPointList.cpp */,
08FE0BC4127E2AC1000C4FB5 /* SVGAnimatedPreserveAspectRatio.h */,
@@ -23056,6 +23062,7 @@
43B9336913B261B1004584BF /* SVGAnimatedPointList.h in Headers */,
43A625F813B3304000AC94B8 /* SVGAnimatedColor.h in Headers */,
087558C613B4A57D00F49307 /* SurrogatePairAwareTextIterator.h in Headers */,
+ 0863951613B5FE5700BB344D /* SVGAnimatedPath.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -25818,6 +25825,7 @@
43A625F913B3304000AC94B8 /* SVGAnimatedColor.cpp in Sources */,
43A6266713B3D11000AC94B8 /* SVGAnimatedString.cpp in Sources */,
087558C513B4A57D00F49307 /* SurrogatePairAwareTextIterator.cpp in Sources */,
+ 08B5F25513B5FFF2002959EC /* SVGAnimatedPath.cpp in Sources */,
376DCCE113B4F966002EBEFC /* TextRun.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Modified: trunk/Source/WebCore/svg/SVGAllInOne.cpp (89748 => 89749)
--- trunk/Source/WebCore/svg/SVGAllInOne.cpp 2011-06-25 21:20:22 UTC (rev 89748)
+++ trunk/Source/WebCore/svg/SVGAllInOne.cpp 2011-06-25 21:36:56 UTC (rev 89749)
@@ -34,6 +34,7 @@
#include "SVGAnimatedColor.cpp"
#include "SVGAnimatedLength.cpp"
#include "SVGAnimatedNumber.cpp"
+#include "SVGAnimatedPath.cpp"
#include "SVGAnimatedPointList.cpp"
#include "SVGAnimatedRect.cpp"
#include "SVGAnimatedString.cpp"
Modified: trunk/Source/WebCore/svg/SVGAnimateElement.cpp (89748 => 89749)
--- trunk/Source/WebCore/svg/SVGAnimateElement.cpp 2011-06-25 21:20:22 UTC (rev 89748)
+++ trunk/Source/WebCore/svg/SVGAnimateElement.cpp 2011-06-25 21:36:56 UTC (rev 89749)
@@ -32,7 +32,6 @@
#include "RenderObject.h"
#include "SVGAnimatorFactory.h"
#include "SVGNames.h"
-#include "SVGPathParserFactory.h"
#include "SVGStyledElement.h"
using namespace std;
@@ -44,7 +43,6 @@
, m_animatedAttributeType(AnimatedString)
, m_fromPropertyValueType(RegularPropertyValue)
, m_toPropertyValueType(RegularPropertyValue)
- , m_animatedPathPointer(0)
{
ASSERT(hasTagName(SVGNames::animateTag) || hasTagName(SVGNames::setTag) || hasTagName(SVGNames::animateColorTag));
}
@@ -147,7 +145,6 @@
{
ASSERT(percentage >= 0 && percentage <= 1);
ASSERT(resultElement);
- AnimationMode animationMode = this->animationMode();
SVGElement* targetElement = this->targetElement();
if (!targetElement)
return;
@@ -162,43 +159,11 @@
if (results->m_animatedAttributeType == AnimatedString && m_animatedAttributeType != AnimatedString)
return;
switch (m_animatedAttributeType) {
- case AnimatedPath: {
- if (animationMode == ToAnimation) {
- ASSERT(results->m_animatedPathPointer);
- m_fromPath = results->m_animatedPathPointer->copy();
- }
- if (!percentage) {
- ASSERT(m_fromPath);
- ASSERT(percentage >= 0);
- results->m_animatedPathPointer = m_fromPath.get();
- } else if (percentage == 1) {
- ASSERT(m_toPath);
- results->m_animatedPathPointer = m_toPath.get();
- } else {
- if (m_fromPath && m_toPath) {
- SVGPathParserFactory* factory = SVGPathParserFactory::self();
- if (!factory->buildAnimatedSVGPathByteStream(m_fromPath.get(), m_toPath.get(), results->m_animatedPath, percentage)) {
- results->m_animatedPath.clear();
- results->m_animatedPathPointer = 0;
- } else
- results->m_animatedPathPointer = results->m_animatedPath.get();
- } else
- results->m_animatedPathPointer = 0;
- // Fall back to discrete animation if the paths are not compatible
- if (!results->m_animatedPathPointer) {
- ASSERT(m_fromPath);
- ASSERT(m_toPath);
- ASSERT(!results->m_animatedPath);
- results->m_animatedPathPointer = ((animationMode == FromToAnimation && percentage > 0.5f) || animationMode == ToAnimation || percentage == 1)
- ? m_toPath.get() : m_fromPath.get();
- }
- }
- return;
- }
case AnimatedAngle:
case AnimatedColor:
case AnimatedLength:
case AnimatedNumber:
+ case AnimatedPath:
case AnimatedPoints:
case AnimatedRect:
case AnimatedString: {
@@ -259,21 +224,11 @@
// FIXME: Needs more solid way determine target attribute type.
m_animatedAttributeType = determineAnimatedAttributeType(targetElement);
switch (m_animatedAttributeType) {
- case AnimatedPath: {
- SVGPathParserFactory* factory = SVGPathParserFactory::self();
- if (factory->buildSVGPathByteStreamFromString(toString, m_toPath, UnalteredParsing)) {
- // For to-animations the from number is calculated later
- if (animationMode() == ToAnimation || factory->buildSVGPathByteStreamFromString(fromString, m_fromPath, UnalteredParsing))
- return true;
- }
- m_fromPath.clear();
- m_toPath.clear();
- break;
- }
case AnimatedAngle:
case AnimatedColor:
case AnimatedLength:
case AnimatedNumber:
+ case AnimatedPath:
case AnimatedPoints:
case AnimatedRect:
case AnimatedString:
@@ -304,6 +259,9 @@
case AnimatedString:
ensureAnimator()->calculateFromAndByValues(m_fromType, m_toType, fromString, byString);
return true;
+ case AnimatedPath:
+ ASSERT_NOT_REACHED(); // This state is not reachable for now.
+ break;
default:
break;
}
@@ -317,17 +275,11 @@
ASSERT(targetElement);
m_animatedAttributeType = determineAnimatedAttributeType(targetElement);
switch (m_animatedAttributeType) {
- case AnimatedPath: {
- m_animatedPath.clear();
- SVGPathParserFactory* factory = SVGPathParserFactory::self();
- factory->buildSVGPathByteStreamFromString(baseString, m_animatedPath, UnalteredParsing);
- m_animatedPathPointer = m_animatedPath.get();
- return;
- }
case AnimatedAngle:
case AnimatedColor:
case AnimatedLength:
case AnimatedNumber:
+ case AnimatedPath:
case AnimatedPoints:
case AnimatedRect:
case AnimatedString: {
@@ -347,23 +299,11 @@
{
String valueToApply;
switch (m_animatedAttributeType) {
- case AnimatedPath: {
- if (!m_animatedPathPointer || m_animatedPathPointer->isEmpty())
- valueToApply = String();
- else {
- // We need to keep going to string and back because we are currently only able to paint
- // "processed" paths where complex shapes are replaced with simpler ones. Path
- // morphing needs to be done with unprocessed paths.
- // FIXME: This could be optimized if paths were not processed at parse time.
- SVGPathParserFactory* factory = SVGPathParserFactory::self();
- factory->buildStringFromByteStream(m_animatedPathPointer, valueToApply, UnalteredParsing);
- }
- break;
- }
case AnimatedAngle:
case AnimatedColor:
case AnimatedLength:
case AnimatedNumber:
+ case AnimatedPath:
case AnimatedPoints:
case AnimatedRect:
case AnimatedString:
@@ -387,6 +327,7 @@
case AnimatedColor:
case AnimatedLength:
case AnimatedNumber:
+ case AnimatedPath:
case AnimatedPoints:
case AnimatedRect:
case AnimatedString:
Modified: trunk/Source/WebCore/svg/SVGAnimateElement.h (89748 => 89749)
--- trunk/Source/WebCore/svg/SVGAnimateElement.h 2011-06-25 21:20:22 UTC (rev 89748)
+++ trunk/Source/WebCore/svg/SVGAnimateElement.h 2011-06-25 21:36:56 UTC (rev 89749)
@@ -28,7 +28,6 @@
#include "SVGAnimatedType.h"
#include "SVGAnimatedTypeAnimator.h"
#include "SVGAnimationElement.h"
-#include "SVGPathByteStream.h"
#include <wtf/OwnPtr.h>
namespace WebCore {
@@ -74,11 +73,7 @@
AnimatedPropertyValueType m_fromPropertyValueType;
AnimatedPropertyValueType m_toPropertyValueType;
- OwnPtr<SVGPathByteStream> m_fromPath;
- OwnPtr<SVGPathByteStream> m_toPath;
- OwnPtr<SVGPathByteStream> m_animatedPath;
- SVGPathByteStream* m_animatedPathPointer;
-
+
OwnPtr<SVGAnimatedType> m_fromType;
OwnPtr<SVGAnimatedType> m_toType;
OwnPtr<SVGAnimatedType> m_animatedType;
Modified: trunk/Source/WebCore/svg/SVGAnimatedAngle.cpp (89748 => 89749)
--- trunk/Source/WebCore/svg/SVGAnimatedAngle.cpp 2011-06-25 21:20:22 UTC (rev 89748)
+++ trunk/Source/WebCore/svg/SVGAnimatedAngle.cpp 2011-06-25 21:36:56 UTC (rev 89749)
@@ -42,7 +42,7 @@
PassOwnPtr<SVGAnimatedType> SVGAnimatedAngleAnimator::constructFromString(const String& string)
{
- OwnPtr<SVGAnimatedType> animatedType = SVGAnimatedType::createAngle(new SVGAngle());
+ OwnPtr<SVGAnimatedType> animatedType = SVGAnimatedType::createAngle(new SVGAngle);
ExceptionCode ec = 0;
animatedType->angle().setValueAsString(string, ec);
ASSERT(!ec);
Added: trunk/Source/WebCore/svg/SVGAnimatedPath.cpp (0 => 89749)
--- trunk/Source/WebCore/svg/SVGAnimatedPath.cpp (rev 0)
+++ trunk/Source/WebCore/svg/SVGAnimatedPath.cpp 2011-06-25 21:36:56 UTC (rev 89749)
@@ -0,0 +1,127 @@
+/*
+ * 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 "SVGAnimatedPath.h"
+
+#include "SVGAnimateElement.h"
+#include "SVGPathParserFactory.h"
+
+namespace WebCore {
+
+SVGAnimatedPathAnimator::SVGAnimatedPathAnimator(SVGAnimationElement* animationElement, SVGElement* contextElement)
+ : SVGAnimatedTypeAnimator(AnimatedPath, animationElement, contextElement)
+{
+}
+
+PassOwnPtr<SVGAnimatedType> SVGAnimatedPathAnimator::constructFromString(const String& string)
+{
+ bool result = false;
+ return constructFromString(string, result);
+}
+
+PassOwnPtr<SVGAnimatedType> SVGAnimatedPathAnimator::constructFromString(const String& string, bool& result)
+{
+ OwnPtr<SVGPathByteStream> byteStream = SVGPathByteStream::create();
+ result = SVGPathParserFactory::self()->buildSVGPathByteStreamFromString(string, byteStream, UnalteredParsing);
+ return SVGAnimatedType::createPath(byteStream.release());
+}
+
+void SVGAnimatedPathAnimator::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);
+ AnimationMode animationMode = animationElement->animationMode();
+
+ bool success = false;
+ to = constructFromString(toString, success);
+
+ // For to-animations the from number is calculated later.
+ if (!success || animationMode == ToAnimation) {
+ from = SVGAnimatedType::createPath(SVGPathByteStream::create());
+ return;
+ }
+
+ from = constructFromString(fromString, success);
+ if (success)
+ return;
+
+ from = SVGAnimatedType::createPath(SVGPathByteStream::create());
+}
+
+void SVGAnimatedPathAnimator::calculateFromAndByValues(OwnPtr<SVGAnimatedType>&, OwnPtr<SVGAnimatedType>&, const String&, const String&)
+{
+ ASSERT_NOT_REACHED();
+}
+
+void SVGAnimatedPathAnimator::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();
+
+ SVGPathByteStream* toPath = to->path();
+ ASSERT(toPath);
+
+ SVGPathByteStream* fromPath = from->path();
+ ASSERT(fromPath);
+
+ SVGPathByteStream* animatedPath = animated->path();
+ ASSERT(animatedPath);
+
+ if (animationMode == ToAnimation)
+ fromPath->initializeFrom(animatedPath);
+
+ if (!percentage) {
+ animatedPath->initializeFrom(fromPath);
+ return;
+ }
+
+ if (percentage == 1) {
+ animatedPath->initializeFrom(toPath);
+ return;
+ }
+
+ OwnPtr<SVGPathByteStream> newAnimatedPath = adoptPtr(animatedPath);
+ bool success = SVGPathParserFactory::self()->buildAnimatedSVGPathByteStream(fromPath, toPath, newAnimatedPath, percentage);
+ animatedPath = newAnimatedPath.leakPtr();
+ if (success)
+ return;
+
+ if ((animationMode == FromToAnimation && percentage > 0.5) || animationMode == ToAnimation)
+ animatedPath->initializeFrom(toPath);
+ else
+ animatedPath->initializeFrom(fromPath);
+}
+
+float SVGAnimatedPathAnimator::calculateDistance(const String&, const String&)
+{
+ // FIXME: Support paced animations.
+ return -1;
+}
+
+}
+
+#endif // ENABLE(SVG) && ENABLE(SVG_ANIMATION)
Added: trunk/Source/WebCore/svg/SVGAnimatedPath.h (0 => 89749)
--- trunk/Source/WebCore/svg/SVGAnimatedPath.h (rev 0)
+++ trunk/Source/WebCore/svg/SVGAnimatedPath.h 2011-06-25 21:36:56 UTC (rev 89749)
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+#ifndef SVGAnimatedPath_h
+#define SVGAnimatedPath_h
+
+#if ENABLE(SVG) && ENABLE(SVG_ANIMATION)
+#include "SVGAnimatedTypeAnimator.h"
+
+namespace WebCore {
+
+class SVGAnimationElement;
+
+class SVGAnimatedPathAnimator : public SVGAnimatedTypeAnimator {
+
+public:
+ SVGAnimatedPathAnimator(SVGAnimationElement*, SVGElement*);
+ virtual ~SVGAnimatedPathAnimator() { }
+
+ 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);
+
+private:
+ PassOwnPtr<SVGAnimatedType> constructFromString(const String&, bool &success);
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG) && ENABLE(SVG_ANIMATION)
+#endif
Modified: trunk/Source/WebCore/svg/SVGAnimatedType.cpp (89748 => 89749)
--- trunk/Source/WebCore/svg/SVGAnimatedType.cpp 2011-06-25 21:20:22 UTC (rev 89748)
+++ trunk/Source/WebCore/svg/SVGAnimatedType.cpp 2011-06-25 21:36:56 UTC (rev 89749)
@@ -27,6 +27,7 @@
#include "SVGColor.h"
#include "SVGLength.h"
#include "SVGParserUtilities.h"
+#include "SVGPathParserFactory.h"
#include "SVGPointList.h"
namespace WebCore {
@@ -51,6 +52,9 @@
case AnimatedNumber:
delete m_data.number;
break;
+ case AnimatedPath:
+ delete m_data.path;
+ break;
case AnimatedPoints:
delete m_data.pointList;
break;
@@ -98,6 +102,14 @@
return animatedType.release();
}
+PassOwnPtr<SVGAnimatedType> SVGAnimatedType::createPath(PassOwnPtr<SVGPathByteStream> path)
+{
+ ASSERT(path);
+ OwnPtr<SVGAnimatedType> animatedType = adoptPtr(new SVGAnimatedType(AnimatedPath));
+ animatedType->m_data.path = path.leakPtr();
+ return animatedType.release();
+}
+
PassOwnPtr<SVGAnimatedType> SVGAnimatedType::createPointList(SVGPointList* pointList)
{
ASSERT(pointList);
@@ -146,6 +158,12 @@
return *m_data.number;
}
+SVGPathByteStream* SVGAnimatedType::path()
+{
+ ASSERT(m_type == AnimatedPath);
+ return m_data.path;
+}
+
SVGPointList& SVGAnimatedType::pointList()
{
ASSERT(m_type == AnimatedPoints);
@@ -179,6 +197,12 @@
case AnimatedNumber:
ASSERT(m_data.number);
return String::number(*m_data.number);
+ case AnimatedPath: {
+ ASSERT(m_data.path);
+ String result;
+ SVGPathParserFactory::self()->buildStringFromByteStream(m_data.path, result, UnalteredParsing);
+ return result;
+ }
case AnimatedPoints:
ASSERT(m_data.pointList);
return m_data.pointList->valueAsString();
@@ -216,6 +240,14 @@
ASSERT(m_data.number);
parseNumberFromString(value, *m_data.number);
break;
+ case AnimatedPath: {
+ ASSERT(m_data.path);
+ OwnPtr<SVGPathByteStream> pathByteStream = adoptPtr(m_data.path);
+ if (!SVGPathParserFactory::self()->buildSVGPathByteStreamFromString(value, pathByteStream, UnalteredParsing))
+ ec = 1; // Arbitary value > 0, it doesn't matter as we don't report the exception code.
+ m_data.path = pathByteStream.leakPtr();
+ break;
+ }
case AnimatedPoints:
ASSERT(m_data.pointList);
m_data.pointList->clear();
Modified: trunk/Source/WebCore/svg/SVGAnimatedType.h (89748 => 89749)
--- trunk/Source/WebCore/svg/SVGAnimatedType.h 2011-06-25 21:20:22 UTC (rev 89748)
+++ trunk/Source/WebCore/svg/SVGAnimatedType.h 2011-06-25 21:36:56 UTC (rev 89749)
@@ -22,6 +22,7 @@
#if ENABLE(SVG) && ENABLE(SVG_ANIMATION)
#include "SVGElement.h"
+#include "SVGPathByteStream.h"
namespace WebCore {
@@ -40,6 +41,7 @@
static PassOwnPtr<SVGAnimatedType> createColor(Color*);
static PassOwnPtr<SVGAnimatedType> createLength(SVGLength*);
static PassOwnPtr<SVGAnimatedType> createNumber(float*);
+ static PassOwnPtr<SVGAnimatedType> createPath(PassOwnPtr<SVGPathByteStream>);
static PassOwnPtr<SVGAnimatedType> createPointList(SVGPointList*);
static PassOwnPtr<SVGAnimatedType> createRect(FloatRect*);
static PassOwnPtr<SVGAnimatedType> createString(String*);
@@ -50,6 +52,7 @@
Color& color();
SVGLength& length();
float& number();
+ SVGPathByteStream* path();
SVGPointList& pointList();
FloatRect& rect();
String& string();
@@ -73,6 +76,7 @@
Color* color;
SVGLength* length;
float* number;
+ SVGPathByteStream* path;
SVGPointList* pointList;
FloatRect* rect;
String* string;
Modified: trunk/Source/WebCore/svg/SVGAnimatorFactory.h (89748 => 89749)
--- trunk/Source/WebCore/svg/SVGAnimatorFactory.h 2011-06-25 21:20:22 UTC (rev 89748)
+++ trunk/Source/WebCore/svg/SVGAnimatorFactory.h 2011-06-25 21:36:56 UTC (rev 89749)
@@ -25,6 +25,7 @@
#include "SVGAnimatedColor.h"
#include "SVGAnimatedLength.h"
#include "SVGAnimatedNumber.h"
+#include "SVGAnimatedPath.h"
#include "SVGAnimatedPointList.h"
#include "SVGAnimatedRect.h"
#include "SVGAnimatedString.h"
@@ -50,6 +51,8 @@
return adoptPtr(new SVGAnimatedLengthAnimator(animationElement, contextElement));
case AnimatedNumber:
return adoptPtr(new SVGAnimatedNumberAnimator(animationElement, contextElement));
+ case AnimatedPath:
+ return adoptPtr(new SVGAnimatedPathAnimator(animationElement, contextElement));
case AnimatedPoints:
return adoptPtr(new SVGAnimatedPointListAnimator(animationElement, contextElement));
case AnimatedRect:
Modified: trunk/Source/WebCore/svg/SVGPathByteStream.h (89748 => 89749)
--- trunk/Source/WebCore/svg/SVGPathByteStream.h 2011-06-25 21:20:22 UTC (rev 89748)
+++ trunk/Source/WebCore/svg/SVGPathByteStream.h 2011-06-25 21:36:56 UTC (rev 89749)
@@ -56,6 +56,12 @@
return adoptPtr(new SVGPathByteStream(m_data));
}
+ void initializeFrom(SVGPathByteStream* other)
+ {
+ ASSERT(other);
+ m_data = other->m_data;
+ }
+
typedef Vector<unsigned char> Data;
typedef Data::const_iterator DataIterator;
Modified: trunk/Source/WebCore/svg/SVGPathParserFactory.cpp (89748 => 89749)
--- trunk/Source/WebCore/svg/SVGPathParserFactory.cpp 2011-06-25 21:20:22 UTC (rev 89748)
+++ trunk/Source/WebCore/svg/SVGPathParserFactory.cpp 2011-06-25 21:36:56 UTC (rev 89749)
@@ -142,7 +142,11 @@
bool SVGPathParserFactory::buildSVGPathByteStreamFromSVGPathSegList(const SVGPathSegList& list, OwnPtr<SVGPathByteStream>& result, PathParsingMode parsingMode)
{
- result = SVGPathByteStream::create();
+ if (result)
+ result->clear();
+ else
+ result = SVGPathByteStream::create();
+
if (list.isEmpty())
return false;
@@ -219,7 +223,11 @@
bool SVGPathParserFactory::buildSVGPathByteStreamFromString(const String& d, OwnPtr<SVGPathByteStream>& result, PathParsingMode parsingMode)
{
- result = SVGPathByteStream::create();
+ if (result)
+ result->clear();
+ else
+ result = SVGPathByteStream::create();
+
if (d.isEmpty())
return false;
@@ -236,7 +244,11 @@
{
ASSERT(fromStream);
ASSERT(toStream);
- result = SVGPathByteStream::create();
+ if (result)
+ result->clear();
+ else
+ result = SVGPathByteStream::create();
+
if (fromStream->isEmpty() || toStream->isEmpty())
return false;