Reviewed by Mitz.
authorrwlbuis <rwlbuis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Nov 2006 22:39:24 +0000 (22:39 +0000)
committerrwlbuis <rwlbuis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Nov 2006 22:39:24 +0000 (22:39 +0000)
        http://bugs.webkit.org/show_bug.cgi?id=11666
        .getScreenCTM() returns wrong values

        Take into account the local transform matrix too and
        so fix getScreenCTM/getCTM for <text>.

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

LayoutTests/ChangeLog
LayoutTests/svg/custom/text-ctm-expected.checksum [new file with mode: 0644]
LayoutTests/svg/custom/text-ctm-expected.png [new file with mode: 0644]
LayoutTests/svg/custom/text-ctm-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/text-ctm.svg [new file with mode: 0644]
WebCore/ChangeLog
WebCore/ksvg2/svg/SVGStyledTransformableElement.cpp
WebCore/ksvg2/svg/SVGTextElement.cpp
WebCore/ksvg2/svg/SVGTransformable.cpp
WebCore/ksvg2/svg/SVGTransformable.h

index 45df4a52a2d9574c4e8cc22ce27e0bb081974bff..f2a9c19b54705ed559e4f0025d84682c8cdab8c8 100644 (file)
@@ -1,3 +1,16 @@
+2006-11-24  Rob Buis  <buis@kde.org>
+
+        Reviewed by Mitz.
+
+        Testcase for:
+        http://bugs.webkit.org/show_bug.cgi?id=11666
+        .getScreenCTM() returns wrong values
+
+        * svg/custom/text-ctm-expected.checksum: Added.
+        * svg/custom/text-ctm-expected.png: Added.
+        * svg/custom/text-ctm-expected.txt: Added.
+        * svg/custom/text-ctm.svg: Added.
+
 2006-11-22  Rob Buis  <buis@kde.org>
 
         Reviewed by Eric.
