Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(561)

Unified Diff: LayoutTests/fast/svg/getbbox.html

Issue 355813004: [SVG2] Elements that don't render shouldn't contribute to ancestor bboxes. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fix nit Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/svg/getbbox.html
diff --git a/LayoutTests/fast/svg/getbbox.html b/LayoutTests/fast/svg/getbbox.html
new file mode 100644
index 0000000000000000000000000000000000000000..3a76932ad9b70dda6a111590903098b2c17feb2a
--- /dev/null
+++ b/LayoutTests/fast/svg/getbbox.html
@@ -0,0 +1,95 @@
+<!doctype html>
+<title>getBBox tests</title>
+<script src=../../resources/testharness.js></script>
+<script src=../../resources/testharnessreport.js></script>
+<div id="testcontainer">
+<svg width="1" height="1" visibility="hidden">
+<g id="g1">
+ <polygon id="p1" fill="none" stroke="red" />
+ <rect id="r1" x="50" y="50" width="50" height="50" fill="green" />
+</g>
+<g id="g2">
+ <rect id="r2" x="50" y="50" width="50" height="50" fill="green" />
+ <rect id="r3" x="20" y="20" width="20" height="0" fill="red" />
+ <rect id="r4" x="120" y="20" width="20" height="20" fill="blue" style="display:none" />
+ <ellipse id="c1" cx="20" cy="120" rx="0" ry="20" fill="black" />
+ <g>
+ <rect id="r5" x="120" y="120" width="-1" height="100" fill="cyan" />
+ </g>
+</g>
+<g id="g3">
+ <path id="p2" fill="none" stroke="red" />
+ <rect id="r6" x="50" y="50" width="50" height="50" fill="green" />
+ <!-- The following path should be included in the bbox. -->
+ <path d=""
+</g>
+<g id="g4">
+ <polyline id="p3" fill="none" stroke="red" />
+ <rect id="r7" x="50" y="50" width="50" height="50" fill="green" />
+</g>
+<g id="g5">
+ <path id="p4" d="M3"/>
+ <rect id="r8" x="50" y="50" width="50" height="50" fill="green" />
+</g>
+<g id="g6">
+ <polygon id="p5" points="47" fill="none" stroke="red" />
+ <rect id="r9" x="50" y="50" width="50" height="50" fill="green" />
+</g>
+<g id="g7">
+ <polyline id="p6" points="47" fill="none" stroke="red" />
+ <rect id="r10" x="50" y="50" width="50" height="50" fill="green" />
+</g>
+</svg>
+</div>
+<div id=log></div>
+<script>
+var EPSILON = Math.pow(2, -24); // float epsilon
+
+function assert_rect_approx_equals(rect, expected, epsilon) {
+ assert_approx_equals(rect.x, expected.x, epsilon, "x");
+ assert_approx_equals(rect.y, expected.y, epsilon, "y");
+ assert_approx_equals(rect.width, expected.width, epsilon, "width");
+ assert_approx_equals(rect.height, expected.height, epsilon, "height");
+}
+
+test(function() {
+ assert_rect_approx_equals(document.getElementById("p1").getBBox(), {"x":0, "y":0, "width":0, "height":0 }, EPSILON);
+}, "getBBox on polygon with no points attribute");
+test(function() {
+ assert_rect_approx_equals(document.getElementById("p3").getBBox(), {"x":0, "y":0, "width":0, "height":0}, EPSILON);
+}, "getBBox on polyline with no points attribute");
+test(function() {
+ assert_rect_approx_equals(document.getElementById("p2").getBBox(), {"x":0, "y":0, "width":0, "height":0 }, EPSILON);
+}, "getBBox on path with no d attribute");
+test(function() {
+ assert_rect_approx_equals(document.getElementById("p4").getBBox(), {"x":0, "y":0, "width":0, "height":0 }, EPSILON);
+}, "getBBox on path with no valid path segments in d attribute");
+test(function() {
+ assert_rect_approx_equals(document.getElementById("p5").getBBox(), {"x":0, "y":0, "width":0, "height":0 }, EPSILON);
+}, "getBBox on polygon with no valid point in the points attribute");
+test(function() {
+ assert_rect_approx_equals(document.getElementById("p6").getBBox(), {"x":0, "y":0, "width":0, "height":0 }, EPSILON);
+}, "getBBox on polyline with no valid point in the points attribute");
+test(function() {
+ assert_rect_approx_equals(document.getElementById("g1").getBBox(), document.getElementById("r1").getBBox(), EPSILON);
+}, "polygon doesn't contribute to parent bbox");
+test(function() {
+ assert_rect_approx_equals(document.getElementById("g1").getBBox(), document.getElementById("r2").getBBox(), EPSILON);
+}, "group with hidden child");
+test(function() {
+ assert_rect_approx_equals(document.getElementById("g3").getBBox(), document.getElementById("r6").getBBox(), EPSILON);
+}, "path doesn't contribute to parent bbox");
+test(function() {
+ assert_rect_approx_equals(document.getElementById("g5").getBBox(), document.getElementById("r8").getBBox(), EPSILON);
+}, "path with only invalid segments doesn't contribute to parent bbox");
+test(function() {
+ assert_rect_approx_equals(document.getElementById("g4").getBBox(), document.getElementById("r7").getBBox(), EPSILON);
+}, "polyline doesn't contribute to parent bbox");
+test(function() {
+ assert_rect_approx_equals(document.getElementById("g6").getBBox(), document.getElementById("r9").getBBox(), EPSILON);
+}, "polygon with no valid points doesn't contribute to parent bbox");
+test(function() {
+ assert_rect_approx_equals(document.getElementById("g7").getBBox(), document.getElementById("r10").getBBox(), EPSILON);
+}, "polyline with no valid points doesn't contribute to parent bbox");
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698