2006-03-05 Alexander Kellett <lypanov@kde.org>
authorlypanov <lypanov@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 5 Mar 2006 14:33:18 +0000 (14:33 +0000)
committerlypanov <lypanov@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 5 Mar 2006 14:33:18 +0000 (14:33 +0000)
        Reviewed by Eric.

        - new reduced testcases for:
          http://bugzilla.opendarwin.org/show_bug.cgi?id=6951
          http://bugzilla.opendarwin.org/show_bug.cgi?id=6890

        * svg/custom/polyline-invalid-points.svg: Added.
        * svg/custom/polyline-setattribute-points-null.svg: Added.

2006-03-05  Alexander Kellett  <lypanov@kde.org>

        Reviewed by Eric.

        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=6890
          and http://bugzilla.opendarwin.org/show_bug.cgi?id=6951
          by being more tolerant towards invalid points data

        - new tests:
          svg/custom/polyline-setattribute-points-null.svg
          svg/custom/polyline-invalid-points.svg

        * ksvg2/svg/svgpathparser.cpp:
        (SVGPolyParser::parsePoints):

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

LayoutTests/ChangeLog
LayoutTests/svg/custom/polyline-invalid-points.svg [new file with mode: 0644]
LayoutTests/svg/custom/polyline-setattribute-points-null.svg [new file with mode: 0644]
WebCore/ChangeLog
WebCore/ksvg2/svg/svgpathparser.cpp

index 33dd7d502c6c6dc0acdfe3bd2bcfb648efb0d0dc..dad563b9229959eb3e08d3ad08a9439e17123236 100644 (file)
@@ -1,3 +1,14 @@
+2006-03-05  Alexander Kellett  <lypanov@kde.org>
+
+        Reviewed by Eric.
+
+        - new reduced testcases for:
+          http://bugzilla.opendarwin.org/show_bug.cgi?id=6951
+          http://bugzilla.opendarwin.org/show_bug.cgi?id=6890  
+
+        * svg/custom/polyline-invalid-points.svg: Added.
+        * svg/custom/polyline-setattribute-points-null.svg: Added.
+
 2006-03-05  Mitz Pettel  <opendarwin.org@mitzpettel.com>
 
         Reviewed by Darin, landed by ap.
diff --git a/LayoutTests/svg/custom/polyline-invalid-points.svg b/LayoutTests/svg/custom/polyline-invalid-points.svg
new file mode 100644 (file)
index 0000000..c87acfe
--- /dev/null
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg">
+    <rect x="0" y="0" width="100" height="100" fill="red"/>
+    <polyline fill="none" stroke="green" stroke-width="100" points="50,0 50, 100,INF INF"/>
+</svg>
diff --git a/LayoutTests/svg/custom/polyline-setattribute-points-null.svg b/LayoutTests/svg/custom/polyline-setattribute-points-null.svg
new file mode 100644 (file)
index 0000000..bf7b101
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" onload="init()">
+
+    <script>
+        var d;
+        function init()
+        {
+            var polyline = document.createElementNS("http://www.w3.org/2000/svg", "polyline");
+            polyline.setAttribute("points", d);
+            var g = document.getElementById("container");
+            g.appendChild(polyline);
+            // verify that the script arrived here without error by filling the rectangle with green
+            document.getElementById("passed").setAttribute("fill", "green");
+        }
+    </script>
+    
+    <rect id="passed" x="0" y="0" width="100" height="100" fill="red"/>
+    <g id="container"></g>
+
+</svg>
index a279d543cb6d413d997a2742c96c85290f98166d..9d7e308652e3258982f646d4c6d251b5edd4f692 100644 (file)
@@ -1,3 +1,18 @@
+2006-03-05  Alexander Kellett  <lypanov@kde.org>
+
+        Reviewed by Eric.
+
+        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=6890
+          and http://bugzilla.opendarwin.org/show_bug.cgi?id=6951
+          by being more tolerant towards invalid points data
+
+        - new tests:
+          svg/custom/polyline-setattribute-points-null.svg
+          svg/custom/polyline-invalid-points.svg
+
+        * ksvg2/svg/svgpathparser.cpp:
+        (SVGPolyParser::parsePoints):
+
 2006-03-05  Maciej Stachowiak  <mjs@apple.com>
 
         Rubber stamped by Eric.
index 5ea38323a7dd334fc59a321d9e1a03c9b5546b48..8067bfeb5cd89767dcc8788d7e290fff91628f02 100644 (file)
@@ -1,5 +1,6 @@
 /* This file is part of the KDE project
    Copyright (C) 2002, 2003 The Karbon Developers
+                 2006       Alexander Kellett <lypanov@kde.org>
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
@@ -89,30 +90,35 @@ const char *KSVG::parseCoord(const char *ptr, double &number)
     return ptr;
 }
 
-void
-SVGPolyParser::parsePoints( const QString &s ) const
+void SVGPolyParser::parsePoints(const QString &s) const
 {
-    if(!s.isEmpty())
-    {
-        QString points = s;
-        points = points.replace(',', ' ');
-        points = points.simplifyWhiteSpace();
-        const char *ptr = points.latin1();
-        const char *end = points.latin1() + points.length();
-
-        double curx = 0, cury = 0;
-        int nr = 0;
-        while( ptr < end )
-        {
-            //std::cout << "ptr : " << ptr << std::endl;
-            //std::cout << "end : " << end << std::endl;
-            ptr = parseCoord( ptr, curx );
-            if( *ptr == ',' || *ptr == ' ' )
-                ptr++;
-            ptr = parseCoord( ptr, cury );
-            svgPolyTo( curx, cury, nr++ );
-            if( *ptr == ' ' )
-                ptr++;
+    if (!s.isEmpty()) {
+        QString pointData = s;
+        pointData = pointData.replace(',', ' ');
+        pointData = pointData.simplifyWhiteSpace();
+        const char* currSegment = pointData.latin1();
+        const char* eoString = pointData.latin1() + pointData.length();
+        
+        int segmentNum = 0;
+        while (currSegment < eoString) {
+            const char* prevSegment = currSegment;
+            double xPos = 0;
+            currSegment = parseCoord(currSegment, xPos); 
+            if (currSegment == prevSegment)
+                break;
+                
+            if (*currSegment == ',' || *currSegment == ' ')
+                currSegment++;
+
+            prevSegment = currSegment;
+            double yPos = 0;
+            currSegment = parseCoord(currSegment, yPos);
+            if (currSegment == prevSegment)
+                break;
+                
+            svgPolyTo(xPos, yPos, segmentNum++);
+            if (*currSegment == ' ')
+                currSegment++;
         }
     }
 }