Diff
Modified: trunk/LayoutTests/ChangeLog (101902 => 101903)
--- trunk/LayoutTests/ChangeLog 2011-12-03 05:26:52 UTC (rev 101902)
+++ trunk/LayoutTests/ChangeLog 2011-12-03 05:34:42 UTC (rev 101903)
@@ -1,3 +1,27 @@
+2011-12-02 Stephen Chenney <[email protected]>
+
+ 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.
+ * 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 Vincent Scheib <[email protected]>
[Chromium] test_expectations typo fix for chunked-progress-event-expectedLength.html
Modified: trunk/LayoutTests/platform/chromium/test_expectations.txt (101902 => 101903)
--- trunk/LayoutTests/platform/chromium/test_expectations.txt 2011-12-03 05:26:52 UTC (rev 101902)
+++ trunk/LayoutTests/platform/chromium/test_expectations.txt 2011-12-03 05:34:42 UTC (rev 101903)
@@ -3818,6 +3818,9 @@
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
Deleted: trunk/LayoutTests/platform/chromium-mac/svg/custom/zero-path-square-cap-rendering2-expected.txt (101902 => 101903)
--- trunk/LayoutTests/platform/chromium-mac/svg/custom/zero-path-square-cap-rendering2-expected.txt 2011-12-03 05:26:52 UTC (rev 101902)
+++ trunk/LayoutTests/platform/chromium-mac/svg/custom/zero-path-square-cap-rendering2-expected.txt 2011-12-03 05:34:42 UTC (rev 101903)
@@ -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="" 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="" 0 0"]
Deleted: trunk/LayoutTests/platform/chromium-win/svg/custom/zero-path-square-cap-rendering2-expected.txt (101902 => 101903)
--- trunk/LayoutTests/platform/chromium-win/svg/custom/zero-path-square-cap-rendering2-expected.txt 2011-12-03 05:26:52 UTC (rev 101902)
+++ trunk/LayoutTests/platform/chromium-win/svg/custom/zero-path-square-cap-rendering2-expected.txt 2011-12-03 05:34:42 UTC (rev 101903)
@@ -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="" 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="" 0 0"]
Added: trunk/LayoutTests/platform/mac/svg/custom/path-moveto-only-rendering-expected.png (0 => 101903)
--- trunk/LayoutTests/platform/mac/svg/custom/path-moveto-only-rendering-expected.png (rev 0)
+++ trunk/LayoutTests/platform/mac/svg/custom/path-moveto-only-rendering-expected.png 2011-12-03 05:34:42 UTC (rev 101903)
@@ -0,0 +1,5 @@
+\x89PNG
+
+
+IHDR X \x9Av\x82p )tEXtchecksum 61e83440d4a92dbbfce8190495beedaf\xDB\xFF \x92IDATx\x9C\xED\xDAA
+\xC30 \xC1\xA4*\x8C"\x83 1\x9F\xE2 I\x97B_kE\x99Apߕn߾\xDB\xDC\xF8\xDB8\xC6v\x8Dk\xF5 \xB8\xA5\xD7\xEA \xC0s #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\xCC{c\xF5\x86[9?\xE7\xEA p[\xFB\x9Cs\xAE <\x83 \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @\xE6'G\x84\xF8\x96 IEND\xAEB`\x82
\ No newline at end of file
Added: trunk/LayoutTests/platform/mac/svg/custom/path-moveto-only-rendering-expected.txt (0 => 101903)
--- trunk/LayoutTests/platform/mac/svg/custom/path-moveto-only-rendering-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac/svg/custom/path-moveto-only-rendering-expected.txt 2011-12-03 05:34:42 UTC (rev 101903)
@@ -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="" 0 0"]
Added: trunk/LayoutTests/platform/mac/svg/custom/subpaths-moveto-only-rendering-expected.png (0 => 101903)
--- trunk/LayoutTests/platform/mac/svg/custom/subpaths-moveto-only-rendering-expected.png (rev 0)
+++ trunk/LayoutTests/platform/mac/svg/custom/subpaths-moveto-only-rendering-expected.png 2011-12-03 05:34:42 UTC (rev 101903)
@@ -0,0 +1,5 @@
+\x89PNG
+
+
+IHDR X \x9Av\x82p )tEXtchecksum 61e83440d4a92dbbfce8190495beedaf\xDB\xFF \x92IDATx\x9C\xED\xDAA
+\xC30 \xC1\xA4*\x8C"\x83 1\x9F\xE2 I\x97B_kE\x99Apߕn߾\xDB\xDC\xF8\xDB8\xC6v\x8Dk\xF5 \xB8\xA5\xD7\xEA \xC0s #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\x8C 2 \xC8 #@ \x80\xCC{c\xF5\x86[9?\xE7\xEA p[\xFB\x9Cs\xAE <\x83 \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @F\x80 d \x90 @\xE6'G\x84\xF8\x96 IEND\xAEB`\x82
\ No newline at end of file
Added: trunk/LayoutTests/platform/mac/svg/custom/subpaths-moveto-only-rendering-expected.txt (0 => 101903)
--- trunk/LayoutTests/platform/mac/svg/custom/subpaths-moveto-only-rendering-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac/svg/custom/subpaths-moveto-only-rendering-expected.txt 2011-12-03 05:34:42 UTC (rev 101903)
@@ -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="" 0 0 M 10 10"]
Added: trunk/LayoutTests/svg/custom/path-moveto-only-rendering.svg (0 => 101903)
--- trunk/LayoutTests/svg/custom/path-moveto-only-rendering.svg (rev 0)
+++ trunk/LayoutTests/svg/custom/path-moveto-only-rendering.svg 2011-12-03 05:34:42 UTC (rev 101903)
@@ -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>
Added: trunk/LayoutTests/svg/custom/subpaths-moveto-only-rendering.svg (0 => 101903)
--- trunk/LayoutTests/svg/custom/subpaths-moveto-only-rendering.svg (rev 0)
+++ trunk/LayoutTests/svg/custom/subpaths-moveto-only-rendering.svg 2011-12-03 05:34:42 UTC (rev 101903)
@@ -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>
Modified: trunk/LayoutTests/svg/custom/zero-path-square-cap-rendering2-expected.txt (101902 => 101903)
--- trunk/LayoutTests/svg/custom/zero-path-square-cap-rendering2-expected.txt 2011-12-03 05:26:52 UTC (rev 101902)
+++ trunk/LayoutTests/svg/custom/zero-path-square-cap-rendering2-expected.txt 2011-12-03 05:34:42 UTC (rev 101903)
@@ -4,4 +4,4 @@
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="" 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="" 0 0"]
+ RenderSVGPath {path} at (0,0) size 0x0 [fill={[type=SOLID] [color=#000000]}] [data="" 0 0"]
Modified: trunk/Source/WebCore/ChangeLog (101902 => 101903)
--- trunk/Source/WebCore/ChangeLog 2011-12-03 05:26:52 UTC (rev 101902)
+++ trunk/Source/WebCore/ChangeLog 2011-12-03 05:34:42 UTC (rev 101903)
@@ -1,3 +1,32 @@
+2011-12-02 Stephen Chenney <[email protected]>
+
+ 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.
+ (WebCore::Path::hasCurrentPoint): Now uses CGPathIsEmpty directly
+ (WebCore::Path::transform) : Now uses CGPathIsEmpty directly
+
2011-12-02 Mihnea Ovidenie <[email protected]>
[CSSRegions]More renaming for region style rules.
Modified: trunk/Source/WebCore/platform/graphics/cg/PathCG.cpp (101902 => 101903)
--- trunk/Source/WebCore/platform/graphics/cg/PathCG.cpp 2011-12-03 05:26:52 UTC (rev 101902)
+++ trunk/Source/WebCore/platform/graphics/cg/PathCG.cpp 2011-12-03 05:34:42 UTC (rev 101903)
@@ -41,6 +41,59 @@
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 @@
{
// 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::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,12 +321,18 @@
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
{
- return !isEmpty();
+ return !CGPathIsEmpty(m_path);
}
FloatPoint Path::currentPoint() const
@@ -311,7 +386,7 @@
void Path::transform(const AffineTransform& transform)
{
- if (transform.isIdentity() || isEmpty())
+ if (transform.isIdentity() || CGPathIsEmpty(m_path))
return;
CGMutablePathRef path = CGPathCreateMutable();