Reviewed by Oliver.
authorzimmermann <zimmermann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 3 Dec 2006 13:36:37 +0000 (13:36 +0000)
committerzimmermann <zimmermann@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 3 Dec 2006 13:36:37 +0000 (13:36 +0000)
Fix following bugs:
http://bugs.webkit.org/show_bug.cgi?id=11734
http://bugs.webkit.org/show_bug.cgi?id=11685

SVGPoint/SVGRect/SVGNumber were missing put() support.
SVGPoint.matrixTransform() was missing.

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

29 files changed:
LayoutTests/ChangeLog
LayoutTests/svg/custom/SVGNumber-interface-expected.checksum [new file with mode: 0644]
LayoutTests/svg/custom/SVGNumber-interface-expected.png [new file with mode: 0644]
LayoutTests/svg/custom/SVGNumber-interface-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/SVGNumber-interface.svg [new file with mode: 0644]
LayoutTests/svg/custom/SVGPoint-interface-expected.checksum [new file with mode: 0644]
LayoutTests/svg/custom/SVGPoint-interface-expected.png [new file with mode: 0644]
LayoutTests/svg/custom/SVGPoint-interface-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/SVGPoint-interface.svg [new file with mode: 0644]
LayoutTests/svg/custom/SVGPoint-matrixTransform-expected.checksum [new file with mode: 0644]
LayoutTests/svg/custom/SVGPoint-matrixTransform-expected.png [new file with mode: 0644]
LayoutTests/svg/custom/SVGPoint-matrixTransform-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/SVGPoint-matrixTransform.svg [new file with mode: 0644]
LayoutTests/svg/custom/SVGRect-interface-expected.checksum [new file with mode: 0644]
LayoutTests/svg/custom/SVGRect-interface-expected.png [new file with mode: 0644]
LayoutTests/svg/custom/SVGRect-interface-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/SVGRect-interface.svg [new file with mode: 0644]
WebCore/CMakeLists.txt
WebCore/ChangeLog
WebCore/DerivedSources.make
WebCore/bindings/js/JSSVGNumber.cpp
WebCore/bindings/js/JSSVGNumber.h
WebCore/bindings/js/JSSVGPoint.cpp
WebCore/bindings/js/JSSVGPoint.h
WebCore/bindings/js/JSSVGRect.cpp
WebCore/bindings/js/JSSVGRect.h
WebCore/bindings/objc/DOMSVGPoint.mm
WebCore/platform/graphics/FloatPoint.cpp
WebCore/platform/graphics/FloatPoint.h

index 5760851..6805ee7 100644 (file)
@@ -1,3 +1,29 @@
+2006-12-03  Nikolas Zimmermann  <zimmermann@kde.org>
+
+        Reviewed by Oliver.
+
+        Add a new set of svg layout tests specifically testing SVGPoint/SVGRect/SVGNumber js wrapping.
+
+        It's related to following bugs:
+        http://bugs.webkit.org/show_bug.cgi?id=11734
+        http://bugs.webkit.org/show_bug.cgi?id=11685
+
+        * svg/custom/SVGNumber-interface-expected.checksum: Added.
+        * svg/custom/SVGNumber-interface-expected.png: Added.
+        * svg/custom/SVGNumber-interface-expected.txt: Added.
+        * svg/custom/SVGNumber-interface.svg: Added.
+        * svg/custom/SVGPoint-interface-expected.checksum: Added.
+        * svg/custom/SVGPoint-interface-expected.png: Added.
+        * svg/custom/SVGPoint-interface-expected.txt: Added.
+        * svg/custom/SVGPoint-interface.svg: Added.
+        * svg/custom/SVGPoint-matrixTransform-expected.checksum: Added.
+        * svg/custom/SVGPoint-matrixTransform-expected.txt: Added.
+        * svg/custom/SVGPoint-matrixTransform.svg: Added.
+        * svg/custom/SVGRect-interface-expected.checksum: Added.
+        * svg/custom/SVGRect-interface-expected.png: Added.
+        * svg/custom/SVGRect-interface-expected.txt: Added.
+        * svg/custom/SVGRect-interface.svg: Added.
+
 2006-12-03  Rob Buis  <buis@kde.org>
 
         Reviewed by Oliver.
