Reviewed by Mitz.
authorrwlbuis <rwlbuis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Dec 2006 21:47:46 +0000 (21:47 +0000)
committerrwlbuis <rwlbuis@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Dec 2006 21:47:46 +0000 (21:47 +0000)
        http://bugs.webkit.org/show_bug.cgi?id=11686
        WebKit draws Carto.net tabgroup example completely incorrectly (ff does fine)

        Make sure the SVG render objects are laid out before measuring their
        dimensions using relativeBBox.

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

LayoutTests/ChangeLog
LayoutTests/svg/custom/getBBox-js-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/getBBox-js.svg [new file with mode: 0644]
WebCore/ChangeLog
WebCore/ksvg2/svg/SVGLocatable.cpp

index b3e2987e679f7f61d21f1470fde63cca68cb1398..4e5e8db9b91158bca8f4ed295b829f0f7af2a359 100644 (file)
@@ -1,3 +1,14 @@
+2006-12-05  Rob Buis  <buis@kde.org>
+
+        Reviewed by Mitz.
+
+        Testcase for:
+        http://bugs.webkit.org/show_bug.cgi?id=11686
+        WebKit draws Carto.net tabgroup example completely incorrectly (ff does fine)
+
+        * svg/custom/getBBox-js-expected.txt: Added.
+        * svg/custom/getBBox-js.svg: Added.
+
 2006-12-05  Kirby White  <KWhiteRight@gmail.com>
 
         Reviewed and landed by Alexey.
diff --git a/LayoutTests/svg/custom/getBBox-js-expected.txt b/LayoutTests/svg/custom/getBBox-js-expected.txt
new file mode 100644 (file)
index 0000000..c6e564d
--- /dev/null
@@ -0,0 +1,43 @@
+
+  
+  
+    function init()
+    {
+        if (window.layoutTestController)
+            layoutTestController.dumpAsText();
+        var g = document.createElementNS("http://www.w3.org/2000/svg", "g");
+        document.rootElement.appendChild(g);
+        var txt = document.createElementNS("http://www.w3.org/2000/svg", "text");
+        txt.setAttribute("x", "50");
+        txt.setAttribute("y", "50");
+        var textNode = document.createTextNode("Failed");
+        txt.appendChild(textNode);
+        g.appendChild(txt);
+        if (g.getBBox().width > 0 && g.getBBox().height > 0) {
+            if (txt.getBBox().width > 0 && txt.getBBox().height > 0) {
+                var img = document.createElementNS("http://www.w3.org/2000/svg", "image");
+                img.setAttribute("x", "0");
+                img.setAttribute("y", "0");
+                img.setAttribute("width", "100");
+                img.setAttribute("height", "100");
+                img.setAttribute("visibility", "hidden");
+                img.setAttributeNS("http://www.w3.org/1999/xlink", "href", "resources/magnify.png");
+                g.appendChild(img);
+                if (img.getBBox().width > 0 && img.getBBox().height > 0) {
+                    var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
+                    rect.setAttribute("x", "0");
+                    rect.setAttribute("y", "0");
+                    rect.setAttribute("width", "100");
+                    rect.setAttribute("height", "100");
+                    rect.setAttribute("visibility", "hidden");
+                    g.appendChild(rect);
+                    if (rect.getBBox().width > 0 && rect.getBBox().height > 0) {
+                    textNode.data = "Passed";
+                    }
+                }
+            }
+        }
+    }
+  
+  
+Passed
diff --git a/LayoutTests/svg/custom/getBBox-js.svg b/LayoutTests/svg/custom/getBBox-js.svg
new file mode 100644 (file)
index 0000000..f3b63da
--- /dev/null
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" onload="init()">
+  <script type="text/javascript">
+  <![CDATA[
+    function init()
+    {
+        if (window.layoutTestController)
+            layoutTestController.dumpAsText();
+        var g = document.createElementNS("http://www.w3.org/2000/svg", "g");
+        document.rootElement.appendChild(g);
+        var txt = document.createElementNS("http://www.w3.org/2000/svg", "text");
+        txt.setAttribute("x", "50");
+        txt.setAttribute("y", "50");
+        var textNode = document.createTextNode("Failed");
+        txt.appendChild(textNode);
+        g.appendChild(txt);
+        if (g.getBBox().width > 0 && g.getBBox().height > 0) {
+            if (txt.getBBox().width > 0 && txt.getBBox().height > 0) {
+                var img = document.createElementNS("http://www.w3.org/2000/svg", "image");
+                img.setAttribute("x", "0");
+                img.setAttribute("y", "0");
+                img.setAttribute("width", "100");
+                img.setAttribute("height", "100");
+                img.setAttribute("visibility", "hidden");
+                img.setAttributeNS("http://www.w3.org/1999/xlink", "href", "resources/magnify.png");
+                g.appendChild(img);
+                if (img.getBBox().width > 0 && img.getBBox().height > 0) {
+                    var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
+                    rect.setAttribute("x", "0");
+                    rect.setAttribute("y", "0");
+                    rect.setAttribute("width", "100");
+                    rect.setAttribute("height", "100");
+                    rect.setAttribute("visibility", "hidden");
+                    g.appendChild(rect);
+                    if (rect.getBBox().width > 0 && rect.getBBox().height > 0) {
+                    textNode.data = "Passed";
+                    }
+                }
+            }
+        }
+    }
+  ]]>
+  </script>
+</svg>
index 317de8e3a10d269fb9cde5c3e2eca7a8c80fea53..0a71d8a2740c5a21d20a8c473aa116176cfb9a84 100644 (file)
@@ -1,3 +1,16 @@
+2006-12-05  Rob Buis  <buis@kde.org>
+
+        Reviewed by Mitz.
+
+        http://bugs.webkit.org/show_bug.cgi?id=11686
+        WebKit draws Carto.net tabgroup example completely incorrectly (ff does fine)
+
+        Make sure the SVG render objects are laid out before measuring their 
+        dimensions using relativeBBox.
+
+        * ksvg2/svg/SVGLocatable.cpp:
+        (WebCore::SVGLocatable::getBBox):
+
 2006-12-05  John Sullivan  <sullivan@apple.com>
 
         Reviewed by Darin
index 188fe9cce1fe772a0bc995cc9062e32dbf4035a2..3a26387ed516e68cc3cc15b533ce434ac6976872 100644 (file)
@@ -76,8 +76,11 @@ SVGElement* SVGLocatable::farthestViewportElement(const SVGStyledElement* e)
 FloatRect SVGLocatable::getBBox(const SVGStyledElement* e)
 {
     FloatRect bboxRect;
-    
+
     if (e && e->renderer()) {
+        // Need this to make sure we have render object dimensions.
+        // See bug 11686.
+        e->document()->updateLayoutIgnorePendingStylesheets();
         bboxRect = e->renderer()->relativeBBox(false);
         bboxRect.setSize(bboxRect.size() - FloatSize(1, 1)); // FIXME: Why -1 here?
     }