[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

krit at webkit.org krit at webkit.org
Wed Dec 22 11:52:42 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit af733732e3544b8a53eb9aa9592d809a62e8fd2a
Author: krit at webkit.org <krit at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Aug 10 11:12:09 2010 +0000

    2010-08-10  Dirk Schulze  <krit at webkit.org>
    
            Reviewed by Nikolas Zimmermann.
    
            Use SVGPathParser to create SVG paths and to perform path animations
            https://bugs.webkit.org/show_bug.cgi?id=43696
    
            Removed toString() functions in all SVGPathSeg* objects as well as toPath() in SVGPathSegList.
            These hacks were used to create a SVG path data string or a platform path from a SVGPathSegList.
            Use the new SVGPathParser instead.
    
            Doesn't affect any tests.
    
            * svg/SVGAnimateElement.cpp:
            (WebCore::SVGAnimateElement::applyResultsToTarget):
            * svg/SVGPathElement.cpp:
            (WebCore::SVGPathElement::toPathData):
            * svg/SVGPathParserFactory.cpp:
            (WebCore::SVGPathParserFactory::buildPathFromSVGPathSegList):
            (WebCore::SVGPathParserFactory::buildStringFromByteStream):
            (WebCore::SVGPathParserFactory::buildStringFromSVGPathSegList):
            * svg/SVGPathParserFactory.h:
            * svg/SVGPathSeg.cpp:
            * svg/SVGPathSeg.h:
            * svg/SVGPathSegArc.cpp:
            * svg/SVGPathSegArc.h:
            * svg/SVGPathSegClosePath.h:
            (WebCore::SVGPathSegClosePath::pathSegTypeAsLetter):
            * svg/SVGPathSegCurvetoCubic.h:
            * svg/SVGPathSegCurvetoCubicSmooth.h:
            * svg/SVGPathSegCurvetoQuadratic.h:
            * svg/SVGPathSegLinetoHorizontal.h:
            * svg/SVGPathSegLinetoVertical.h:
            * svg/SVGPathSegList.cpp:
            (WebCore::SVGPathSegList::getPathSegAtLength):
            * svg/SVGPathSegList.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@65065 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 790720b..d6e9ff5 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,40 @@
+2010-08-10  Dirk Schulze  <krit at webkit.org>
+
+        Reviewed by Nikolas Zimmermann.
+
+        Use SVGPathParser to create SVG paths and to perform path animations
+        https://bugs.webkit.org/show_bug.cgi?id=43696
+
+        Removed toString() functions in all SVGPathSeg* objects as well as toPath() in SVGPathSegList.
+        These hacks were used to create a SVG path data string or a platform path from a SVGPathSegList.
+        Use the new SVGPathParser instead.
+
+        Doesn't affect any tests.
+
+        * svg/SVGAnimateElement.cpp:
+        (WebCore::SVGAnimateElement::applyResultsToTarget):
+        * svg/SVGPathElement.cpp:
+        (WebCore::SVGPathElement::toPathData):
+        * svg/SVGPathParserFactory.cpp:
+        (WebCore::SVGPathParserFactory::buildPathFromSVGPathSegList):
+        (WebCore::SVGPathParserFactory::buildStringFromByteStream):
+        (WebCore::SVGPathParserFactory::buildStringFromSVGPathSegList):
+        * svg/SVGPathParserFactory.h:
+        * svg/SVGPathSeg.cpp:
+        * svg/SVGPathSeg.h:
+        * svg/SVGPathSegArc.cpp:
+        * svg/SVGPathSegArc.h:
+        * svg/SVGPathSegClosePath.h:
+        (WebCore::SVGPathSegClosePath::pathSegTypeAsLetter):
+        * svg/SVGPathSegCurvetoCubic.h:
+        * svg/SVGPathSegCurvetoCubicSmooth.h:
+        * svg/SVGPathSegCurvetoQuadratic.h:
+        * svg/SVGPathSegLinetoHorizontal.h:
+        * svg/SVGPathSegLinetoVertical.h:
+        * svg/SVGPathSegList.cpp:
+        (WebCore::SVGPathSegList::getPathSegAtLength):
+        * svg/SVGPathSegList.h:
+
 2010-08-10  Sheriff Bot  <webkit.review.bot at gmail.com>
 
         Unreviewed, rolling out r65056.
diff --git a/WebCore/svg/SVGAnimateElement.cpp b/WebCore/svg/SVGAnimateElement.cpp
index 07e46b4..2723804 100644
--- a/WebCore/svg/SVGAnimateElement.cpp
+++ b/WebCore/svg/SVGAnimateElement.cpp
@@ -279,12 +279,8 @@ void SVGAnimateElement::applyResultsToTarget()
             // "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.
-            unsigned itemCount = m_animatedPath->numberOfItems();
-            ExceptionCode ec;
-            for (unsigned n = 0; n < itemCount; ++n) {
-                RefPtr<SVGPathSeg> segment = m_animatedPath->getItem(n, ec);
-                valueToApply.append(segment->toString() + " ");
-            }
+            SVGPathParserFactory* factory = SVGPathParserFactory::self();
+            factory->buildStringFromSVGPathSegList(m_animatedPath.get(), valueToApply, UnalteredParsing);
         }
     } else if (m_propertyType == PointsProperty) {
         if (!m_animatedPoints || !m_animatedPoints->numberOfItems())
diff --git a/WebCore/svg/SVGPathElement.cpp b/WebCore/svg/SVGPathElement.cpp
index ee619b6..2adc05f 100644
--- a/WebCore/svg/SVGPathElement.cpp
+++ b/WebCore/svg/SVGPathElement.cpp
@@ -263,7 +263,10 @@ SVGPathSegList* SVGPathElement::animatedNormalizedPathSegList() const
 
 Path SVGPathElement::toPathData() const
 {
-    return pathSegList()->toPathData();
+    Path result;
+    SVGPathParserFactory* factory = SVGPathParserFactory::self();
+    factory->buildPathFromSVGPathSegList(pathSegList(), result);
+    return result;
 }
 
 }
