2006-04-21 Rob Buis <buis@kde.org>
authoreseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 23 Apr 2006 22:57:22 +0000 (22:57 +0000)
committereseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 23 Apr 2006 22:57:22 +0000 (22:57 +0000)
        Reviewed by hyatt.  Landed by eseidel.

        Fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=8170:
        SVG CSS property values with extra items do not get treated
        as invalid (they should)

        Fixes the handling of invalid svg css properties similar
        to how invalid html css properties are handled, ie. discard
        the property if there are more values in the value list than
        expected.

        Test: svg/custom/invalid-css.svg

        * ksvg2/css/SVGCSSParser.cpp:
        (WebCore::CSSParser::parseSVGValue):

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

LayoutTests/ChangeLog
LayoutTests/svg/custom/invalid-css-expected.checksum [new file with mode: 0644]
LayoutTests/svg/custom/invalid-css-expected.png [new file with mode: 0644]
LayoutTests/svg/custom/invalid-css-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/invalid-css.svg [new file with mode: 0644]
WebCore/ChangeLog
WebCore/ksvg2/css/SVGCSSParser.cpp

index 1168bc2..bf8da35 100644 (file)
@@ -1,3 +1,11 @@
+2006-04-23  Rob Buis  <buis@kde.org>
+
+        Reviewed by hyatt.  Landed by eseidel.
+
+        Tests for invalid svg css properties.
+
+        * svg/custom/invalid-css.svg: Added.
+
 2006-04-21  Jon Shier  <jshier@iastate.edu>
         
         Reviewed by ggaren.  Landed by eseidel.