diff --git a/LayoutTests/svg/custom/SVGNumber-interface-expected.checksum b/LayoutTests/svg/custom/SVGNumber-interface-expected.checksum
new file mode 100644 (file)
index 0000000..2e5db2a
--- /dev/null
@@ -0,0 +1 @@
+988e95b97553fe9700d1cee4a6a45c7e
\ No newline at end of file
diff --git a/LayoutTests/svg/custom/SVGNumber-interface-expected.png b/LayoutTests/svg/custom/SVGNumber-interface-expected.png
new file mode 100644 (file)
index 0000000..918cbfe
Binary files /dev/null and b/LayoutTests/svg/custom/SVGNumber-interface-expected.png differ
diff --git a/LayoutTests/svg/custom/SVGNumber-interface-expected.txt b/LayoutTests/svg/custom/SVGNumber-interface-expected.txt
new file mode 100644 (file)
index 0000000..13da9a4
--- /dev/null
@@ -0,0 +1,10 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+    KCanvasContainer {svg} at (0,0) size 100x200
+      KCanvasItem {rect} at (0,0) size 100x20 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (0,30) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,30.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (0,60) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,60.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (0,90) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,90.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (0,120) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,120.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (0,150) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,150.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (0,180) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,180.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
diff --git a/LayoutTests/svg/custom/SVGNumber-interface.svg b/LayoutTests/svg/custom/SVGNumber-interface.svg
new file mode 100644 (file)
index 0000000..ba6faac
--- /dev/null
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" onload="init()">
+
+    <script>
+        function init()
+        {
+            var number = document.rootElement.createSVGNumber();
+
+            // Test initial value
+            if (number.value == 0) {
+                document.getElementById("test1").setAttribute("fill", "green");
+            }
+            
+            // Assign new values from local function
+            number.value = 100;
+            if (number.value == 100) {
+                document.getElementById("test2").setAttribute("fill", "green");
+            }
+
+            // Assign new values from external function
+            assignValues(number);
+            if (number.value == 300) {
+                document.getElementById("test3").setAttribute("fill", "green");
+            }
+
+            // Create new number in external function, check values
+            var newNumber = createNewNumber();
+            if (newNumber.value == 66) {
+                document.getElementById("test4").setAttribute("fill", "green");
+            }
+
+            // Check swapping of number objects
+            var savedNumber = number;
+            number = newNumber;
+            if (number.value == 66) {
+                document.getElementById("test5").setAttribute("fill", "green");
+            }
+
+            number = savedNumber;
+            if (number.value == 300) {
+                document.getElementById("test6").setAttribute("fill", "green");
+            }
+
+            // Modifying savedNumber, should also modify number
+            savedNumber.value = 150;
+
+            if (number.value == 150) {
+                document.getElementById("test7").setAttribute("fill", "green");
+            }
+        }
+
+        function assignValues(n)
+        {
+            n.value = 300;
+        }
+
+        function createNewNumber()
+        {
+            var number = document.rootElement.createSVGNumber();
+            number.value = 66;
+            return number;
+        }
+    </script>
+    
+    <rect id="test1" transform="translate(0, 0)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test2" transform="translate(0, 30)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test3" transform="translate(0, 60)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test4" transform="translate(0, 90)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test5" transform="translate(0, 120)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test6" transform="translate(0, 150)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test7" transform="translate(0, 180)" x="0" y="0" width="100" height="20" fill="red"/>
+</svg>
diff --git a/LayoutTests/svg/custom/SVGPoint-interface-expected.checksum b/LayoutTests/svg/custom/SVGPoint-interface-expected.checksum
new file mode 100644 (file)
index 0000000..851133c
--- /dev/null
@@ -0,0 +1 @@
+55229c4afff83a90197ac49e08518925
\ No newline at end of file
diff --git a/LayoutTests/svg/custom/SVGPoint-interface-expected.png b/LayoutTests/svg/custom/SVGPoint-interface-expected.png
new file mode 100644 (file)
index 0000000..8b2da33
Binary files /dev/null and b/LayoutTests/svg/custom/SVGPoint-interface-expected.png differ
diff --git a/LayoutTests/svg/custom/SVGPoint-interface-expected.txt b/LayoutTests/svg/custom/SVGPoint-interface-expected.txt
new file mode 100644 (file)
index 0000000..fd20457
--- /dev/null
@@ -0,0 +1,17 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+    KCanvasContainer {svg} at (0,0) size 210x200
+      KCanvasItem {rect} at (0,0) size 100x20 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (0,30) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,30.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (0,60) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,60.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (0,90) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,90.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (0,120) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,120.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (0,150) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,150.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (0,180) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,180.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (110,0) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(110.00,0.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (110,30) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(110.00,30.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (110,60) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(110.00,60.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (110,90) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(110.00,90.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (110,120) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(110.00,120.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (110,150) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(110.00,150.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (110,180) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(110.00,180.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
diff --git a/LayoutTests/svg/custom/SVGPoint-interface.svg b/LayoutTests/svg/custom/SVGPoint-interface.svg
new file mode 100644 (file)
index 0000000..70dfaee
--- /dev/null
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" onload="init()">
+
+    <script>
+        function init()
+        {
+            var point = document.rootElement.createSVGPoint();
+
+            // Test initial values
+            if (point.x == 0) {
+                document.getElementById("test1").setAttribute("fill", "green");
+            }
+            if (point.y == 0) {
+                document.getElementById("test2").setAttribute("fill", "green");
+            }
+
+            // Assign new values from local function
+            point.x = 100;
+            point.y = 200;
+            if (point.x == 100) {
+                document.getElementById("test3").setAttribute("fill", "green");
+            }
+            if (point.y == 200) {
+                document.getElementById("test4").setAttribute("fill", "green");
+            }
+
+            // Assign new values from external function
+            assignValues(point);
+            if (point.x == 300) {
+                document.getElementById("test5").setAttribute("fill", "green");
+            }
+            if (point.y == 400) {
+                document.getElementById("test6").setAttribute("fill", "green");
+            }
+
+            // Create new point in external function, check values
+            var newPoint = createNewPoint();
+            if (newPoint.x == 66) {
+                document.getElementById("test7").setAttribute("fill", "green");
+            }
+            if (newPoint.y == 666) {
+                document.getElementById("test8").setAttribute("fill", "green");
+            }
+
+            // Check swapping of point objects
+            var savedPoint = point;
+            point = newPoint;
+            if (point.x == 66) {
+                document.getElementById("test9").setAttribute("fill", "green");
+            }
+            if (point.y == 666) {
+                document.getElementById("test10").setAttribute("fill", "green");
+            }
+
+            point = savedPoint;
+            if (point.x == 300) {
+                document.getElementById("test11").setAttribute("fill", "green");
+            }
+            if (point.y == 400) {
+                document.getElementById("test12").setAttribute("fill", "green");
+            }
+
+            // Modifying savedPoint, should also modify point
+            savedPoint.x = 150;
+            savedPoint.y = 250;
+
+            if (point.x == 150) {
+                document.getElementById("test13").setAttribute("fill", "green");
+            }
+            if (point.y == 250) {
+                document.getElementById("test14").setAttribute("fill", "green");
+            }
+        }
+
+        function assignValues(p)
+        {
+            p.x = 300;
+            p.y = 400;
+        }
+
+        function createNewPoint()
+        {
+            var point = document.rootElement.createSVGPoint();
+            point.x = 66;
+            point.y = 666;
+            return point;
+        }
+    </script>
+    
+    <rect id="test1" transform="translate(0, 0)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test2" transform="translate(0, 30)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test3" transform="translate(0, 60)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test4" transform="translate(0, 90)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test5" transform="translate(0, 120)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test6" transform="translate(0, 150)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test7" transform="translate(0, 180)" x="0" y="0" width="100" height="20" fill="red"/>
+
+    <rect id="test8" transform="translate(110, 0)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test9" transform="translate(110, 30)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test10" transform="translate(110, 60)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test11" transform="translate(110, 90)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test12" transform="translate(110, 120)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test13" transform="translate(110, 150)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test14" transform="translate(110, 180)" x="0" y="0" width="100" height="20" fill="red"/>
+</svg>
diff --git a/LayoutTests/svg/custom/SVGPoint-matrixTransform-expected.checksum b/LayoutTests/svg/custom/SVGPoint-matrixTransform-expected.checksum
new file mode 100644 (file)
index 0000000..72b6bec
--- /dev/null
@@ -0,0 +1 @@
+f75846c96fba8cb39ed15e33572506ae
\ No newline at end of file
diff --git a/LayoutTests/svg/custom/SVGPoint-matrixTransform-expected.png b/LayoutTests/svg/custom/SVGPoint-matrixTransform-expected.png
new file mode 100644 (file)
index 0000000..bee731c
Binary files /dev/null and b/LayoutTests/svg/custom/SVGPoint-matrixTransform-expected.png differ
diff --git a/LayoutTests/svg/custom/SVGPoint-matrixTransform-expected.txt b/LayoutTests/svg/custom/SVGPoint-matrixTransform-expected.txt
new file mode 100644 (file)
index 0000000..b610a4b
--- /dev/null
@@ -0,0 +1,6 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+    KCanvasContainer {svg} at (80,24) size 172x72
+      RenderSVGText {text} at (20,20) size 800x18
+        RenderSVGInlineText {#text} at (0,-14) size 43x18
+          text run at (0,-14) width 43: "Passed"
diff --git a/LayoutTests/svg/custom/SVGPoint-matrixTransform.svg b/LayoutTests/svg/custom/SVGPoint-matrixTransform.svg
new file mode 100644 (file)
index 0000000..7b67b49
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" onload="runTest()">
+    <title>Test of the SVGPoint object and .matrixTransform() method</title>
+    <script type="text/ecmascript">
+        <![CDATA[
+            function runTest() {
+                var svgPoint = document.rootElement.createSVGPoint();
+                var ctm = document.getElementById("test").getScreenCTM();
+                svgPoint.x = 30;
+                svgPoint.y = 30;
+                svgPoint = svgPoint.matrixTransform(ctm.inverse());
+                if (svgPoint.x == 15 && svgPoint.y == 15) {
+                    document.getElementById("test").textContent = "Passed";
+                }
+            }
+        ]]>
+    </script>
+    <text transform="scale(2)" x="20" y="20" id="test">Failed</text>
+</svg>
diff --git a/LayoutTests/svg/custom/SVGRect-interface-expected.checksum b/LayoutTests/svg/custom/SVGRect-interface-expected.checksum
new file mode 100644 (file)
index 0000000..851133c
--- /dev/null
@@ -0,0 +1 @@
+55229c4afff83a90197ac49e08518925
\ No newline at end of file
diff --git a/LayoutTests/svg/custom/SVGRect-interface-expected.png b/LayoutTests/svg/custom/SVGRect-interface-expected.png
new file mode 100644 (file)
index 0000000..8b2da33
Binary files /dev/null and b/LayoutTests/svg/custom/SVGRect-interface-expected.png differ
diff --git a/LayoutTests/svg/custom/SVGRect-interface-expected.txt b/LayoutTests/svg/custom/SVGRect-interface-expected.txt
new file mode 100644 (file)
index 0000000..fd20457
--- /dev/null
@@ -0,0 +1,17 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+    KCanvasContainer {svg} at (0,0) size 210x200
+      KCanvasItem {rect} at (0,0) size 100x20 [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (0,30) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,30.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (0,60) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,60.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (0,90) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,90.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (0,120) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,120.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (0,150) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,150.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (0,180) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(0.00,180.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (110,0) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(110.00,0.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (110,30) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(110.00,30.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (110,60) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(110.00,60.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (110,90) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(110.00,90.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (110,120) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(110.00,120.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (110,150) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(110.00,150.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
+      KCanvasItem {rect} at (110,180) size 100x20 [transform={m=((1.00,0.00)(0.00,1.00)) t=(110.00,180.00)}] [fill={[type=SOLID] [color=#008000]}] [data="M0.00,0.00L100.00,0.00L100.00,20.00L0.00,20.00"]
diff --git a/LayoutTests/svg/custom/SVGRect-interface.svg b/LayoutTests/svg/custom/SVGRect-interface.svg
new file mode 100644 (file)
index 0000000..255618a
--- /dev/null
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" onload="init()">
+
+    <script><![CDATA[
+        function init()
+        {
+            var rect = document.rootElement.createSVGRect();
+
+            // Test initial values
+            if (rect.x == 0 && rect.y == 0) {
+                document.getElementById("test1").setAttribute("fill", "green");
+            }
+            if (rect.width == 0 && rect.height == 0) {
+                document.getElementById("test2").setAttribute("fill", "green");
+            }
+
+            // Assign new values from local function
+            rect.x = 100; rect.y = 200;
+            rect.width = 300; rect.height = 400;
+            if (rect.x == 100 && rect.y == 200) {
+                document.getElementById("test3").setAttribute("fill", "green");
+            }
+            if (rect.width == 300 && rect.height == 400) {
+                document.getElementById("test4").setAttribute("fill", "green");
+            }
+
+            // Assign new values from external function
+            assignValues(rect);
+            if (rect.x == 250 && rect.y == 350) {
+                document.getElementById("test5").setAttribute("fill", "green");
+            }
+            if (rect.width == 450 && rect.height == 550) {
+                document.getElementById("test6").setAttribute("fill", "green");
+            }
+
+            // Create new rect in external function, check values
+            var newRect = createNewRect();
+            if (newRect.x == 6 && newRect.y == 66) {
+                document.getElementById("test7").setAttribute("fill", "green");
+            }
+            if (newRect.width == 666 && newRect.height == 6666) {
+                document.getElementById("test8").setAttribute("fill", "green");
+            }
+
+            // Check swapping of rect objects
+            var savedRect = rect;
+            rect = newRect;
+            if (rect.x == 6 && rect.y == 66) {
+                document.getElementById("test9").setAttribute("fill", "green");
+            }
+            if (rect.width == 666 && rect.height == 6666) {
+                document.getElementById("test10").setAttribute("fill", "green");
+            }
+
+            rect = savedRect;
+            if (rect.x == 250 && rect.y == 350) {
+                document.getElementById("test11").setAttribute("fill", "green");
+            }
+            if (rect.width == 450 && rect.height == 550) {
+                document.getElementById("test12").setAttribute("fill", "green");
+            }
+
+            // Modifying savedRect, should also modify rect
+            savedRect.x = 150; savedRect.y = 250;
+            savedRect.width = 350; savedRect.height = 450;
+
+            if (rect.x == 150 && rect.y == 250) {
+                document.getElementById("test13").setAttribute("fill", "green");
+            }
+            if (rect.width == 350 && rect.height == 450) {
+                document.getElementById("test14").setAttribute("fill", "green");
+            }
+        }
+
+        function assignValues(r)
+        {
+            r.x = 250; r.y = 350;
+            r.width = 450; r.height = 550;
+        }
+
+        function createNewRect()
+        {
+            var rect = document.rootElement.createSVGRect();
+            rect.x = 6; rect.y = 66;
+            rect.width = 666; rect.height = 6666;
+            return rect;
+        }
+    ]]></script>
+    
+    <rect id="test1" transform="translate(0, 0)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test2" transform="translate(0, 30)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test3" transform="translate(0, 60)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test4" transform="translate(0, 90)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test5" transform="translate(0, 120)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test6" transform="translate(0, 150)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test7" transform="translate(0, 180)" x="0" y="0" width="100" height="20" fill="red"/>
+
+    <rect id="test8" transform="translate(110, 0)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test9" transform="translate(110, 30)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test10" transform="translate(110, 60)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test11" transform="translate(110, 90)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test12" transform="translate(110, 120)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test13" transform="translate(110, 150)" x="0" y="0" width="100" height="20" fill="red"/>
+    <rect id="test14" transform="translate(110, 180)" x="0" y="0" width="100" height="20" fill="red"/>
+</svg>
index 3a436bc..2f99bee 100644 (file)
@@ -384,6 +384,7 @@ create_generated_cpp_helper( JSHTMLInputElementBaseTable.inl)
 
 IF (WEBKIT_USE_SVG_SUPPORT)
     create_cpp_lut( bindings/js/JSSVGNumber.cpp JSSVGNumberTable.inl bindings/js/JSSVGNumber.cpp )
+    create_generated_cpp_helper( JSSVGNumberTable.inl )
 
     create_cpp_lut( bindings/js/JSSVGPoint.cpp JSSVGPointTable.inl bindings/js/JSSVGPoint.cpp )
     create_generated_cpp_helper( JSSVGPointTable.inl )
index 7b4417b..656c106 100644 (file)
@@ -1,5 +1,60 @@
 2006-12-03  Nikolas Zimmermann  <zimmermann@kde.org>
 
+        Reviewed by Oliver.
+
+        Fix following bugs:
+        http://bugs.webkit.org/show_bug.cgi?id=11734
+        http://bugs.webkit.org/show_bug.cgi?id=11685
+
+        SVGPoint/SVGRect/SVGNumber were missing put() support.
+        SVGPoint.matrixTransform() was missing.
+
+        In SVG DOM there are no cases where a readwrite property
+        exists of type SVGRect/SVGNumber/SVGPoint. Only function
+        calls returns instances of these objects. It would make
+        no sense to be able to write "someObj.getBbox().x = 100", and
+        modify the actual stored internal value of "someObj".
+
+        The only cases where these modification makes sense, is
+        when these SVGPoint/SVGRect/SVGNumber objects are created
+        via document.rootElement.createSVGPoint/Rect/Number (SVGSVGElement interface).
+
+        Result: The current implementation, where we just modify the stored FloatPoint/FloatRect/double
+        values in the JSSVGPoint/Rect/Number wrappers directly, is sufficient.
+
+        Patch created by Rob & me - co production.
+        Long live the great carto.next examples! :-)
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * bindings/js/JSSVGNumber.cpp:
+        (WebCore::):
+        (WebCore::JSSVGNumber::getOwnPropertySlot):
+        (WebCore::JSSVGNumber::getValueProperty):
+        (WebCore::JSSVGNumber::put):
+        (WebCore::JSSVGNumber::putValueProperty):
+        * bindings/js/JSSVGNumber.h:
+        (WebCore::JSSVGNumber::):
+        (WebCore::JSSVGNumber::impl):
+        * bindings/js/JSSVGPoint.cpp:
+        (WebCore::JSSVGPoint::JSSVGPoint):
+        (WebCore::JSSVGPoint::put):
+        (WebCore::JSSVGPoint::putValueProperty):
+        (WebCore::JSSVGPointProtoFunc::callAsFunction):
+        * bindings/js/JSSVGPoint.h:
+        (WebCore::JSSVGPoint::):
+        * bindings/js/JSSVGRect.cpp:
+        (WebCore::JSSVGRect::put):
+        (WebCore::JSSVGRect::putValueProperty):
+        * bindings/js/JSSVGRect.h:
+        * bindings/objc/DOMSVGPoint.mm:
+        (-[DOMSVGPoint matrixTransform:]):
+        * platform/graphics/FloatPoint.cpp:
+        (WebCore::FloatPoint::matrixTransform):
+        * platform/graphics/FloatPoint.h:
+
+2006-12-03  Nikolas Zimmermann  <zimmermann@kde.org>
+
         Reviewed by Dave.
 
         Another missing piece in the platform/graphics move.
index 43ddc39..a3d7e04 100644 (file)
@@ -455,6 +455,7 @@ all : \
     JSSVGPointTable.cpp \
     JSSVGPreserveAspectRatio.h \
     JSSVGRectTable.cpp \
+    JSSVGNumberTable.cpp \
     JSSVGElement.h \
     JSSVGSVGElement.h \
     JSSVGEllipseElement.h \
index bed7d59..42f04b5 100644 (file)
 #include "config.h"
 #include "JSSVGNumber.h"
 
+#include "JSSVGNumberTable.cpp"
+
 using namespace KJS;
 
 namespace WebCore {
 
-const ClassInfo JSSVGNumber::info = { "SVGNumber", 0, 0, 0 };
+const ClassInfo JSSVGNumber::info = { "SVGNumber", 0, &JSSVGNumberTable, 0 };
+
+/*
+@begin JSSVGNumberTable 4
+  value         WebCore::JSSVGNumber::NumberValue       DontDelete
+@end
+*/
 
 JSSVGNumber::~JSSVGNumber()
 {
@@ -38,19 +46,31 @@ JSSVGNumber::~JSSVGNumber()
 
 bool JSSVGNumber::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
 {
-    if (propertyName == "value") {
-        slot.setCustom(this, getValue);
-        return true;
+    return getStaticValueSlot<JSSVGNumber, DOMObject>(exec,  &JSSVGNumberTable, this, propertyName, slot);
+}
+
+JSValue* JSSVGNumber::getValueProperty(ExecState* exec, int token) const
+{
+    switch (token) {
+    case NumberValue:
+        return jsNumber(m_value);
+    default:
+        return 0;
     }
-    return DOMObject::getOwnPropertySlot(exec, propertyName, slot);
 }
 
-JSValue* JSSVGNumber::getValue(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot)
+void JSSVGNumber::put(KJS::ExecState* exec, const KJS::Identifier& propertyName, KJS::JSValue* value, int attr)
 {
-    JSSVGNumber* thisObj = static_cast<JSSVGNumber*>(slot.slotBase());
-    if (propertyName == "value")
-        return jsNumber(thisObj->m_value);
-    return 0;
+    lookupPut<JSSVGNumber>(exec, propertyName, value, attr, &JSSVGNumberTable, this);
+}
+
+void JSSVGNumber::putValueProperty(KJS::ExecState* exec, int token, KJS::JSValue* value, int attr)
+{
+    switch (token) {
+    case NumberValue:
+        m_value = value->toNumber(exec);
+        break;
+    }
 }
 
 JSValue* getJSSVGNumber(ExecState* exec, double v)
index 96b8798..ec52993 100644 (file)
@@ -34,13 +34,20 @@ class JSSVGNumber : public KJS::DOMObject {
 public:
     JSSVGNumber(KJS::ExecState*, double v) : m_value(v) { }
     ~JSSVGNumber();
-    
+
     virtual bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);
-    static JSValue* getValue(KJS::ExecState*, KJS::JSObject* originalObject, const KJS::Identifier& propertyName, const KJS::PropertySlot& slot);
-    // no put - all read-only
-    
+    JSValue* getValueProperty(KJS::ExecState*, int token) const;
+
+    virtual void put(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*, int attr = KJS::None);
+    void putValueProperty(KJS::ExecState*, int, KJS::JSValue*, int attr);
+
     virtual const KJS::ClassInfo* classInfo() const { return &info; }
     static const KJS::ClassInfo info;
+
+    enum { NumberValue };
+
+    double impl() { return m_value; }
+
 private:
     double m_value;
 };
index ab183f5..b8e4e22 100644 (file)
@@ -24,7 +24,9 @@
  */
 
 #include "config.h"
+#include "JSSVGMatrix.h"
 #include "JSSVGPoint.h"
+#include "SVGMatrix.h"
 
 #include "JSSVGPointTable.cpp"
 
@@ -35,11 +37,22 @@ namespace WebCore {
 const ClassInfo JSSVGPoint::info = { "SVGPoint", 0, &JSSVGPointTable, 0 };
 /*
 @begin JSSVGPointTable 4
-  x         WebCore::JSSVGPoint::PointX       DontDelete|ReadOnly
-  y         WebCore::JSSVGPoint::PointY       DontDelete|ReadOnly
+  x         WebCore::JSSVGPoint::PointX       DontDelete
+  y         WebCore::JSSVGPoint::PointY       DontDelete
+@end
+@begin JSSVGPointProtoTable 2
+ matrixTransform    WebCore::JSSVGPoint::MatrixTransform DontDelete|Function 1
 @end
 */
 
+KJS_IMPLEMENT_PROTOFUNC(JSSVGPointProtoFunc)
+KJS_IMPLEMENT_PROTOTYPE("JSSVGPoint", JSSVGPointProto, JSSVGPointProtoFunc)
+
+JSSVGPoint::JSSVGPoint(KJS::ExecState* exec, const FloatPoint& p) : m_point(p)
+{
+    setPrototype(JSSVGPointProto::self(exec));
+}
+
 JSSVGPoint::~JSSVGPoint()
 {
 }
@@ -61,6 +74,42 @@ JSValue* JSSVGPoint::getValueProperty(ExecState* exec, int token) const
     }
 }
 
+void JSSVGPoint::put(KJS::ExecState* exec, const KJS::Identifier& propertyName, KJS::JSValue* value, int attr)
+{
+    lookupPut<JSSVGPoint>(exec, propertyName, value, attr, &JSSVGPointTable, this);
+}
+
+void JSSVGPoint::putValueProperty(KJS::ExecState* exec, int token, KJS::JSValue* value, int attr)
+{
+    switch (token) {
+    case PointX:
+        m_point.setX(value->toNumber(exec));
+        break;
+    case PointY:
+        m_point.setY(value->toNumber(exec));
+        break;
+    }
+}
+
+JSValue* JSSVGPointProtoFunc::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
+{
+    if (!thisObj->inherits(&JSSVGPoint::info))
+        return throwError(exec, TypeError);
+
+    FloatPoint point = static_cast<JSSVGPoint*>(thisObj)->impl();
+    switch (id) {
+        case JSSVGPoint::MatrixTransform: {
+            SVGMatrix* mat = toSVGMatrix(args[0]);
+            if (!mat)
+                return jsUndefined();
+            FloatPoint p = point.matrixTransform(mat->matrix());
+            return getJSSVGPoint(exec, p);
+        }
+    }
+
+    return jsUndefined();
+}
+
 JSValue* getJSSVGPoint(ExecState* exec, const FloatPoint& p)
 {
     return new JSSVGPoint(exec, p);
index 70d44fd..3c8a40a 100644 (file)
 
 namespace WebCore {
 
+KJS_DEFINE_PROTOTYPE(JSSVGPointProto)
+
 class JSSVGPoint : public KJS::DOMObject {
 public:
-    JSSVGPoint(KJS::ExecState*, const FloatPoint& p) : m_point(p) { }
+    JSSVGPoint(KJS::ExecState*, const FloatPoint&);
     ~JSSVGPoint();
-    
+
     virtual bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);
     JSValue* getValueProperty(KJS::ExecState*, int token) const;
-    // no put - all read-only
-    
+
+    virtual void put(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*, int attr = KJS::None);
+    void putValueProperty(KJS::ExecState*, int, KJS::JSValue*, int attr);
+
     virtual const KJS::ClassInfo* classInfo() const { return &info; }
     static const KJS::ClassInfo info;
-    enum { PointX, PointY };
-    
+
+    enum { PointX, PointY, MatrixTransform };
+
     FloatPoint impl() { return m_point; }
-    
 private:
     FloatPoint m_point;
+    friend class JSSVGPointProto;
 };
 
 KJS::JSValue* getJSSVGPoint(KJS::ExecState*, const FloatPoint&);
index 73ebbab..03adec7 100644 (file)
@@ -35,10 +35,10 @@ namespace WebCore {
 const ClassInfo JSSVGRect::info = { "SVGRect", 0, &JSSVGRectTable, 0 };
 /*
 @begin JSSVGRectTable 4
-  x         WebCore::JSSVGRect::RectX           DontDelete|ReadOnly
-  y         WebCore::JSSVGRect::RectY           DontDelete|ReadOnly
-  width     WebCore::JSSVGRect::RectWidth       DontDelete|ReadOnly
-  height    WebCore::JSSVGRect::RectHeight      DontDelete|ReadOnly
+  x         WebCore::JSSVGRect::RectX           DontDelete
+  y         WebCore::JSSVGRect::RectY           DontDelete
+  width     WebCore::JSSVGRect::RectWidth       DontDelete
+  height    WebCore::JSSVGRect::RectHeight      DontDelete
 @end
 */
 
@@ -67,6 +67,29 @@ JSValue* JSSVGRect::getValueProperty(ExecState* exec, int token) const
     }
 }
 
+void JSSVGRect::put(KJS::ExecState* exec, const KJS::Identifier& propertyName, KJS::JSValue* value, int attr)
+{
+    lookupPut<JSSVGRect>(exec, propertyName, value, attr, &JSSVGRectTable, this);
+}
+
+void JSSVGRect::putValueProperty(KJS::ExecState* exec, int token, KJS::JSValue* value, int attr)
+{
+    switch (token) {
+    case RectX:
+        m_rect.setX(value->toNumber(exec));
+        break;
+    case RectY:
+        m_rect.setY(value->toNumber(exec));
+        break;
+    case RectWidth:
+        m_rect.setWidth(value->toNumber(exec));
+        break;
+    case RectHeight:
+        m_rect.setHeight(value->toNumber(exec));
+        break;
+    }  
+}
+
 JSValue* getJSSVGRect(ExecState* exec, const FloatRect& r)
 {
     return new JSSVGRect(exec, r);
index a2f2f23..9837402 100644 (file)
@@ -35,17 +35,20 @@ class JSSVGRect : public KJS::DOMObject {
 public:
     JSSVGRect(KJS::ExecState*, const FloatRect& r) : m_rect(r) { }
     ~JSSVGRect();
-    
+
     virtual bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);
     JSValue* getValueProperty(KJS::ExecState*, int token) const;
-    // no put - all read-only
-    
+
+    virtual void put(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*, int attr = KJS::None);
+    void putValueProperty(KJS::ExecState*, int, KJS::JSValue*, int attr);
+
     virtual const KJS::ClassInfo* classInfo() const { return &info; }
     static const KJS::ClassInfo info;
+
     enum { RectX, RectY, RectWidth, RectHeight };
-    
+
     FloatRect impl() { return m_rect; }
-    
+
 private:
     FloatRect m_rect;
 };
index e6f98d7..b50e064 100644 (file)
@@ -31,7 +31,9 @@
 #import "DOMSVGPoint.h"
 
 #import "DOMInternal.h"
+#import "DOMSVGMatrix.h"
 #import "FloatPoint.h"
+#import "SVGMatrix.h"
 
 #define IMPL reinterpret_cast<WebCore::FloatPoint*>(_internal)
 
@@ -71,8 +73,8 @@
 
 - (DOMSVGPoint *)matrixTransform:(DOMSVGMatrix *)matrix
 {
-    // FIXME: IMPLEMENT ME
-    return [DOMSVGPoint _SVGPointWith:WebCore::FloatPoint()];
+    ASSERT(matrix);
+    return [DOMSVGPoint _SVGPointWith:IMPL->matrixTransform([matrix _SVGMatrix]->matrix())];
 }
 
 @end
index 5eb255e..fb69ad5 100644 (file)
  */
 
 #include "config.h"
-#include "IntPoint.h"
-
 #include "FloatPoint.h"
 
+#include "AffineTransform.h"
+#include "IntPoint.h"
+
 namespace WebCore {
 
 FloatPoint::FloatPoint(const IntPoint& p) : m_x(p.x()), m_y(p.y())
 {
 }
 
+FloatPoint FloatPoint::matrixTransform(const AffineTransform& transform) const
+{
+    double newX, newY;
+    transform.map((double)m_x, (double)m_y, &newX, &newY);
+    return FloatPoint(newX, newY);
+}
+
 }
index 84cf196..8a5473f 100644 (file)
@@ -52,6 +52,7 @@ class TPoint;
 
 namespace WebCore {
 
+class AffineTransform;
 class IntPoint;
 
 class FloatPoint {
@@ -87,10 +88,13 @@ public:
     FloatPoint(const TPoint& );
 #endif
 
+    FloatPoint matrixTransform(const AffineTransform&) const;
+
 private:
     float m_x, m_y;
 };
 
+
 inline FloatPoint& operator+=(FloatPoint& a, const FloatSize& b)
 {
     a.move(b.width(), b.height());