diff --git a/WebCore/svg/SVGPathParserFactory.cpp b/WebCore/svg/SVGPathParserFactory.cpp
index 6d17abc..cf1a888 100644
--- a/WebCore/svg/SVGPathParserFactory.cpp
+++ b/WebCore/svg/SVGPathParserFactory.cpp
@@ -26,9 +26,10 @@
 #include "SVGPathBuilder.h"
 #include "SVGPathByteStreamBuilder.h"
 #include "SVGPathByteStreamSource.h"
-#include "SVGPathStringBuilder.h"
 #include "SVGPathParser.h"
 #include "SVGPathSegListBuilder.h"
+#include "SVGPathSegListSource.h"
+#include "SVGPathStringBuilder.h"
 #include "SVGPathStringSource.h"
 
 namespace WebCore {
@@ -129,6 +130,21 @@ bool SVGPathParserFactory::buildPathFromByteStream(SVGPathByteStream* stream, Pa
     return ok;
 }
 
+bool SVGPathParserFactory::buildPathFromSVGPathSegList(SVGPathSegList* pathSegList, Path& result)
+{
+    ASSERT(pathSegList);
+    if (!pathSegList->numberOfItems())
+        return false;
+
+    SVGPathBuilder* builder = globalSVGPathBuilder(result);
+
+    OwnPtr<SVGPathSegListSource> source = SVGPathSegListSource::create(pathSegList);
+    SVGPathParser* parser = globalSVGPathParser(source.get(), builder);
+    bool ok = parser->parsePathDataFromSource(NormalizedParsing);
+    parser->cleanup();
+    return ok;
+}
+
 bool SVGPathParserFactory::buildSVGPathSegListFromString(const String& d, SVGPathSegList* result, PathParsingMode parsingMode)
 {
     ASSERT(result);
@@ -171,8 +187,24 @@ bool SVGPathParserFactory::buildStringFromByteStream(SVGPathByteStream* stream,
     OwnPtr<SVGPathByteStreamSource> source = SVGPathByteStreamSource::create(stream);
     SVGPathParser* parser = globalSVGPathParser(source.get(), builder);
     bool ok = parser->parsePathDataFromSource(parsingMode);
+    result = builder->result();
     parser->cleanup();
+    return ok;
+}
+
+bool SVGPathParserFactory::buildStringFromSVGPathSegList(SVGPathSegList* pathSegList, String& result, PathParsingMode parsingMode)
+{
+    ASSERT(pathSegList);
+    if (!pathSegList->numberOfItems())
+        return false; 
+
+    SVGPathStringBuilder* builder = globalSVGPathStringBuilder();
+
+    OwnPtr<SVGPathSegListSource> source = SVGPathSegListSource::create(pathSegList);
+    SVGPathParser* parser = globalSVGPathParser(source.get(), builder);
+    bool ok = parser->parsePathDataFromSource(parsingMode);
     result = builder->result();
+    parser->cleanup();
     return ok;
 }
 
diff --git a/WebCore/svg/SVGPathParserFactory.h b/WebCore/svg/SVGPathParserFactory.h
index 0aa3c99..37418d4 100644
--- a/WebCore/svg/SVGPathParserFactory.h
+++ b/WebCore/svg/SVGPathParserFactory.h
@@ -35,12 +35,14 @@ public:
     static SVGPathParserFactory* self();
 
     bool buildPathFromString(const String&, Path&);
-    bool buildPathFromByteStream(SVGPathByteStream*, Path& result);
+    bool buildPathFromByteStream(SVGPathByteStream*, Path&);
+    bool buildPathFromSVGPathSegList(SVGPathSegList*, Path&);
 
     bool buildSVGPathSegListFromString(const String&, SVGPathSegList*, PathParsingMode);
     bool buildSVGPathSegListFromByteStream(SVGPathByteStream*, SVGPathSegList*, PathParsingMode);
 
     bool buildStringFromByteStream(SVGPathByteStream*, String&, PathParsingMode);
+    bool buildStringFromSVGPathSegList(SVGPathSegList*, String&, PathParsingMode);
 
     bool buildSVGPathByteStreamFromString(const String&, OwnPtr<SVGPathByteStream>&, PathParsingMode);
 
diff --git a/WebCore/svg/SVGPathSeg.cpp b/WebCore/svg/SVGPathSeg.cpp
index 98ff15d..56ee56c 100644
--- a/WebCore/svg/SVGPathSeg.cpp
+++ b/WebCore/svg/SVGPathSeg.cpp
@@ -45,20 +45,10 @@ String SVGPathSeg::pathSegTypeAsLetter() const
     return "";
 }
 
-String SVGPathSeg::toString() const
-{
-    return "";
-}
-
 const QualifiedName& SVGPathSeg::associatedAttributeName() const
 {
     return SVGNames::dAttr;
 }
 
-String SVGPathSegSingleCoord::toString() const
-{
-    return pathSegTypeAsLetter() + String::format(" %.6lg %.6lg", m_x, m_y);
-}
-
 } // namespace WebCore
 #endif // ENABLE(SVG)
