REGRESSION (r91125): Polyline tool in google docs is broken
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Dec 2011 16:37:36 +0000 (16:37 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 Dec 2011 16:37:36 +0000 (16:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=65796

Source/WebCore:

Patch by Stephen Chenney <schenney@chromium.org> on 2011-12-02
Reviewed by Darin Adler.

Work around a bug in CoreGraphics, that caused incorrect bounds for paths
consisting only of move-to elements. This causes problems in SVG, when the enormous
bounds prevented the drawing of things behind.

Tests: svg/custom/path-moveto-only-rendering.svg
       svg/custom/subpaths-moveto-only-rendering.svg

* platform/graphics/cg/PathCG.cpp:
(WebCore::PathIsEmptyOrSingleMoveTester::PathIsEmptyOrSingleMoveTester): Class to
test for isEmpty accoridng ot the same rules as other platforms.
(WebCore::PathIsEmptyOrSingleMoveTester::isEmpty): Query the result
(WebCore::PathIsEmptyOrSingleMoveTester::testPathElement): Path iterator method
(WebCore::PathHasOnlyMoveToTester::PathHasOnlyMoveToTester): Class to test whether a
path contains only move-to elements, and hence should have null bounds.
(WebCore::PathHasOnlyMoveToTester::hasOnlyMoveTo): Query the result
(WebCore::PathHasOnlyMoveToTester::testPathElement): Path iterator method.
(WebCore::Path::boundingRect): Modified to check for move-to only paths
(WebCore::Path::fastBoundingRect): Modified to check for move-to only paths
(WebCore::Path::isEmpty): Now uses the method that matches other platforms.

LayoutTests:

Work around a bug in CoreGraphics, that caused incorrect bounds for paths
consisting only of move-to elements. This causes problems in SVG, when the enormous
bounds prevented the drawing of things behind.

Will revert expectation file when expectations are stable.

Patch by Stephen Chenney <schenney@chromium.org> on 2011-12-02
Reviewed by Darin Adler.

* platform/chromium-mac/svg/custom/zero-path-square-cap-rendering2-expected.txt: Removed.
* platform/chromium-win/svg/custom/zero-path-square-cap-rendering2-expected.txt: Removed.
* platform/mac/svg/custom/path-moveto-only-rendering-expected.png: Added.
* platform/mac/svg/custom/path-moveto-only-rendering-expected.txt: Added.
* platform/mac/svg/custom/subpaths-moveto-only-rendering-expected.png: Added.
* platform/mac/svg/custom/subpaths-moveto-only-rendering-expected.txt: Added.
* platform/win/svg/custom/path-moveto-only-rendering-expected.png: Added.
* platform/win/svg/custom/path-moveto-only-rendering-expected.txt: Added.
* platform/win/svg/custom/subpaths-moveto-only-rendering-expected.png: Added.
* platform/win/svg/custom/subpaths-moveto-only-rendering-expected.txt: Added.
* svg/custom/path-moveto-only-rendering.svg: Added.
* svg/custom/subpaths-moveto-only-rendering.svg: Added.
* svg/custom/zero-path-square-cap-rendering2-expected.txt: Modified text output
* platform/chromium/test_expectations.txt: Added flakiness for new tests from this patch

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

21 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/chromium-mac/svg/custom/path-moveto-only-rendering-expected.png [new file with mode: 0644]
LayoutTests/platform/chromium-mac/svg/custom/path-moveto-only-rendering-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium-mac/svg/custom/subpaths-moveto-only-rendering-expected.png [new file with mode: 0644]
LayoutTests/platform/chromium-mac/svg/custom/subpaths-moveto-only-rendering-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium-mac/svg/custom/zero-path-square-cap-rendering2-expected.txt [deleted file]
LayoutTests/platform/chromium-win/svg/custom/zero-path-square-cap-rendering2-expected.txt [deleted file]
LayoutTests/platform/chromium/test_expectations.txt
LayoutTests/platform/mac/svg/custom/path-moveto-only-rendering-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/custom/path-moveto-only-rendering-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/svg/custom/subpaths-moveto-only-rendering-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/custom/subpaths-moveto-only-rendering-expected.txt [new file with mode: 0644]
LayoutTests/platform/win/svg/custom/path-moveto-only-rendering-expected.png [new file with mode: 0644]
LayoutTests/platform/win/svg/custom/path-moveto-only-rendering-expected.txt [new file with mode: 0644]
LayoutTests/platform/win/svg/custom/subpaths-moveto-only-rendering-expected.png [new file with mode: 0644]
LayoutTests/platform/win/svg/custom/subpaths-moveto-only-rendering-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/path-moveto-only-rendering.svg [new file with mode: 0644]
LayoutTests/svg/custom/subpaths-moveto-only-rendering.svg [new file with mode: 0644]
LayoutTests/svg/custom/zero-path-square-cap-rendering2-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/cg/PathCG.cpp

index d0a89e2..5fdcc51 100644 (file)
@@ -1,3 +1,31 @@
+2011-12-02  Stephen Chenney  <schenney@chromium.org>
+
+        REGRESSION (r91125): Polyline tool in google docs is broken
+        https://bugs.webkit.org/show_bug.cgi?id=65796
+
+        Work around a bug in CoreGraphics, that caused incorrect bounds for paths
+        consisting only of move-to elements. This causes problems in SVG, when the enormous
+        bounds prevented the drawing of things behind.
+
+        Will revert expectation file when expectations are stable.
+
+        Reviewed by Darin Adler.
+
+        * platform/chromium-mac/svg/custom/zero-path-square-cap-rendering2-expected.txt: Removed.
+        * platform/chromium-win/svg/custom/zero-path-square-cap-rendering2-expected.txt: Removed.
+        * platform/mac/svg/custom/path-moveto-only-rendering-expected.png: Added.
+        * platform/mac/svg/custom/path-moveto-only-rendering-expected.txt: Added.
+        * platform/mac/svg/custom/subpaths-moveto-only-rendering-expected.png: Added.
+        * platform/mac/svg/custom/subpaths-moveto-only-rendering-expected.txt: Added.
+        * platform/win/svg/custom/path-moveto-only-rendering-expected.png: Added.
+        * platform/win/svg/custom/path-moveto-only-rendering-expected.txt: Added.
+        * platform/win/svg/custom/subpaths-moveto-only-rendering-expected.png: Added.
+        * platform/win/svg/custom/subpaths-moveto-only-rendering-expected.txt: Added.
+        * svg/custom/path-moveto-only-rendering.svg: Added.
+        * svg/custom/subpaths-moveto-only-rendering.svg: Added.
+        * svg/custom/zero-path-square-cap-rendering2-expected.txt: Modified text output
+        * platform/chromium/test_expectations.txt: Added flakiness for new tests from this patch
+
 2011-12-02  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         [Qt] fast/forms/select/listbox-in-multi-column.html fails
diff --git a/LayoutTests/platform/chromium-mac/svg/custom/path-moveto-only-rendering-expected.png b/LayoutTests/platform/chromium-mac/svg/custom/path-moveto-only-rendering-expected.png
new file mode 100644 (file)
index 0000000..f981ffc
Binary files /dev/null and b/LayoutTests/platform/chromium-mac/svg/custom/path-moveto-only-rendering-expected.png differ
diff --git a/LayoutTests/platform/chromium-mac/svg/custom/path-moveto-only-rendering-expected.txt b/LayoutTests/platform/chromium-mac/svg/custom/path-moveto-only-rendering-expected.txt
new file mode 100644 (file)
index 0000000..d67e35f
--- /dev/null
@@ -0,0 +1,7 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (0,0) size 77x77
+    RenderSVGContainer {g} at (0,0) size 77x77 [transform={m=((0.77,0.00)(0.00,0.77)) t=(0.00,0.00)}]
+      RenderSVGPath {rect} at (0,0) size 77x77 [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
+      RenderSVGPath {path} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#FF0000] [stroke width=496.95] [miter limit=8.00] [line cap=SQUARE]}] [fill={[type=SOLID] [color=#000000]}] [data="M 0 0"]
diff --git a/LayoutTests/platform/chromium-mac/svg/custom/subpaths-moveto-only-rendering-expected.png b/LayoutTests/platform/chromium-mac/svg/custom/subpaths-moveto-only-rendering-expected.png
new file mode 100644 (file)
index 0000000..f981ffc
Binary files /dev/null and b/LayoutTests/platform/chromium-mac/svg/custom/subpaths-moveto-only-rendering-expected.png differ
diff --git a/LayoutTests/platform/chromium-mac/svg/custom/subpaths-moveto-only-rendering-expected.txt b/LayoutTests/platform/chromium-mac/svg/custom/subpaths-moveto-only-rendering-expected.txt
new file mode 100644 (file)
index 0000000..2509f69
--- /dev/null
@@ -0,0 +1,7 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (0,0) size 77x77
+    RenderSVGContainer {g} at (0,0) size 77x77 [transform={m=((0.77,0.00)(0.00,0.77)) t=(0.00,0.00)}]
+      RenderSVGPath {rect} at (0,0) size 77x77 [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
+      RenderSVGPath {path} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#FF0000] [stroke width=496.95] [miter limit=8.00] [line cap=SQUARE]}] [fill={[type=SOLID] [color=#000000]}] [data="M 0 0 M 10 10"]
diff --git a/LayoutTests/platform/chromium-mac/svg/custom/zero-path-square-cap-rendering2-expected.txt b/LayoutTests/platform/chromium-mac/svg/custom/zero-path-square-cap-rendering2-expected.txt
deleted file mode 100644 (file)
index c55f49d..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderSVGRoot {svg} at (0,165) size 134x122
-    RenderSVGContainer {g} at (0,165) size 134x122 [transform={m=((1.09,0.00)(0.00,1.09)) t=(0.00,0.00)}]
-      RenderSVGPath {path} at (0,165) size 134x122 [fill={[type=SOLID] [color=#008000]}] [data="M 0 39403 L 103176 39403 L 103176 132091 L 0 132091 Z"]
-      RenderSVGPath {path} at (0,0) size 0x0 [fill={[type=SOLID] [color=#000000]}] [data="M 0 0"]
diff --git a/LayoutTests/platform/chromium-win/svg/custom/zero-path-square-cap-rendering2-expected.txt b/LayoutTests/platform/chromium-win/svg/custom/zero-path-square-cap-rendering2-expected.txt
deleted file mode 100644 (file)
index c55f49d..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderSVGRoot {svg} at (0,165) size 134x122
-    RenderSVGContainer {g} at (0,165) size 134x122 [transform={m=((1.09,0.00)(0.00,1.09)) t=(0.00,0.00)}]
-      RenderSVGPath {path} at (0,165) size 134x122 [fill={[type=SOLID] [color=#008000]}] [data="M 0 39403 L 103176 39403 L 103176 132091 L 0 132091 Z"]
-      RenderSVGPath {path} at (0,0) size 0x0 [fill={[type=SOLID] [color=#000000]}] [data="M 0 0"]
index a00c059..7cfcb98 100644 (file)
@@ -3789,6 +3789,9 @@ BUGWK73494 : svg/text/non-bmp-positioning-lists.svg = IMAGE+TEXT IMAGE
 BUGWK73494 : svg/as-image/svg-non-integer-scaled-image.html = IMAGE PASS
 BUGWK73494 DEBUG : svg/hixie/perf/007.xml = PASS TIMEOUT
 
+BUGWK73587 : svg/custom/path-moveto-only-rendering.svg = PASS IMAGE
+BUGWK73587 : svg/custom/subpaths-moveto-only-rendering.svg = PASS IMAGE
+
 BUGWK73514 WIN DEBUG : platform/chromium/compositing/lost-compositor-context-permanently.html = TIMEOUT
 BUGWK73517 WIN DEBUG : inspector/console/console-command-clear.html = CRASH
 BUGWK73517 DEBUG : inspector/debugger/script-formatter-breakpoints.html = CRASH TIMEOUT TEXT
diff --git a/LayoutTests/platform/mac/svg/custom/path-moveto-only-rendering-expected.png b/LayoutTests/platform/mac/svg/custom/path-moveto-only-rendering-expected.png
new file mode 100644 (file)
index 0000000..e16d7f8
Binary files /dev/null and b/LayoutTests/platform/mac/svg/custom/path-moveto-only-rendering-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/custom/path-moveto-only-rendering-expected.txt b/LayoutTests/platform/mac/svg/custom/path-moveto-only-rendering-expected.txt
new file mode 100644 (file)
index 0000000..d67e35f
--- /dev/null
@@ -0,0 +1,7 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (0,0) size 77x77
+    RenderSVGContainer {g} at (0,0) size 77x77 [transform={m=((0.77,0.00)(0.00,0.77)) t=(0.00,0.00)}]
+      RenderSVGPath {rect} at (0,0) size 77x77 [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
+      RenderSVGPath {path} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#FF0000] [stroke width=496.95] [miter limit=8.00] [line cap=SQUARE]}] [fill={[type=SOLID] [color=#000000]}] [data="M 0 0"]
diff --git a/LayoutTests/platform/mac/svg/custom/subpaths-moveto-only-rendering-expected.png b/LayoutTests/platform/mac/svg/custom/subpaths-moveto-only-rendering-expected.png
new file mode 100644 (file)
index 0000000..e16d7f8
Binary files /dev/null and b/LayoutTests/platform/mac/svg/custom/subpaths-moveto-only-rendering-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/custom/subpaths-moveto-only-rendering-expected.txt b/LayoutTests/platform/mac/svg/custom/subpaths-moveto-only-rendering-expected.txt
new file mode 100644 (file)
index 0000000..2509f69
--- /dev/null
@@ -0,0 +1,7 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (0,0) size 77x77
+    RenderSVGContainer {g} at (0,0) size 77x77 [transform={m=((0.77,0.00)(0.00,0.77)) t=(0.00,0.00)}]
+      RenderSVGPath {rect} at (0,0) size 77x77 [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
+      RenderSVGPath {path} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#FF0000] [stroke width=496.95] [miter limit=8.00] [line cap=SQUARE]}] [fill={[type=SOLID] [color=#000000]}] [data="M 0 0 M 10 10"]
diff --git a/LayoutTests/platform/win/svg/custom/path-moveto-only-rendering-expected.png b/LayoutTests/platform/win/svg/custom/path-moveto-only-rendering-expected.png
new file mode 100644 (file)
index 0000000..f981ffc
Binary files /dev/null and b/LayoutTests/platform/win/svg/custom/path-moveto-only-rendering-expected.png differ
diff --git a/LayoutTests/platform/win/svg/custom/path-moveto-only-rendering-expected.txt b/LayoutTests/platform/win/svg/custom/path-moveto-only-rendering-expected.txt
new file mode 100644 (file)
index 0000000..d67e35f
--- /dev/null
@@ -0,0 +1,7 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (0,0) size 77x77
+    RenderSVGContainer {g} at (0,0) size 77x77 [transform={m=((0.77,0.00)(0.00,0.77)) t=(0.00,0.00)}]
+      RenderSVGPath {rect} at (0,0) size 77x77 [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
+      RenderSVGPath {path} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#FF0000] [stroke width=496.95] [miter limit=8.00] [line cap=SQUARE]}] [fill={[type=SOLID] [color=#000000]}] [data="M 0 0"]
diff --git a/LayoutTests/platform/win/svg/custom/subpaths-moveto-only-rendering-expected.png b/LayoutTests/platform/win/svg/custom/subpaths-moveto-only-rendering-expected.png
new file mode 100644 (file)
index 0000000..f981ffc
Binary files /dev/null and b/LayoutTests/platform/win/svg/custom/subpaths-moveto-only-rendering-expected.png differ
diff --git a/LayoutTests/platform/win/svg/custom/subpaths-moveto-only-rendering-expected.txt b/LayoutTests/platform/win/svg/custom/subpaths-moveto-only-rendering-expected.txt
new file mode 100644 (file)
index 0000000..2509f69
--- /dev/null
@@ -0,0 +1,7 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderSVGRoot {svg} at (0,0) size 77x77
+    RenderSVGContainer {g} at (0,0) size 77x77 [transform={m=((0.77,0.00)(0.00,0.77)) t=(0.00,0.00)}]
+      RenderSVGPath {rect} at (0,0) size 77x77 [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=100.00] [height=100.00]
+      RenderSVGPath {path} at (0,0) size 0x0 [stroke={[type=SOLID] [color=#FF0000] [stroke width=496.95] [miter limit=8.00] [line cap=SQUARE]}] [fill={[type=SOLID] [color=#000000]}] [data="M 0 0 M 10 10"]
diff --git a/LayoutTests/svg/custom/path-moveto-only-rendering.svg b/LayoutTests/svg/custom/path-moveto-only-rendering.svg
new file mode 100644 (file)
index 0000000..595a3ca
--- /dev/null
@@ -0,0 +1,6 @@
+<svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg">
+  <g transform="scale(0.766666)">
+    <rect width="100" height="100" style="fill:green"/>
+    <path stroke="red" stroke-width="496.95" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="8" shape-rendering="optimizeSpeed" d="M 0 0"/>
+  </g>
+</svg>
diff --git a/LayoutTests/svg/custom/subpaths-moveto-only-rendering.svg b/LayoutTests/svg/custom/subpaths-moveto-only-rendering.svg
new file mode 100644 (file)
index 0000000..89798b0
--- /dev/null
@@ -0,0 +1,6 @@
+<svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg">
+  <g transform="scale(0.766666)">
+    <rect width="100" height="100" style="fill:green"/>
+    <path stroke="red" stroke-width="496.95" stroke-linecap="square" stroke-linejoin="miter" stroke-miterlimit="8" shape-rendering="optimizeSpeed" d="M 0 0 m 10 10"/>
+  </g>
+</svg>
index 473d929..c55f49d 100644 (file)
@@ -4,4 +4,4 @@ layer at (0,0) size 800x600
   RenderSVGRoot {svg} at (0,165) size 134x122
     RenderSVGContainer {g} at (0,165) size 134x122 [transform={m=((1.09,0.00)(0.00,1.09)) t=(0.00,0.00)}]
       RenderSVGPath {path} at (0,165) size 134x122 [fill={[type=SOLID] [color=#008000]}] [data="M 0 39403 L 103176 39403 L 103176 132091 L 0 132091 Z"]
-      RenderSVGPath {path} at (-2147483648,-2147483648) size -2147483648x-2147483648 [fill={[type=SOLID] [color=#000000]}] [data="M 0 0"]
+      RenderSVGPath {path} at (0,0) size 0x0 [fill={[type=SOLID] [color=#000000]}] [data="M 0 0"]
index cf7e238..8ae3c95 100644 (file)
@@ -1,3 +1,30 @@
+2011-12-02  Stephen Chenney  <schenney@chromium.org>
+
+        REGRESSION (r91125): Polyline tool in google docs is broken
+        https://bugs.webkit.org/show_bug.cgi?id=65796
+
+        Reviewed by Darin Adler.
+
+        Work around a bug in CoreGraphics, that caused incorrect bounds for paths
+        consisting only of move-to elements. This causes problems in SVG, when the enormous
+        bounds prevented the drawing of things behind.
+
+        Tests: svg/custom/path-moveto-only-rendering.svg
+               svg/custom/subpaths-moveto-only-rendering.svg
+
+        * platform/graphics/cg/PathCG.cpp:
+        (WebCore::PathIsEmptyOrSingleMoveTester::PathIsEmptyOrSingleMoveTester): Class to
+        test for isEmpty accoridng ot the same rules as other platforms.
+        (WebCore::PathIsEmptyOrSingleMoveTester::isEmpty): Query the result
+        (WebCore::PathIsEmptyOrSingleMoveTester::testPathElement): Path iterator method
+        (WebCore::PathHasOnlyMoveToTester::PathHasOnlyMoveToTester): Class to test whether a
+        path contains only move-to elements, and hence should have null bounds.
+        (WebCore::PathHasOnlyMoveToTester::hasOnlyMoveTo): Query the result
+        (WebCore::PathHasOnlyMoveToTester::testPathElement): Path iterator method.
+        (WebCore::Path::boundingRect): Modified to check for move-to only paths
+        (WebCore::Path::fastBoundingRect): Modified to check for move-to only paths
+        (WebCore::Path::isEmpty): Now uses the method that matches other platforms.
+
 2011-12-02  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r101794.
index b36c766..79a322f 100644 (file)
 
 namespace WebCore {
 
+// A class to provide an isEmpty test that considers a one-element path with only a MoveTo element
+// to be empty. This behavior is consistent with other platforms in WebKit, and is needed to prevent
+// incorrect (according to the spec) linecap stroking for zero length paths in SVG.
+class PathIsEmptyOrSingleMoveTester {
+public:
+    PathIsEmptyOrSingleMoveTester() : m_moveCount(0) { }
+
+    bool isEmpty() const
+    {
+        return m_moveCount <= 1;
+    }
+
+    static void testPathElement(void* info, const CGPathElement* element)
+    {
+        PathIsEmptyOrSingleMoveTester* tester = static_cast<PathIsEmptyOrSingleMoveTester*>(info);
+        if (element->type == kCGPathElementMoveToPoint)
+            ++tester->m_moveCount;
+        else {
+            // Any non move element implies a non-empty path; set the count to 2 to force
+            // isEmpty to return false.
+            tester->m_moveCount = 2;
+        }
+    }
+
+private:
+    // Any non-move-to element, or more than one move-to element, will make the count >= 2.
+    unsigned m_moveCount;
+};
+
+// Paths with only move-to elements do not draw under any circumstances, so their bound should
+// be empty. Currently, CoreGraphics returns non-empty bounds for such paths. Radar 10450621
+// tracks this. This class reports paths that have only move-to elements, allowing the
+// bounding box code to work around the CoreGraphics problem.
+class PathHasOnlyMoveToTester {
+public:
+    PathHasOnlyMoveToTester() : m_hasSeenOnlyMoveTo(true) { }
+
+    bool hasOnlyMoveTo() const
+    {
+        return m_hasSeenOnlyMoveTo;
+    }
+
+    static void testPathElement(void* info, const CGPathElement* element)
+    {
+        PathHasOnlyMoveToTester* tester = static_cast<PathHasOnlyMoveToTester*>(info);
+        if (tester->m_hasSeenOnlyMoveTo && element->type != kCGPathElementMoveToPoint)
+            tester->m_hasSeenOnlyMoveTo = false;
+    }
+
+private:
+    bool m_hasSeenOnlyMoveTo;
+};
+
 static size_t putBytesNowhere(void*, const void*, size_t count)
 {
     return count;
@@ -165,6 +218,14 @@ FloatRect Path::boundingRect() const
 {
     // CGPathGetBoundingBox includes the path's control points, CGPathGetPathBoundingBox
     // does not, but only exists on 10.6 and above.
+    // A bug in CoreGraphics leads to an incorrect bound on paths containing only move-to elements
+    // with a linecap style that is non-butt. All paths with only move-to elements (regardless of
+    // linecap) are effectively empty for bounding purposes and here we make it so.
+    PathHasOnlyMoveToTester tester;
+    CGPathApply(m_path, &tester, PathHasOnlyMoveToTester::testPathElement);
+    if (tester.hasOnlyMoveTo())
+        return FloatRect(0, 0, 0, 0);
+
 #if !defined(BUILDING_ON_LEOPARD)
     return CGPathGetPathBoundingBox(m_path);
 #else
@@ -174,6 +235,14 @@ FloatRect Path::boundingRect() const
 
 FloatRect Path::fastBoundingRect() const
 {
+    // A bug in CoreGraphics leads to an incorrect bound on paths containing only move-to elements
+    // with a linecap style that is non-butt. All paths with only move-to elements (regardless of
+    // linecap) are effectively empty for bounding purposes and here we make it so.
+    PathHasOnlyMoveToTester tester;
+    CGPathApply(m_path, &tester, PathHasOnlyMoveToTester::testPathElement);
+    if (tester.hasOnlyMoveTo())
+        return FloatRect(0, 0, 0, 0);
+
     return CGPathGetBoundingBox(m_path);
 }
 
@@ -252,7 +321,13 @@ void Path::clear()
 
 bool Path::isEmpty() const
 {
-    return CGPathIsEmpty(m_path);
+    // The SVG rendering code that uses this method relies on paths with a single move-to
+    // element, and nothing else, as being empty. Until that code is refactored to avoid
+    // the dependence on isEmpty, we match the behavior of other platforms.
+    // When the SVG code is refactored, we could use CGPathIsEmpty(m_path);
+    PathIsEmptyOrSingleMoveTester tester;
+    CGPathApply(m_path, &tester, PathIsEmptyOrSingleMoveTester::testPathElement);
+    return tester.isEmpty();
 }
 
 bool Path::hasCurrentPoint() const