getBBox() on a SVGPathElement with curves incorrectly includes control points
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Aug 2011 22:12:02 +0000 (22:12 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Aug 2011 22:12:02 +0000 (22:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=53512
<rdar://problem/9861154>

Reviewed by Dirk Schulze.

The CoreGraphics implementation of Path::boundingRect() called
CGPathGetBoundingBox, which includes the path's control points in its
calculations. Snow Leopard added CGPathGetPathBoundingBox, which
finds the bounding box of only points within the path, and does not
include control points. On Snow Leopard and above, we now use the latter.

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

LayoutTests/ChangeLog
LayoutTests/platform/chromium/test_expectations.txt
LayoutTests/svg/custom/getBBox-path-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/getBBox-path.svg [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/cg/PathCG.cpp

index ca7282f..b17a93d 100644 (file)
@@ -1,5 +1,20 @@
 2011-08-30  Tim Horton  <timothy_horton@apple.com>
 
+        getBBox() on a SVGPathElement with curves incorrectly includes control points
+        https://bugs.webkit.org/show_bug.cgi?id=53512
+        <rdar://problem/9861154>
+
+        Reviewed by Dirk Schulze.
+
+        Add a test ensuring that getBBox returns only the bounds of the filled shape,
+        not the bounds of all of the control points.
+
+        * platform/chromium/test_expectations.txt:
+        * svg/custom/getBBox-path-expected.txt: Added.
+        * svg/custom/getBBox-path.svg: Added.
+
+2011-08-30  Tim Horton  <timothy_horton@apple.com>
+
         SVG panning y-axis is flipped in WebKit2
         https://bugs.webkit.org/show_bug.cgi?id=65800
         <rdar://problem/9908012>
index 46ec393..5fa0c5e 100644 (file)
@@ -3587,6 +3587,9 @@ BUGWK65862 MAC DEBUG SLOW : storage/indexeddb/index-cursor.html = PASS
 // Caused by r92618
 BUGWK65874 : fast/js/preventExtensions.html = TEXT
 
+// Introduced due to BUGWK53512, fails under Skia right now
+BUGWK65939 : svg/custom/getBBox-path.svg = TEXT
+
 // Caused by r92704
 BUGWK65951 WIN DEBUG : webaudio/audiobuffersource.html = CRASH
 BUGWK65951 WIN DEBUG : webaudio/mixing.html = CRASH
diff --git a/LayoutTests/svg/custom/getBBox-path-expected.txt b/LayoutTests/svg/custom/getBBox-path-expected.txt
new file mode 100644 (file)
index 0000000..86db678
--- /dev/null
@@ -0,0 +1 @@
+100 37.5 PASS
diff --git a/LayoutTests/svg/custom/getBBox-path.svg b/LayoutTests/svg/custom/getBBox-path.svg
new file mode 100644 (file)
index 0000000..21dca93
--- /dev/null
@@ -0,0 +1,21 @@
+<?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 txt = document.getElementById("text");
+        size = document.getElementById("shape").getBBox();
+        var passState = "FAIL";
+        if(size.width == 100 && size.height == 37.5)
+            passState = "PASS";
+        var textNode = document.createTextNode(size.width + " " + size.height + " " + passState);
+        txt.appendChild(textNode);
+    }
+  ]]>
+  </script>
+  <path id="shape" d="M100,100 C125,150 175,150 200,100 z" />
+  <text id="text" x="50" y="50" />
+</svg>
index b673349..18901c4 100644 (file)
@@ -1,5 +1,24 @@
 2011-08-30  Tim Horton  <timothy_horton@apple.com>
 
+        getBBox() on a SVGPathElement with curves incorrectly includes control points
+        https://bugs.webkit.org/show_bug.cgi?id=53512
+        <rdar://problem/9861154>
+
+        Reviewed by Dirk Schulze.
+
+        The CoreGraphics implementation of Path::boundingRect() called
+        CGPathGetBoundingBox, which includes the path's control points in its
+        calculations. Snow Leopard added CGPathGetPathBoundingBox, which
+        finds the bounding box of only points within the path, and does not
+        include control points. On Snow Leopard and above, we now use the latter.
+
+        Test: svg/custom/getBBox-path.svg
+
+        * platform/graphics/cg/PathCG.cpp:
+        (WebCore::Path::boundingRect):
+
+2011-08-30  Tim Horton  <timothy_horton@apple.com>
+
         SVG panning y-axis is flipped in WebKit2
         https://bugs.webkit.org/show_bug.cgi?id=65800
         <rdar://problem/9908012>
index 514444b..acfe105 100644 (file)
@@ -163,7 +163,13 @@ void Path::translate(const FloatSize& size)
 
 FloatRect Path::boundingRect() const
 {
+    // CGPathGetBoundingBox includes the path's control points, CGPathGetPathBoundingBox
+    // does not, but only exists on 10.6 and above.
+#if !defined(BUILDING_ON_LEOPARD)
+    return CGPathGetPathBoundingBox(m_path);
+#else
     return CGPathGetBoundingBox(m_path);
+#endif
 }
 
 FloatRect Path::strokeBoundingRect(StrokeStyleApplier* applier) const