diff --git a/WebCore/svg/SVGPathSeg.h b/WebCore/svg/SVGPathSeg.h
index 0616e3a..6c4db89 100644
--- a/WebCore/svg/SVGPathSeg.h
+++ b/WebCore/svg/SVGPathSeg.h
@@ -85,7 +85,6 @@ public:
 
     virtual unsigned short pathSegType() const;
     virtual String pathSegTypeAsLetter() const;
-    virtual String toString() const;
 
     const QualifiedName& associatedAttributeName() const;
     
@@ -107,8 +106,6 @@ public:
     void setY(float y) { m_y = y; }
     float y() const { return m_y; }
 
-    virtual String toString() const;
-
 private:
     float m_x;
     float m_y;
diff --git a/WebCore/svg/SVGPathSegArc.cpp b/WebCore/svg/SVGPathSegArc.cpp
index 78d4c56..f606905 100644
--- a/WebCore/svg/SVGPathSegArc.cpp
+++ b/WebCore/svg/SVGPathSegArc.cpp
@@ -25,11 +25,6 @@
 
 namespace WebCore {
 
-String SVGPathSegArc::toString() const
-{
-    return pathSegTypeAsLetter() + String::format(" %.6lg %.6lg %.6lg %d %d %.6lg %.6lg", m_r1, m_r2, m_angle, m_largeArcFlag, m_sweepFlag, m_x, m_y);
-}
-
 SVGPathSegArcAbs::SVGPathSegArcAbs(float x, float y, float r1, float r2, float angle, bool largeArcFlag, bool sweepFlag)
     : SVGPathSegArc(x, y, r1, r2, angle, largeArcFlag, sweepFlag)
 {
diff --git a/WebCore/svg/SVGPathSegArc.h b/WebCore/svg/SVGPathSegArc.h
index 2782206..c7bbbb0 100644
--- a/WebCore/svg/SVGPathSegArc.h
+++ b/WebCore/svg/SVGPathSegArc.h
@@ -41,8 +41,6 @@ namespace WebCore {
         {
         }
 
-        virtual String toString() const;
-
         void setX(float x) { m_x = x; }
         float x() const { return m_x; }
 
diff --git a/WebCore/svg/SVGPathSegClosePath.h b/WebCore/svg/SVGPathSegClosePath.h
index 49a1dc9..635c970 100644
--- a/WebCore/svg/SVGPathSegClosePath.h
+++ b/WebCore/svg/SVGPathSegClosePath.h
@@ -35,7 +35,6 @@ public:
 
     virtual unsigned short pathSegType() const { return PATHSEG_CLOSEPATH; }
     virtual String pathSegTypeAsLetter() const { return "Z"; }
-    virtual String toString() const { return "Z"; }
 
 private:
     SVGPathSegClosePath();
diff --git a/WebCore/svg/SVGPathSegCurvetoCubic.h b/WebCore/svg/SVGPathSegCurvetoCubic.h
index aa9c060..7e2735e 100644
--- a/WebCore/svg/SVGPathSegCurvetoCubic.h
+++ b/WebCore/svg/SVGPathSegCurvetoCubic.h
@@ -32,8 +32,6 @@ namespace WebCore {
     public:
         SVGPathSegCurvetoCubic(float x, float y, float x1, float y1, float x2, float y2) : SVGPathSeg() , m_x(x) , m_y(y) , m_x1(x1) , m_y1(y1) , m_x2(x2) , m_y2(y2) {}
 
-        virtual String toString() const { return pathSegTypeAsLetter() + String::format(" %.6lg %.6lg %.6lg %.6lg %.6lg %.6lg", m_x1, m_y1, m_x2, m_y2, m_x, m_y); }
-
         void setX(float x) { m_x = x; }
         float x() const { return m_x; }
 
diff --git a/WebCore/svg/SVGPathSegCurvetoCubicSmooth.h b/WebCore/svg/SVGPathSegCurvetoCubicSmooth.h
index e12460b..bc8895c 100644
--- a/WebCore/svg/SVGPathSegCurvetoCubicSmooth.h
+++ b/WebCore/svg/SVGPathSegCurvetoCubicSmooth.h
@@ -33,8 +33,6 @@ namespace WebCore {
         SVGPathSegCurvetoCubicSmooth(float x, float y, float x2, float y2)
         : m_x(x), m_y(y), m_x2(x2), m_y2(y2) { }
 
-        virtual String toString() const { return pathSegTypeAsLetter() + String::format(" %.6lg %.6lg %.6lg %.6lg", m_x2, m_y2, m_x, m_y); }
-
         void setX(float x) { m_x = x; }
         float x() const { return m_x; }
 
diff --git a/WebCore/svg/SVGPathSegCurvetoQuadratic.h b/WebCore/svg/SVGPathSegCurvetoQuadratic.h
index 10d8f43..967442f 100644
--- a/WebCore/svg/SVGPathSegCurvetoQuadratic.h
+++ b/WebCore/svg/SVGPathSegCurvetoQuadratic.h
@@ -33,8 +33,6 @@ namespace WebCore {
         SVGPathSegCurvetoQuadratic(float x, float y, float x1, float y1)
         : SVGPathSeg(), m_x(x), m_y(y), m_x1(x1), m_y1(y1) {}
 
-        virtual String toString() const { return pathSegTypeAsLetter() + String::format(" %.6lg %.6lg %.6lg %.6lg", m_x1, m_y1, m_x, m_y); }
-
         void setX(float x) { m_x = x; }
         float x() const { return m_x; }
 
diff --git a/WebCore/svg/SVGPathSegLinetoHorizontal.h b/WebCore/svg/SVGPathSegLinetoHorizontal.h
index a4072ae..3a16ad1 100644
--- a/WebCore/svg/SVGPathSegLinetoHorizontal.h
+++ b/WebCore/svg/SVGPathSegLinetoHorizontal.h
@@ -32,8 +32,6 @@ namespace WebCore {
     public:
         SVGPathSegLinetoHorizontal(float x) : SVGPathSeg(), m_x(x) {}
 
-        virtual String toString() const { return pathSegTypeAsLetter() + String::format(" %.6lg", m_x); }
-
         void setX(float x) { m_x = x; }
         float x() const { return m_x; }
 
diff --git a/WebCore/svg/SVGPathSegLinetoVertical.h b/WebCore/svg/SVGPathSegLinetoVertical.h
index fb54c32..d4d9f85 100644
--- a/WebCore/svg/SVGPathSegLinetoVertical.h
+++ b/WebCore/svg/SVGPathSegLinetoVertical.h
@@ -32,8 +32,6 @@ namespace WebCore {
     public:
         SVGPathSegLinetoVertical(float y) : SVGPathSeg(), m_y(y) {}
 
-        virtual String toString() const { return pathSegTypeAsLetter() + String::format(" %.6lg", m_y); }
-
         void setY(float y) { m_y = y; }
         float y() const { return m_y; }
 
diff --git a/WebCore/svg/SVGPathSegList.cpp b/WebCore/svg/SVGPathSegList.cpp
index aeec0c8..b445d3e 100644
--- a/WebCore/svg/SVGPathSegList.cpp
+++ b/WebCore/svg/SVGPathSegList.cpp
@@ -103,62 +103,6 @@ unsigned SVGPathSegList::getPathSegAtLength(double length, ExceptionCode& ec)
     // WebKit/Opera/FF all return the last path segment if the distance exceeds the actual path length:
     return traversalState.m_segmentIndex ? traversalState.m_segmentIndex - 1 : 0;
 }
-
-Path SVGPathSegList::toPathData()
-{
-    // FIXME : This should also support non-normalized PathSegLists
-    Path pathData;
-    int len = numberOfItems();
-    ExceptionCode ec = 0;
-    FloatPoint previousEndPoint(0, 0);
-    for (int i = 0; i < len; ++i) {
-        SVGPathSeg* segment = getItem(i, ec).get();
-        if (ec)
-            return Path();
-        switch (segment->pathSegType()) {
-        case PathSegMoveToAbs: {
-            SVGPathSegMovetoAbs* moveTo = static_cast<SVGPathSegMovetoAbs*>(segment);
-            FloatPoint endPoint(moveTo->x(), moveTo->y());
-            pathData.moveTo(endPoint);
-            previousEndPoint = endPoint;
-            break;
-        }
-        case PathSegLineToAbs: {
-            SVGPathSegLinetoAbs* lineTo = static_cast<SVGPathSegLinetoAbs*>(segment);
-            FloatPoint endPoint(lineTo->x(), lineTo->y());
-            pathData.addLineTo(endPoint);
-            previousEndPoint = endPoint;
-            break;
-        }
-        case PathSegCurveToCubicAbs: {
-            SVGPathSegCurvetoCubicAbs* curveTo = static_cast<SVGPathSegCurvetoCubicAbs*>(segment);
-            FloatPoint endPoint(curveTo->x(), curveTo->y());
-            pathData.addBezierCurveTo(FloatPoint(curveTo->x1(), curveTo->y1()),
-                                      FloatPoint(curveTo->x2(), curveTo->y2()),
-                                      endPoint);
-            previousEndPoint = endPoint;
-            break;
-        }
-        case PathSegCurveToCubicRel: {
-            SVGPathSegCurvetoCubicRel* curveTo = static_cast<SVGPathSegCurvetoCubicRel*>(segment);
-            FloatSize endPoint(curveTo->x(), curveTo->y());
-            pathData.addBezierCurveTo(previousEndPoint + FloatSize(curveTo->x1(), curveTo->y1()),
-                                      previousEndPoint + FloatSize(curveTo->x2(), curveTo->y2()),
-                                      previousEndPoint + endPoint);
-            previousEndPoint += endPoint;
-            break;
-        }
-        case PathSegClosePath:
-            pathData.closeSubpath();
-            break;
-        default:
-            ASSERT(false); // FIXME: This only works with normalized/processed path data.
-            break;
-        }
-    }
-    
-    return pathData;
-}
     
 float adjustAnimatedValue(float from, float to, float progress)
 {
diff --git a/WebCore/svg/SVGPathSegList.h b/WebCore/svg/SVGPathSegList.h
index aea50b9..7e7134f 100644
--- a/WebCore/svg/SVGPathSegList.h
+++ b/WebCore/svg/SVGPathSegList.h
@@ -35,7 +35,6 @@ namespace WebCore {
         virtual ~SVGPathSegList();
 
         unsigned getPathSegAtLength(double, ExceptionCode&);
-        Path toPathData();
         
         static PassRefPtr<SVGPathSegList> createAnimated(const SVGPathSegList* fromList, const SVGPathSegList* toList, float progress);
         

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list