haikuwebkit/LayoutTests/svg/custom/GetBBox-path-nodata.html

54 lines
1.8 KiB
HTML
Raw Permalink Normal View History

Elements with rendering disabled due to dimensions should not contribute to parent bounding box https://bugs.webkit.org/show_bug.cgi?id=134184 Patch by Nikos Andronikos <nikos.andronikos-webkit@cisra.canon.com.au> on 2014-07-12 Reviewed by Dirk Schulze. Source/WebCore: SVG elements that have rendering disabled should not contribute to any ancestor elements bounding box. Examples of elements with rendering disabled: - basic shape with width <= 0 or height <= 0 - path with no path data (d attribute missing or empty) - polyline or polygon element with no point data (points attribute missing or empty) To achieve this a method (isRenderingDisabled) was added to RenderSVGShape and it's derived classes. This is used to determine if an element is included when creating the union of child bounding boxes in a container element. Tests: svg/custom/GetBBox-path-nodata.html svg/custom/GetBBox-polygon-nodata.html svg/custom/GetBBox-polyline-nodata.html svg/custom/getBBox-container-hiddenchild.html * rendering/svg/RenderSVGEllipse.cpp: (WebCore::RenderSVGEllipse::isRenderingDisabled): New method added. Checks bounding box to determine if rendering is disabled. * rendering/svg/RenderSVGEllipse.h: * rendering/svg/RenderSVGPath.cpp: (WebCore::RenderSVGPath::isRenderingDisabled): New method added. Checks bounding box to determine if rendering is disabled. * rendering/svg/RenderSVGPath.h: * rendering/svg/RenderSVGRect.cpp: (WebCore::RenderSVGRect::isRenderingDisabled): New method added. Checks bounding box to determine if rendering is disabled. * rendering/svg/RenderSVGRect.h: * rendering/svg/RenderSVGShape.h: (WebCore::RenderSVGShape::isRenderingDisabled): New method added. Always returns false so that derived classes that do not implement this method retain the existing behaviour. * rendering/svg/SVGRenderSupport.cpp: (WebCore::SVGRenderSupport::computeContainerBoundingBoxes): For each element potentially being included in the unioned bounding box of a container, check isRenderingDisabled and skip that element if true. * rendering/svg/RenderSVGEllipse.cpp: (WebCore::RenderSVGEllipse::isRenderingDisabled): * rendering/svg/RenderSVGEllipse.h: * rendering/svg/RenderSVGPath.cpp: (WebCore::RenderSVGPath::isRenderingDisabled): * rendering/svg/RenderSVGPath.h: * rendering/svg/RenderSVGRect.cpp: (WebCore::RenderSVGRect::isRenderingDisabled): * rendering/svg/RenderSVGRect.h: * rendering/svg/RenderSVGShape.h: * rendering/svg/SVGRenderSupport.cpp: (WebCore::SVGRenderSupport::computeContainerBoundingBoxes): LayoutTests: Test, for each element type, that when rendering is disabled, that element does not contribute to the bounding box for an ancestor element. Added test to ensure zero width/height polyline and polygon do contribute to ancestor bounding box. Updated expected results for 1 existing test (shapes-rect-02-t) as this test included zero width and zero height rects and these were previously included in the repaint rect. * platform/mac/svg/W3C-SVG-1.1/shapes-rect-02-t-expected.txt: * svg/custom/GetBBox-path-nodata-expected.txt: Added. * svg/custom/GetBBox-path-nodata.html: Added. * svg/custom/GetBBox-polygon-nodata-expected.txt: Added. * svg/custom/GetBBox-polygon-nodata.html: Added. * svg/custom/GetBBox-polyline-nodata-expected.txt: Added. * svg/custom/GetBBox-polyline-nodata.html: Added. * svg/custom/getBBox-container-hiddenchild-expected.txt: Added. * svg/custom/getBBox-container-hiddenchild.html: Added. * svg/custom/getBBox-perpendicular-polygon-expected.txt: Added. * svg/custom/getBBox-perpendicular-polygon.svg: Added. * svg/custom/getBBox-perpendicular-polyline-expected.txt: Added. * svg/custom/getBBox-perpendicular-polyline.svg: Added. Canonical link: https://commits.webkit.org/152818@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@171046 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2014-07-13 06:35:21 +00:00
<!DOCTYPE html>
<html>
<script>
function check_rect_bbox(bbox, expected_bbox, test_name)
{
var result = true;
var result_str = "";
if (bbox.x == expected_bbox.x && bbox.y == expected_bbox.y && bbox.width == expected_bbox.width && bbox.height == expected_bbox.height) {
result_str = "Passed";
} else {
result_str += test_name + ": Failed";
result_str += "("+bbox.x+","+bbox.y+":"+bbox.width + "," + bbox.height+")";
result = false;
}
var p_result = document.querySelector("#result");
p_result.appendChild(document.createTextNode(result_str + "; "));
return result;
}
function run()
{
if (window.testRunner)
testRunner.dumpAsText();
var p_bbox = document.querySelector("#p1").getBBox();
var g_bbox = document.querySelector("g").getBBox();
var result = true;
result &= check_rect_bbox(p_bbox, {"x":0, "y":0, "width":0, "height":0}, "getBBox on path with no d attribute")
result &= check_rect_bbox(g_bbox, document.querySelector("#r1").getBBox(),"path doesn't contribute to parent bbox")
if (!result) {
var visible_rect = document.querySelector("#r1");
visible_rect.setAttribute("fill", "red");
}
}
</script>
<body onload="run()">
<p>Bug <a href="https://bugs.webkit.org/show_bug.cgi?id=134184">134184</a>: getBBox on path with no d attribute should return (0,0,0,0) and should not contribute to parent bbox</p>
<p>For this test to pass, you should see 'Passed' twice below.</a>
<p id="result"></p>
<svg xmlns="http://www.w3.org/2000/svg">
<g>
<path id="p1" fill="none" stroke="red" />
<rect id="r1" x="50" y="50" width="50" height="50" fill="green" />
</g>
</svg>
</body>
</html>