diff --git a/LayoutTests/svg/custom/invalid-css-expected.checksum b/LayoutTests/svg/custom/invalid-css-expected.checksum
new file mode 100644 (file)
index 0000000..874b7bd
--- /dev/null
@@ -0,0 +1 @@
+8e94f64972ebb3fe1de53bcc8127aefe
\ No newline at end of file
diff --git a/LayoutTests/svg/custom/invalid-css-expected.png b/LayoutTests/svg/custom/invalid-css-expected.png
new file mode 100644 (file)
index 0000000..1320a7d
Binary files /dev/null and b/LayoutTests/svg/custom/invalid-css-expected.png differ
diff --git a/LayoutTests/svg/custom/invalid-css-expected.txt b/LayoutTests/svg/custom/invalid-css-expected.txt
new file mode 100644 (file)
index 0000000..f5efe17
--- /dev/null
@@ -0,0 +1,23 @@
+KCanvasResource {id="clip1" [type=CLIPPER] [clip data=[[winding=NON-ZERO] [path=M40.00,40.00L39.98,40.63L39.92,41.25L39.82,41.87L39.69,42.49L39.51,43.09L39.30,43.68L39.05,44.26L38.76,44.82L38.44,45.36L38.09,45.88L37.71,46.37L37.29,46.85L36.85,47.29L36.37,47.71L35.88,48.09L35.36,48.44L34.82,48.76L34.26,49.05L33.68,49.30L33.09,49.51L32.49,49.69L31.87,49.82L31.25,49.92L30.63,49.98L30.00,50.00L29.37,49.98L28.75,49.92L28.13,49.82L27.51,49.69L26.91,49.51L26.32,49.30L25.74,49.05L25.18,48.76L24.64,48.44L24.12,48.09L23.63,47.71L23.15,47.29L22.71,46.85L22.29,46.37L21.91,45.88L21.56,45.36L21.24,44.82L20.95,44.26L20.70,43.68L20.49,43.09L20.31,42.49L20.18,41.87L20.08,41.25L20.02,40.63L20.00,40.00L20.02,39.37L20.08,38.75L20.18,38.13L20.31,37.51L20.49,36.91L20.70,36.32L20.95,35.74L21.24,35.18L21.56,34.64L21.91,34.12L22.29,33.63L22.71,33.15L23.15,32.71L23.63,32.29L24.12,31.91L24.64,31.56L25.18,31.24L25.74,30.95L26.32,30.70L26.91,30.49L27.51,30.31L28.13,30.18L28.75,30.08L29.37,30.02L30.00,30.00L30.63,30.02L31.25,30.08L31.87,30.18L32.49,30.31L33.09,30.49L33.68,30.70L34.26,30.95L34.82,31.24L35.36,31.56L35.88,31.91L36.37,32.29L36.85,32.71L37.29,33.15L37.71,33.63L38.09,34.12L38.44,34.64L38.76,35.18L39.05,35.74L39.30,36.32L39.51,36.91L39.69,37.51L39.82,38.13L39.92,38.75L39.98,39.37]]]}
+KRenderingPaintServer {id="grad" [type=LINEAR-GRADIENT] [stops=[(0.00,#008000)]] [start=(0,0)] [end=(100,0)]}
+KCanvasResource {id="blurxy" [type=FILTER]  [bounding box=at (-0.10,-0.10) size 1.20x1.20] [effect bounding box mode=0] [effects=[[type=GAUSSIAN-BLUR]  [subregion="at (0,0) size 480x360"] [std dev. x=5.00 y=1.00]]]}
+KCanvasResource {id="marker1" [type=MARKER] [angle=0.00] [ref x=5.00 y=5.00]}
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+    KCanvasContainer {svg} at (0,0) size 334.17x150.83
+      KCanvasContainer {marker} at (0,0) size 16.67x16.67
+        KCanvasItem {rect} at (0,0) size 16.67x16.67 [fill={[type=SOLID] [color=#FF0000]}] [data="M0.00,0.00L10.00,0.00L10.00,10.00L0.00,10.00"]
+      RenderSVGText {text} at (0,0) size 785x18
+        RenderText {#text} at (0,0) size 294x18
+          text run at (0,0) width 294: "The rect should be opaque green, black stroke,"
+      RenderSVGText {text} at (0,0) size 785x18
+        RenderText {#text} at (0,0) size 167x18
+          text run at (0,0) width 167: "no markers and no dashes."
+      KCanvasItem {path} at (49.17,65.83) size 85x85 [stroke={[type=SOLID] [color=#000000] [dash array={10.00, 5.00, 10.00, -1.00}]}] [fill={[type=SOLID] [color=#008000]}] [data="M30.00,40.00L80.00,40.00L80.00,90.00L30.00,90.00"]
+      KCanvasItem {circle} at (265.83,65.83) size 68.33x68.33 [stroke={[type=SOLID] [color=#000000]}] [fill={[type=LINEAR-GRADIENT] [stops=[(0.00,#008000)]] [start=(0,0)] [end=(100,0)]}] [data="M200.00,60.00L199.96,61.26L199.84,62.51L199.65,63.75L199.37,64.97L199.02,66.18L198.60,67.36L198.10,68.52L197.53,69.64L196.89,70.72L196.18,71.76L195.41,72.75L194.58,73.69L193.69,74.58L192.75,75.41L191.76,76.18L190.72,76.89L189.64,77.53L188.52,78.10L187.36,78.60L186.18,79.02L184.97,79.37L183.75,79.65L182.51,79.84L181.26,79.96L180.00,80.00L178.74,79.96L177.49,79.84L176.25,79.65L175.03,79.37L173.82,79.02L172.64,78.60L171.48,78.10L170.36,77.53L169.28,76.89L168.24,76.18L167.25,75.41L166.31,74.58L165.42,73.69L164.59,72.75L163.82,71.76L163.11,70.72L162.47,69.64L161.90,68.52L161.40,67.36L160.98,66.18L160.63,64.97L160.35,63.75L160.16,62.51L160.04,61.26L160.00,60.00L160.04,58.74L160.16,57.49L160.35,56.25L160.63,55.03L160.98,53.82L161.40,52.64L161.90,51.48L162.47,50.36L163.11,49.28L163.82,48.24L164.59,47.25L165.42,46.31L166.31,45.42L167.25,44.59L168.24,43.82L169.28,43.11L170.36,42.47L171.48,41.90L172.64,41.40L173.82,40.98L175.03,40.63L176.25,40.35L177.49,40.16L178.74,40.04L180.00,40.00L181.26,40.04L182.51,40.16L183.75,40.35L184.97,40.63L186.18,40.98L187.36,41.40L188.52,41.90L189.64,42.47L190.72,43.11L191.76,43.82L192.75,44.59L193.69,45.42L194.58,46.31L195.41,47.25L196.18,48.24L196.89,49.28L197.53,50.36L198.10,51.48L198.60,52.64L199.02,53.82L199.37,55.03L199.65,56.25L199.84,57.49L199.96,58.74"]
+      RenderSVGText {text} at (0,0) size 785x18
+        RenderText {#text} at (0,0) size 278x18
+          text run at (0,0) width 278: "The circle should be opaque green, no filter,"
+      RenderSVGText {text} at (0,0) size 785x18
+        RenderText {#text} at (0,0) size 105x18
+          text run at (0,0) width 105: "green stop color."
diff --git a/LayoutTests/svg/custom/invalid-css.svg b/LayoutTests/svg/custom/invalid-css.svg
new file mode 100644 (file)
index 0000000..2373485
--- /dev/null
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="svg-root" width="100%" height="100%" viewBox="0 0 480 360">
+    <style type="text/css"><![CDATA[
+        /* use extra value (auto) to make the css properties invalid */
+        #path1 {
+            fill: red auto;
+            fill-rule: evenodd auto;
+            fill-opacity: 10% auto;
+            marker-start: url(#marker1) auto;
+            marker-mid: url(#marker1) auto;
+            marker-end: url(#marker1) auto;
+            marker: url(#marker1)  url(#marker1)  url(#marker1) auto;
+            stroke-width: 100 auto;
+            stroke-opacity: 10% auto;
+            stroke-dasharray: 10 5 10 auto;
+            clip-path: url(#clip1) auto;
+            clip-rule: evenodd auto;
+            opacity: 0%; /* does not seem supported yet */
+            visibility: hidden auto;
+        }
+        #circle {
+            filter: url(#blurxy) auto;
+        }
+        stop {
+            stop-color: red auto;
+            stop-opacity: 10% auto;
+        }
+        /* test text css props too? */
+    ]]></style>
+    <defs>
+        <clipPath id="clip1">
+            <circle cx="30" cy="40" r="10"/>
+        </clipPath>
+        <linearGradient id="grad" gradientUnits="objectBoundingBox" x1="0" y1="0" x2="1" y2="0">
+            <stop stop-color="green"  offset="0"/>
+        </linearGradient>
+    </defs>
+    <filter id="blurxy" filterUnits="objectBoundingBox" x="-10%" y="-10%" width="120%" height="120%">
+        <feGaussianBlur stdDeviation="5 1"/>
+    </filter>
+    <marker id="marker1" viewBox="0 0 10 10" markerWidth="2" markerHeight="2" refX="5" refY="5" markerUnits="strokeWidth">
+        <rect width="10" height="10" fill="red" stroke="none"/>
+    </marker>
+    <text x="0" y="13">The rect should be opaque green, black stroke,</text>
+    <text x="0" y="33">no markers and no dashes.</text>
+    <path id="path1" fill="green" stroke="black" d="M 30 40 L 80 40 L 80 90  L 30 90 Z"/>
+    <circle id="path2" fill="url(#grad)" stroke="black" cx="180" cy="60" r="20"/>
+    <text x="0" y="110">The circle should be opaque green, no filter,</text>
+    <text x="0" y="130">green stop color.</text>
+</svg>
index e2f0e32..a5cb855 100644 (file)
@@ -1,3 +1,21 @@
+2006-04-21  Rob Buis  <buis@kde.org>
+
+        Reviewed by hyatt.  Landed by eseidel.
+
+        Fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=8170:
+        SVG CSS property values with extra items do not get treated
+        as invalid (they should)
+
+        Fixes the handling of invalid svg css properties similar
+        to how invalid html css properties are handled, ie. discard
+        the property if there are more values in the value list than
+        expected.
+
+        Test: svg/custom/invalid-css.svg
+
+        * ksvg2/css/SVGCSSParser.cpp:
+        (WebCore::CSSParser::parseSVGValue):
+
 2006-04-23  Michael Emmel  <mike.emmel@gmail.com>
 
         Reviewed by mjs.  Landed by eseidel.
index 3fdca22..6ec106b 100644 (file)
@@ -50,10 +50,17 @@ bool CSSParser::parseSVGValue(int propId, bool important)
         return false;
 
     int id = value->id;
+
+    int num = inShorthand() ? 1 : valueList->size();
+
     if (id == CSS_VAL_INHERIT) {
+        if (num != 1)
+            return false;
         addProperty(propId, new CSSInheritedValue(), important);
         return true;
     } else if (id == CSS_VAL_INITIAL) {
+        if (num != 1)
+            return false;
         addProperty(propId, new CSSInitialValue(), important);
         return true;
     }
@@ -194,6 +201,7 @@ bool CSSParser::parseSVGValue(int propId, bool important)
             valid_primitive = true;
             break;
         }
+        /* fallthrough intentional */
     case SVGCSS_PROP_GLYPH_ORIENTATION_HORIZONTAL: // <angle> | inherit
         if(value->unit == CSSPrimitiveValue::CSS_DEG)
             parsedValue = new CSSPrimitiveValue(value->fValue, CSSPrimitiveValue::CSS_DEG);
@@ -271,14 +279,6 @@ bool CSSParser::parseSVGValue(int propId, bool important)
         else
             valid_primitive = validUnit(value, FLength, false);
         break;
-    /* shorthand properties */
-    case SVGCSS_PROP_MARKER:
-    {
-            const int properties[3] = { SVGCSS_PROP_MARKER_START,
-                                        SVGCSS_PROP_MARKER_MID,
-                                        SVGCSS_PROP_MARKER_END };
-            return parseShorthand(propId, properties, 3, important);
-    }
 
     case SVGCSS_PROP_CLIP_PATH:    // <uri> | none | inherit
     case SVGCSS_PROP_FILTER:
@@ -292,6 +292,14 @@ bool CSSParser::parseSVGValue(int propId, bool important)
         }
         break;
 
+    /* shorthand properties */
+    case SVGCSS_PROP_MARKER:
+    {
+        const int properties[3] = { SVGCSS_PROP_MARKER_START,
+                                    SVGCSS_PROP_MARKER_MID,
+                                    SVGCSS_PROP_MARKER_END };
+        return parseShorthand(propId, properties, 3, important);
+    }
     default:
         return false;
     }
@@ -307,15 +315,14 @@ bool CSSParser::parseSVGValue(int propId, bool important)
         else if(value->unit >= KDOMCSSValue::Q_EMS)
             parsedValue = new CSSQuirkPrimitiveValue(value->fValue, CSSPrimitiveValue::CSS_EMS);
         valueList->next();
-        if (valueList->current()) {
-            delete parsedValue;
-            parsedValue = 0;
-        }
     }
     if(parsedValue)
     {
-        addProperty(propId, parsedValue, important);
-        return true;
+        if (!valueList->current() || inShorthand()) {
+            addProperty(propId, parsedValue, important);
+            return true;
+        }
+        delete parsedValue;
     }
     return false;
 }