Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / svg / getbbox.html
blob90ba56c28a345e3dba96b4664490b9f368da6bef
1 <!doctype html>
2 <title>getBBox tests</title>
3 <script src=../../resources/testharness.js></script>
4 <script src=../../resources/testharnessreport.js></script>
5 <div id="testcontainer">
6 <svg width="1" height="1" visibility="hidden">
7 <g id="g1">
8 <polygon id="p1" fill="none" stroke="red" />
9 <rect id="r1" x="50" y="50" width="50" height="50" fill="green" />
10 </g>
11 <g id="g2">
12 <rect id="r2" x="50" y="50" width="50" height="50" fill="green" />
13 <rect id="r3" x="20" y="20" width="20" height="0" fill="red" />
14 <rect id="r4" x="120" y="20" width="20" height="20" fill="blue" style="display:none" />
15 <ellipse id="c1" cx="20" cy="120" rx="0" ry="20" fill="black" />
16 <g>
17 <rect id="r5" x="120" y="120" width="-1" height="100" fill="cyan" />
18 </g>
19 </g>
20 <g id="g3">
21 <path id="p2" fill="none" stroke="red" />
22 <rect id="r6" x="50" y="50" width="50" height="50" fill="green" />
23 <!-- The following path should be included in the bbox. -->
24 <path d=""/>
25 </g>
26 <g id="g4">
27 <polyline id="p3" fill="none" stroke="red" />
28 <rect id="r7" x="50" y="50" width="50" height="50" fill="green" />
29 </g>
30 <g id="g5">
31 <path id="p4" d="M3"/>
32 <rect id="r8" x="50" y="50" width="50" height="50" fill="green" />
33 </g>
34 <g id="g6">
35 <polygon id="p5" points="47" fill="none" stroke="red" />
36 <rect id="r9" x="50" y="50" width="50" height="50" fill="green" />
37 </g>
38 <g id="g7">
39 <polyline id="p6" points="47" fill="none" stroke="red" />
40 <rect id="r10" x="50" y="50" width="50" height="50" fill="green" />
41 </g>
42 <g id="g8">
43 <path id="p7" d="M40 20h0" fill="none" stroke="red" />
44 <rect id="r11" x="50" y="50" width="50" height="50" fill="green" />
45 </g>
46 </svg>
47 </div>
48 <div id=log></div>
49 <script>
50 var EPSILON = Math.pow(2, -24); // float epsilon
52 function assert_rect_approx_equals(rect, expected, epsilon) {
53 assert_approx_equals(rect.x, expected.x, epsilon, "x");
54 assert_approx_equals(rect.y, expected.y, epsilon, "y");
55 assert_approx_equals(rect.width, expected.width, epsilon, "width");
56 assert_approx_equals(rect.height, expected.height, epsilon, "height");
59 test(function() {
60 assert_rect_approx_equals(document.getElementById("p1").getBBox(), {"x":0, "y":0, "width":0, "height":0 }, EPSILON);
61 }, "getBBox on polygon with no points attribute");
62 test(function() {
63 assert_rect_approx_equals(document.getElementById("p3").getBBox(), {"x":0, "y":0, "width":0, "height":0}, EPSILON);
64 }, "getBBox on polyline with no points attribute");
65 test(function() {
66 assert_rect_approx_equals(document.getElementById("p2").getBBox(), {"x":0, "y":0, "width":0, "height":0 }, EPSILON);
67 }, "getBBox on path with no d attribute");
68 test(function() {
69 assert_rect_approx_equals(document.getElementById("p4").getBBox(), {"x":0, "y":0, "width":0, "height":0 }, EPSILON);
70 }, "getBBox on path with no valid path segments in d attribute");
71 test(function() {
72 assert_rect_approx_equals(document.getElementById("p5").getBBox(), {"x":0, "y":0, "width":0, "height":0 }, EPSILON);
73 }, "getBBox on polygon with no valid point in the points attribute");
74 test(function() {
75 assert_rect_approx_equals(document.getElementById("p6").getBBox(), {"x":0, "y":0, "width":0, "height":0 }, EPSILON);
76 }, "getBBox on polyline with no valid point in the points attribute");
77 test(function() {
78 assert_rect_approx_equals(document.getElementById("g1").getBBox(), document.getElementById("r1").getBBox(), EPSILON);
79 }, "polygon doesn't contribute to parent bbox");
80 test(function() {
81 assert_rect_approx_equals(document.getElementById("g1").getBBox(), document.getElementById("r2").getBBox(), EPSILON);
82 }, "group with hidden child");
83 test(function() {
84 assert_rect_approx_equals(document.getElementById("g3").getBBox(), document.getElementById("r6").getBBox(), EPSILON);
85 }, "path doesn't contribute to parent bbox");
86 test(function() {
87 assert_rect_approx_equals(document.getElementById("g5").getBBox(), document.getElementById("r8").getBBox(), EPSILON);
88 }, "path with only invalid segments doesn't contribute to parent bbox");
89 test(function() {
90 assert_rect_approx_equals(document.getElementById("g4").getBBox(), document.getElementById("r7").getBBox(), EPSILON);
91 }, "polyline doesn't contribute to parent bbox");
92 test(function() {
93 assert_rect_approx_equals(document.getElementById("g6").getBBox(), document.getElementById("r9").getBBox(), EPSILON);
94 }, "polygon with no valid points doesn't contribute to parent bbox");
95 test(function() {
96 assert_rect_approx_equals(document.getElementById("g7").getBBox(), document.getElementById("r10").getBBox(), EPSILON);
97 }, "polyline with no valid points doesn't contribute to parent bbox");
98 test(function() {
99 assert_rect_approx_equals(document.getElementById("p7").getBBox(), {"x":40, "y":20, "width":0, "height":0 }, EPSILON);
100 }, "getBBox on path with no height");
101 test(function() {
102 assert_rect_approx_equals(document.getElementById("g8").getBBox(), {"x":40, "y":20, "width":60, "height":80 }, EPSILON);
103 }, "path with no height should contribute to parent bbox");
105 </script>