getBBox() on a SVGPathElement with curves incorrectly includes control points
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Nov 2011 20:40:24 +0000 (20:40 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Nov 2011 20:40:24 +0000 (20:40 +0000)
commit0a41ad1f7e3cabab846391b387cde86f950a7937
treebbe0051892a514cb7a84bf07c44922100dabfc46
parent528f0d509607cd60533fbaf22989b02a904e7596
getBBox() on a SVGPathElement with curves incorrectly includes control points
https://bugs.webkit.org/show_bug.cgi?id=53512
<rdar://problem/9861154>

Reviewed by Oliver Hunt.

Split Path::boundingRect() into two, adding Path::fastBoundingRect()
for a rough estimate of the bounding rect (always equal to or larger
than boundingRect()). fastBoundingRect() currently falls back to
boundingRect() for all ports besides CG, though in most cases
(on a port-by-port basis) the current implementation of boundingRect()
will need to become fastBoundingRect(), and a new, more accurate method will
be implemented for boundingRect().

All previous callers of boundingRect() are transitioned to using fastBoundingRect()
except SVGPathElement::getBBox, which wants an accurate bounding box.

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

* html/HTMLAreaElement.cpp:
* html/canvas/CanvasRenderingContext2D.cpp:
* platform/graphics/Path.cpp:
* platform/graphics/Path.h:
* platform/graphics/cg/GraphicsContextCG.cpp:
* platform/graphics/cg/PathCG.cpp:
(WebCore::Path::boundingRect):
* rendering/RenderObject.h:
* rendering/svg/RenderSVGPath.cpp:
* svg/SVGPathElement.cpp:
* svg/SVGPathElement.h:

Add a test that ensures that getBBox does not include control points in the rect it returns.

* platform/chromium/test_expectations.txt:
* svg/custom/getBBox-path-expected.txt: Added.
* svg/custom/getBBox-path.svg: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@99460 268f45cc-cd09-0410-ab3c-d52691b4dbfc
15 files changed:
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/html/HTMLAreaElement.cpp
Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
Source/WebCore/platform/graphics/Path.cpp
Source/WebCore/platform/graphics/Path.h
Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp
Source/WebCore/platform/graphics/cg/PathCG.cpp
Source/WebCore/rendering/RenderObject.h
Source/WebCore/rendering/svg/RenderSVGPath.cpp
Source/WebCore/svg/SVGPathElement.cpp
Source/WebCore/svg/SVGPathElement.h