diff --git a/LayoutTests/svg/custom/text-ctm-expected.checksum b/LayoutTests/svg/custom/text-ctm-expected.checksum
new file mode 100644 (file)
index 0000000..596df03
--- /dev/null
@@ -0,0 +1 @@
+542cb598974556753153930d1c3dd079
\ No newline at end of file
diff --git a/LayoutTests/svg/custom/text-ctm-expected.png b/LayoutTests/svg/custom/text-ctm-expected.png
new file mode 100644 (file)
index 0000000..54c41af
Binary files /dev/null and b/LayoutTests/svg/custom/text-ctm-expected.png differ
diff --git a/LayoutTests/svg/custom/text-ctm-expected.txt b/LayoutTests/svg/custom/text-ctm-expected.txt
new file mode 100644 (file)
index 0000000..491dbd3
--- /dev/null
@@ -0,0 +1,8 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+    KCanvasContainer {svg} at (140,84) size 172x72
+      KCanvasContainer {g} at (140,84) size 172x72 [transform={m=((1.00,0.00)(0.00,1.00)) t=(10.00,10.00)}]
+        KCanvasContainer {svg} at (140,84) size 172x72
+          RenderSVGText {text} at (70,70) size 800x18
+            RenderSVGInlineText {#text} at (0,-14) size 43x18
+              text run at (0,-14) width 43: "Passed"
diff --git a/LayoutTests/svg/custom/text-ctm.svg b/LayoutTests/svg/custom/text-ctm.svg
new file mode 100644 (file)
index 0000000..8655902
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Basic//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-basic.dtd">
+<svg version="1.1" baseProfile="basic" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="svg-root" width="100%" height="100%" onload="runTest()">
+   <script type="text/ecmascript"><![CDATA[
+      function runTest() {
+         var ctm = document.getElementById("test").getCTM();
+         if (ctm.a == 2 && ctm.b == 0 && ctm.c == 0 && ctm.d == 2 &&
+             ctm.e == -50 && ctm.f == -50) {
+             var ctm = document.getElementById("test").getScreenCTM();
+             if (ctm.a == 2 && ctm.b == 0 && ctm.c == 0 && ctm.d == 2 &&
+                 ctm.e == -40 && ctm.f == -40) {
+                 document.getElementById("test").textContent = "Passed";
+             }
+         }
+      }
+   ]]></script>
+   <g  transform="translate(10, 10)">
+   <svg>
+     <text transform="scale(2) translate(-25, -25)" id="test" x="70" y="70" >Failed</text>
+   </svg>
+   </g>
+</svg>
index 78a203ac552cb60b2a0cfd20ffee3e02e2c03672..74d335521a461f342598e09c961e04be1de91835 100644 (file)
@@ -1,3 +1,24 @@
+2006-11-24  Rob Buis  <buis@kde.org>
+
+        Reviewed by Mitz.
+
+        http://bugs.webkit.org/show_bug.cgi?id=11666
+        .getScreenCTM() returns wrong values
+
+        Take into account the local transform matrix too and
+        so fix getScreenCTM/getCTM for <text>.
+
+        * ksvg2/svg/SVGStyledTransformableElement.cpp:
+        (SVGStyledTransformableElement::getCTM):
+        (SVGStyledTransformableElement::getScreenCTM):
+        * ksvg2/svg/SVGTextElement.cpp:
+        (WebCore::SVGTextElement::getScreenCTM):
+        (WebCore::SVGTextElement::getCTM):
+        * ksvg2/svg/SVGTransformable.cpp:
+        (WebCore::SVGTransformable::getCTM):
+        (WebCore::SVGTransformable::getScreenCTM):
+        * ksvg2/svg/SVGTransformable.h:
+
 2006-11-22  Rob Buis  <buis@kde.org>
 
         Reviewed by Eric.
index 47f7c950edf91801217aed8e8e9c716492aedc75..2915b5204d7ee9d33d684e7e3f1db372d5815038 100644 (file)
@@ -57,22 +57,12 @@ SVGMatrix *SVGStyledTransformableElement::localMatrix() const
 
 SVGMatrix *SVGStyledTransformableElement::getCTM() const
 {
-    SVGMatrix *ctm = SVGLocatable::getCTM(this);
-
-    if(m_localMatrix)
-        ctm->multiply(m_localMatrix.get());
-
-    return ctm;
+    return SVGTransformable::getCTM(this);
 }
 
 SVGMatrix *SVGStyledTransformableElement::getScreenCTM() const
 {
-    SVGMatrix *ctm = SVGLocatable::getScreenCTM(this);
-
-    if(m_localMatrix)
-        ctm->multiply(m_localMatrix.get());
-
-    return ctm;
+    return SVGTransformable::getScreenCTM(this);
 }
 
 void SVGStyledTransformableElement::updateLocalTransform(SVGTransformList *localTransforms)
index c1ad875cafce1dfb37d342d1d850260143a7665b..4048e97ca81403852c17c92740f6d8557a4e03f8 100644 (file)
@@ -104,12 +104,12 @@ FloatRect SVGTextElement::getBBox() const
 
 SVGMatrix* SVGTextElement::getScreenCTM() const
 {
-    return SVGLocatable::getScreenCTM(this);
+    return SVGTransformable::getScreenCTM(this);
 }
 
 SVGMatrix* SVGTextElement::getCTM() const
 {
-    return SVGLocatable::getScreenCTM(this);
+    return SVGTransformable::getCTM(this);
 }
 
 RenderObject* SVGTextElement::createRenderer(RenderArena* arena, RenderStyle* style)
index bf96eb80a07438b85ea6c7c92d81b447f8b28e64..918f4d54d8887d2f5506605a212a32d87826b076 100644 (file)
@@ -41,6 +41,20 @@ SVGTransformable::~SVGTransformable()
 {
 }
 
+SVGMatrix* SVGTransformable::getCTM(const SVGElement* element) const
+{
+    SVGMatrix* ctm = SVGLocatable::getCTM(element);
+    ctm->multiply(localMatrix());
+    return ctm;
+}
+
+SVGMatrix* SVGTransformable::getScreenCTM(const SVGElement* element) const
+{
+    SVGMatrix* ctm = SVGLocatable::getScreenCTM(element);
+    ctm->multiply(localMatrix());
+    return ctm;
+}
+
 void SVGTransformable::parseTransformAttribute(SVGTransformList* list, const AtomicString& transform)
 {
     // Split string for handling 1 transform statement at a time
index 5b0a2f9a6c7fd193303a0e1d71d05d702d307b39..fd8d358a99c16b7c7d253b30ddced9c084b79434 100644 (file)
@@ -39,10 +39,12 @@ namespace WebCore {
 
         // 'SVGTransformable' functions
         virtual SVGMatrix* localMatrix() const = 0;
-        
+
         virtual void updateLocalTransform(SVGTransformList*) = 0;
-        
+
         static void parseTransformAttribute(SVGTransformList*, const AtomicString& transform);
+        SVGMatrix* getCTM(const SVGElement*) const;
+        SVGMatrix* getScreenCTM(const SVGElement*) const;
     };
 
 } // namespace WebCore